mirror of
https://github.com/glfw/glfw.git
synced 2026-11-17 20:28:55 +00:00
Added GLFW_DOUBLEBUFFER.
This commit is contained in:
@@ -222,6 +222,12 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (desired->doublebuffer != current->doublebuffer)
|
||||
{
|
||||
// Double buffering is a hard constraint
|
||||
continue;
|
||||
}
|
||||
|
||||
// Count number of missing buffers
|
||||
{
|
||||
missing = 0;
|
||||
|
||||
+7
-4
@@ -85,10 +85,9 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul
|
||||
const GLXFBConfig n = nativeConfigs[i];
|
||||
_GLFWfbconfig* u = usableConfigs + usableCount;
|
||||
|
||||
if (!getFBConfigAttrib(n, GLX_DOUBLEBUFFER) ||
|
||||
!getFBConfigAttrib(n, GLX_VISUAL_ID))
|
||||
if (!getFBConfigAttrib(n, GLX_VISUAL_ID))
|
||||
{
|
||||
// Only consider double-buffered GLXFBConfigs with associated visuals
|
||||
// Only consider GLXFBConfigs with associated visuals
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -121,7 +120,11 @@ static GLboolean chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* resul
|
||||
u->accumAlphaBits = getFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
|
||||
|
||||
u->auxBuffers = getFBConfigAttrib(n, GLX_AUX_BUFFERS);
|
||||
u->stereo = getFBConfigAttrib(n, GLX_STEREO);
|
||||
|
||||
if (getFBConfigAttrib(n, GLX_STEREO))
|
||||
u->stereo = GL_TRUE;
|
||||
if (getFBConfigAttrib(n, GLX_DOUBLEBUFFER))
|
||||
u->doublebuffer = GL_TRUE;
|
||||
|
||||
if (_glfw.glx.ARB_multisample)
|
||||
u->samples = getFBConfigAttrib(n, GLX_SAMPLES);
|
||||
|
||||
@@ -200,6 +200,7 @@ struct _GLFWfbconfig
|
||||
int stereo;
|
||||
int samples;
|
||||
int sRGB;
|
||||
int doublebuffer;
|
||||
|
||||
// This is defined in the context API's context.h
|
||||
_GLFW_PLATFORM_FBCONFIG;
|
||||
@@ -325,6 +326,7 @@ struct _GLFWlibrary
|
||||
int samples;
|
||||
int sRGB;
|
||||
int refreshRate;
|
||||
int doublebuffer;
|
||||
int api;
|
||||
int major;
|
||||
int minor;
|
||||
|
||||
+3
-1
@@ -127,7 +127,6 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
// Arbitrary array size here
|
||||
NSOpenGLPixelFormatAttribute attributes[40];
|
||||
|
||||
ADD_ATTR(NSOpenGLPFADoubleBuffer);
|
||||
ADD_ATTR(NSOpenGLPFAClosestPolicy);
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
@@ -180,6 +179,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
if (fbconfig->stereo)
|
||||
ADD_ATTR(NSOpenGLPFAStereo);
|
||||
|
||||
if (fbconfig->doublebuffer)
|
||||
ADD_ATTR(NSOpenGLPFADoubleBuffer);
|
||||
|
||||
if (fbconfig->samples != GLFW_DONT_CARE)
|
||||
{
|
||||
if (fbconfig->samples == 0)
|
||||
|
||||
+16
-7
@@ -181,8 +181,7 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
|
||||
{
|
||||
// Get pixel format attributes through WGL_ARB_pixel_format
|
||||
if (!getPixelFormatAttrib(window, n, WGL_SUPPORT_OPENGL_ARB) ||
|
||||
!getPixelFormatAttrib(window, n, WGL_DRAW_TO_WINDOW_ARB) ||
|
||||
!getPixelFormatAttrib(window, n, WGL_DOUBLE_BUFFER_ARB))
|
||||
!getPixelFormatAttrib(window, n, WGL_DRAW_TO_WINDOW_ARB))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -213,13 +212,20 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
|
||||
u->accumAlphaBits = getPixelFormatAttrib(window, n, WGL_ACCUM_ALPHA_BITS_ARB);
|
||||
|
||||
u->auxBuffers = getPixelFormatAttrib(window, n, WGL_AUX_BUFFERS_ARB);
|
||||
u->stereo = getPixelFormatAttrib(window, n, WGL_STEREO_ARB);
|
||||
|
||||
if (getPixelFormatAttrib(window, n, WGL_STEREO_ARB))
|
||||
u->stereo = GL_TRUE;
|
||||
if (getPixelFormatAttrib(window, n, WGL_DOUBLE_BUFFER_ARB))
|
||||
u->doublebuffer = GL_TRUE;
|
||||
|
||||
if (window->wgl.ARB_multisample)
|
||||
u->samples = getPixelFormatAttrib(window, n, WGL_SAMPLES_ARB);
|
||||
|
||||
if (window->wgl.ARB_framebuffer_sRGB)
|
||||
u->sRGB = getPixelFormatAttrib(window, n, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
||||
{
|
||||
if (getPixelFormatAttrib(window, n, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB))
|
||||
u->sRGB = GL_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -236,8 +242,7 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
|
||||
}
|
||||
|
||||
if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
|
||||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
|
||||
!(pfd.dwFlags & PFD_DOUBLEBUFFER))
|
||||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -265,7 +270,11 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
|
||||
u->accumAlphaBits = pfd.cAccumAlphaBits;
|
||||
|
||||
u->auxBuffers = pfd.cAuxBuffers;
|
||||
u->stereo = (pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE;
|
||||
|
||||
if (pfd.dwFlags & PFD_STEREO)
|
||||
u->stereo = GL_TRUE;
|
||||
if (pfd.dwFlags & PFD_DOUBLEBUFFER)
|
||||
u->doublebuffer = GL_TRUE;
|
||||
}
|
||||
|
||||
u->wgl = n;
|
||||
|
||||
+13
-7
@@ -157,6 +157,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
||||
fbconfig.stereo = _glfw.hints.stereo;
|
||||
fbconfig.samples = _glfw.hints.samples;
|
||||
fbconfig.sRGB = _glfw.hints.sRGB;
|
||||
fbconfig.doublebuffer = _glfw.hints.doublebuffer ? GL_TRUE : GL_FALSE;
|
||||
|
||||
// Set up desired window config
|
||||
wndconfig.width = width;
|
||||
@@ -266,13 +267,15 @@ void glfwDefaultWindowHints(void)
|
||||
_glfw.hints.decorated = GL_TRUE;
|
||||
_glfw.hints.autoIconify = GL_TRUE;
|
||||
|
||||
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
|
||||
_glfw.hints.redBits = 8;
|
||||
_glfw.hints.greenBits = 8;
|
||||
_glfw.hints.blueBits = 8;
|
||||
_glfw.hints.alphaBits = 8;
|
||||
_glfw.hints.depthBits = 24;
|
||||
_glfw.hints.stencilBits = 8;
|
||||
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
|
||||
// double buffered
|
||||
_glfw.hints.redBits = 8;
|
||||
_glfw.hints.greenBits = 8;
|
||||
_glfw.hints.blueBits = 8;
|
||||
_glfw.hints.alphaBits = 8;
|
||||
_glfw.hints.depthBits = 24;
|
||||
_glfw.hints.stencilBits = 8;
|
||||
_glfw.hints.doublebuffer = GL_TRUE;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwWindowHint(int target, int hint)
|
||||
@@ -320,6 +323,9 @@ GLFWAPI void glfwWindowHint(int target, int hint)
|
||||
case GLFW_REFRESH_RATE:
|
||||
_glfw.hints.refreshRate = hint;
|
||||
break;
|
||||
case GLFW_DOUBLEBUFFER:
|
||||
_glfw.hints.doublebuffer = hint;
|
||||
break;
|
||||
case GLFW_RESIZABLE:
|
||||
_glfw.hints.resizable = hint;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user