mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Everyone needs to be able to split BPPs these days.
This commit is contained in:
parent
df63d148e5
commit
3089e60fbd
@ -792,9 +792,7 @@ void _glfwPlatformRefreshWindowParams(void)
|
|||||||
forAttribute:NSOpenGLPFAColorSize
|
forAttribute:NSOpenGLPFAColorSize
|
||||||
forVirtualScreen:0];
|
forVirtualScreen:0];
|
||||||
value -= window->alphaBits;
|
value -= window->alphaBits;
|
||||||
window->redBits = value / 3;
|
_glfwSplitBPP(value, &window->redBits, &window->greenBits, &window->blueBits);
|
||||||
window->greenBits = value / 3;
|
|
||||||
window->blueBits = value / 3;
|
|
||||||
|
|
||||||
[window->NSGL.pixelFormat getValues:&value
|
[window->NSGL.pixelFormat getValues:&value
|
||||||
forAttribute:NSOpenGLPFADepthSize
|
forAttribute:NSOpenGLPFADepthSize
|
||||||
|
@ -63,6 +63,35 @@ static int compareVideoModes(const void* firstPtr, const void* secondPtr)
|
|||||||
return firstSize - secondSize;
|
return firstSize - secondSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Convert BPP to RGB bits based on "best guess"
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue)
|
||||||
|
{
|
||||||
|
int delta;
|
||||||
|
|
||||||
|
// We assume that by 32 they really meant 24
|
||||||
|
if (bpp == 32)
|
||||||
|
bpp = 24;
|
||||||
|
|
||||||
|
// Convert "bits per pixel" to red, green & blue sizes
|
||||||
|
|
||||||
|
*red = *green = *blue = bpp / 3;
|
||||||
|
delta = bpp - (*red * 3);
|
||||||
|
if (delta >= 1)
|
||||||
|
*green = *green + 1;
|
||||||
|
|
||||||
|
if (delta == 2)
|
||||||
|
*red = *red + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -284,6 +284,9 @@ void* _glfwPlatformGetProcAddress(const char* procname);
|
|||||||
// Prototypes for platform independent internal functions
|
// Prototypes for platform independent internal functions
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
|
// Fullscren management (fullscreen.c)
|
||||||
|
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
void _glfwSetError(int error);
|
void _glfwSetError(int error);
|
||||||
|
|
||||||
|
@ -34,30 +34,6 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Convert BPP to RGB bits based on "best guess"
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void bpp2rgb(int bpp, int* r, int* g, int* b)
|
|
||||||
{
|
|
||||||
int delta;
|
|
||||||
|
|
||||||
// We assume that by 32 they really meant 24
|
|
||||||
if (bpp == 32)
|
|
||||||
bpp = 24;
|
|
||||||
|
|
||||||
// Convert "bits per pixel" to red, green & blue sizes
|
|
||||||
|
|
||||||
*r = *g = *b = bpp / 3;
|
|
||||||
delta = bpp - (*r * 3);
|
|
||||||
if (delta >= 1)
|
|
||||||
*g = *g + 1;
|
|
||||||
|
|
||||||
if (delta == 2)
|
|
||||||
*r = *r + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Return closest video mode by dimensions, refresh rate and bits per pixel
|
// Return closest video mode by dimensions, refresh rate and bits per pixel
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -226,7 +202,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
|||||||
if (success && dm.dmBitsPerPel >= 15)
|
if (success && dm.dmBitsPerPel >= 15)
|
||||||
{
|
{
|
||||||
// Convert to RGB, and back to bpp ("mask out" alpha bits etc)
|
// Convert to RGB, and back to bpp ("mask out" alpha bits etc)
|
||||||
bpp2rgb(dm.dmBitsPerPel, &r, &g, &b);
|
_glfwSplitBPP(dm.dmBitsPerPel, &r, &g, &b);
|
||||||
bpp = r + g + b;
|
bpp = r + g + b;
|
||||||
|
|
||||||
// Mode "code" for this mode
|
// Mode "code" for this mode
|
||||||
@ -289,6 +265,6 @@ void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
|||||||
// Return desktop mode parameters
|
// Return desktop mode parameters
|
||||||
mode->width = dm.dmPelsWidth;
|
mode->width = dm.dmPelsWidth;
|
||||||
mode->height = dm.dmPelsHeight;
|
mode->height = dm.dmPelsHeight;
|
||||||
bpp2rgb(dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
_glfwSplitBPP(dm.dmBitsPerPel, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,29 +34,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Convert BPP to RGB bits (based on "best guess")
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void bpp2rgb(int bpp, int* r, int* g, int* b)
|
|
||||||
{
|
|
||||||
int delta;
|
|
||||||
|
|
||||||
// Special case: BPP = 32 (I don't think this is necessary for X11??)
|
|
||||||
if (bpp == 32)
|
|
||||||
bpp = 24;
|
|
||||||
|
|
||||||
// Convert "bits per pixel" to red, green & blue sizes
|
|
||||||
*r = *g = *b = bpp / 3;
|
|
||||||
delta = bpp - (*r * 3);
|
|
||||||
if (delta >= 1)
|
|
||||||
*g = *g + 1;
|
|
||||||
|
|
||||||
if (delta == 2)
|
|
||||||
*r = *r + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW internal API //////
|
////// GLFW internal API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -391,7 +368,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
|||||||
depth = vislist[k].depth;
|
depth = vislist[k].depth;
|
||||||
|
|
||||||
// Convert to RGB
|
// Convert to RGB
|
||||||
bpp2rgb(depth, &r, &g, &b);
|
_glfwSplitBPP(depth, &r, &g, &b);
|
||||||
depth = (r << 16) | (g << 8) | b;
|
depth = (r << 16) | (g << 8) | b;
|
||||||
|
|
||||||
// Is this mode unique?
|
// Is this mode unique?
|
||||||
@ -516,7 +493,7 @@ void _glfwPlatformGetDesktopMode(GLFWvidmode* mode)
|
|||||||
bpp = DefaultDepth(dpy, screen);
|
bpp = DefaultDepth(dpy, screen);
|
||||||
|
|
||||||
// Convert BPP to RGB bits
|
// Convert BPP to RGB bits
|
||||||
bpp2rgb(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
_glfwSplitBPP(bpp, &mode->redBits, &mode->greenBits, &mode->blueBits);
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XRANDR)
|
#if defined(_GLFW_HAS_XRANDR)
|
||||||
if (_glfwLibrary.X11.XRandR.available)
|
if (_glfwLibrary.X11.XRandR.available)
|
||||||
|
Loading…
Reference in New Issue
Block a user