Added GLFW_DOUBLEBUFFER.

This commit is contained in:
Camilla Berglund 2014-04-24 19:21:10 +02:00
parent 281013002d
commit c9808586b3
10 changed files with 61 additions and 23 deletions

View File

@ -61,6 +61,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
- Added `GLFW_AUTO_ICONIFY` for controlling whether full screen windows
automatically iconify (and restore the previous video mode) on focus loss
- Added `GLFW_DONT_CARE` for indicating that any value is acceptable
- Added `GLFW_DOUBLEBUFFER` for controlling whether to use double buffering
- Added `GLFW_INCLUDE_ES31` for including the OpenGL ES 3.1 header
- Added *partial and experimental* support for Wayland
- Bugfix: The debug context attribute was set from `GL_ARB_debug_output` even

View File

@ -250,7 +250,7 @@ double time = glfwGetTime();
@section quick_swap_buffers Swapping buffers
GLFW windows always use double-buffering. That means that you have two
GLFW windows by default use double buffering. That means that you have two
rendering buffers; a front buffer and a back buffer. The front buffer is the
one being displayed and the back buffer the one you render to.

View File

@ -93,6 +93,7 @@ find out the actual attributes of the created window and context, use the
The following hints are hard constraints:
- `GLFW_STEREO`
- `GLFW_DOUBLEBUFFER`
- `GLFW_CLIENT_API`
The following additional hints are hard constraints if requesting an OpenGL
@ -137,7 +138,8 @@ application has no preference.
The `GLFW_AUX_BUFFERS` hint specifies the desired number of auxiliary
buffers. `GLFW_DONT_CARE` means the application has no preference.
The `GLFW_STEREO` hint specifies whether to use stereoscopic rendering.
The `GLFW_STEREO` hint specifies whether to use stereoscopic rendering. This is
a hard constraint.
The `GLFW_SAMPLES` hint specifies the desired number of samples to use for
multisampling. Zero disables multisampling. `GLFW_DONT_CARE` means the
@ -146,6 +148,10 @@ application has no preference.
The `GLFW_SRGB_CAPABLE` hint specifies whether the framebuffer should be
sRGB capable.
The `GLFW_DOUBLEBUFFER` hint specifies whether the framebuffer should be double
buffered. You nearly always want to use double buffering. This is a hard
constraint.
The `GLFW_REFRESH_RATE` hint specifies the desired refresh rate for full screen
windows. If set to zero, the highest available refresh rate will be used. This
hint is ignored for windowed mode windows.
@ -154,7 +160,8 @@ hint is ignored for windowed mode windows.
@subsection window_hints_ctx Context related hints
The `GLFW_CLIENT_API` hint specifies which client API to create the context
for. Possible values are `GLFW_OPENGL_API` and `GLFW_OPENGL_ES_API`.
for. Possible values are `GLFW_OPENGL_API` and `GLFW_OPENGL_ES_API`. This is
a hard constraint.
The `GLFW_CONTEXT_VERSION_MAJOR` and `GLFW_CONTEXT_VERSION_MINOR` hints
specify the client API version that the created context must be compatible
@ -219,6 +226,7 @@ a robustness strategy.
| `GLFW_REFRESH_RATE` | 0 | 0 to `INT_MAX` or `GLFW_DONT_CARE` |
| `GLFW_STEREO` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` |
| `GLFW_SRGB_CAPABLE` | `GL_FALSE` | `GL_TRUE` or `GL_FALSE` |
| `GLFW_DOUBLEBUFFER` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` |
| `GLFW_CLIENT_API` | `GLFW_OPENGL_API` | `GLFW_OPENGL_API` or `GLFW_OPENGL_ES_API` |
| `GLFW_CONTEXT_VERSION_MAJOR` | 1 | Any valid major version number of the chosen client API |
| `GLFW_CONTEXT_VERSION_MINOR` | 0 | Any valid minor version number of the chosen client API |
@ -468,7 +476,7 @@ used by the context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or
@section window_swap Swapping buffers
GLFW windows are always double buffered. That means that you have two
GLFW windows are by default double buffered. That means that you have two
rendering buffers; a front buffer and a back buffer. The front buffer is
the one being displayed and the back buffer the one you render to.

View File

@ -514,6 +514,7 @@ extern "C" {
#define GLFW_SAMPLES 0x0002100D
#define GLFW_SRGB_CAPABLE 0x0002100E
#define GLFW_REFRESH_RATE 0x0002100F
#define GLFW_DOUBLEBUFFER 0x00021010
#define GLFW_CLIENT_API 0x00022001
#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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;