Added window parameter to glfwSwapBuffers.

This commit is contained in:
Camilla Berglund 2012-08-06 18:13:37 +02:00
parent aff30d0baa
commit 585a840329
29 changed files with 37 additions and 44 deletions

View File

@ -617,7 +617,7 @@ int main( void )
display(); display();
/* Swap buffers */ /* Swap buffers */
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
/* Check if we are still running */ /* Check if we are still running */

View File

@ -368,7 +368,7 @@ int main(int argc, char *argv[])
animate(); animate();
// Swap buffers // Swap buffers
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -663,7 +663,7 @@ int main(int argc, char** argv)
glDrawElements(GL_LINES, 2* MAP_NUM_LINES , GL_UNSIGNED_INT, 0); glDrawElements(GL_LINES, 2* MAP_NUM_LINES , GL_UNSIGNED_INT, 0);
/* display and process events through callbacks */ /* display and process events through callbacks */
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
/* Check the frame rate and update the heightmap if needed */ /* Check the frame rate and update the heightmap if needed */
dt = glfwGetTime(); dt = glfwGetTime();

View File

@ -500,7 +500,7 @@ int main(void)
drawAllViews(); drawAllViews();
// Swap buffers // Swap buffers
glfwSwapBuffers(); glfwSwapBuffers(window);
do_redraw = 0; do_redraw = 0;
} }

View File

@ -89,7 +89,7 @@ int main(void)
glEnd(); glEnd();
// Swap buffers // Swap buffers
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
if (glfwGetKey(window, GLFW_KEY_ESCAPE)) if (glfwGetKey(window, GLFW_KEY_ESCAPE))

View File

@ -145,7 +145,7 @@ void init_grid(void)
// Draw scene // Draw scene
//======================================================================== //========================================================================
void draw_scene(void) void draw_scene(GLFWwindow window)
{ {
// Clear the color and depth buffers // Clear the color and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@ -162,7 +162,7 @@ void draw_scene(void)
glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad); glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad);
glfwSwapBuffers(); glfwSwapBuffers(window);
} }
@ -450,7 +450,7 @@ int main(int argc, char* argv[])
adjust_grid(); adjust_grid();
// Draw wave grid to OpenGL display // Draw wave grid to OpenGL display
draw_scene(); draw_scene(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -581,7 +581,7 @@ GLFWAPI void glfwSetTime(double time);
/* OpenGL support */ /* OpenGL support */
GLFWAPI void glfwMakeContextCurrent(GLFWwindow window); GLFWAPI void glfwMakeContextCurrent(GLFWwindow window);
GLFWAPI GLFWwindow glfwGetCurrentContext(void); GLFWAPI GLFWwindow glfwGetCurrentContext(void);
GLFWAPI void glfwSwapBuffers(void); GLFWAPI void glfwSwapBuffers(GLFWwindow window);
GLFWAPI void glfwSwapInterval(int interval); GLFWAPI void glfwSwapInterval(int interval);
GLFWAPI int glfwExtensionSupported(const char* extension); GLFWAPI int glfwExtensionSupported(const char* extension);
GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname); GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname);

View File

@ -288,6 +288,7 @@ version of GLFW.</p>
<li>Added <code>modes</code> video mode enumeration and setting test program</li> <li>Added <code>modes</code> video mode enumeration and setting test program</li>
<li>Added <code>glfw3native.h</code> header and platform-specific functions for explicit access to native display, window and context handles</li> <li>Added <code>glfw3native.h</code> header and platform-specific functions for explicit access to native display, window and context handles</li>
<li>Added <code>glfwSetGamma</code>, <code>glfwSetGammaRamp</code> and <code>glfwGetGammaRamp</code> functions and <code>GLFWgammaramp</code> type for monitor gamma ramp control</li> <li>Added <code>glfwSetGamma</code>, <code>glfwSetGammaRamp</code> and <code>glfwGetGammaRamp</code> functions and <code>GLFWgammaramp</code> type for monitor gamma ramp control</li>
<li>Added window parameter to <code>glfwSwapBuffers</code></li>
<li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li> <li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li>
<li>Changed <code>glfwOpenWindow</code> and <code>glfwSetWindowTitle</code> to use UTF-8 encoded strings</li> <li>Changed <code>glfwOpenWindow</code> and <code>glfwSetWindowTitle</code> to use UTF-8 encoded strings</li>
<li>Changed <code>glfwGetProcAddress</code> to return a (generic) function pointer</li> <li>Changed <code>glfwGetProcAddress</code> to return a (generic) function pointer</li>

View File

@ -51,10 +51,8 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
// Swap buffers // Swap buffers
//======================================================================== //========================================================================
void _glfwPlatformSwapBuffers(void) void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{ {
_GLFWwindow* window = _glfwLibrary.currentWindow;
// ARP appears to be unnecessary, but this is future-proof // ARP appears to be unnecessary, but this is future-proof
[window->NSGL.context flushBuffer]; [window->NSGL.context flushBuffer];
} }

View File

@ -324,7 +324,7 @@ void _glfwPlatformWaitEvents(void);
// OpenGL context management // OpenGL context management
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window); void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
void _glfwPlatformSwapBuffers(void); void _glfwPlatformSwapBuffers(_GLFWwindow* window);
void _glfwPlatformSwapInterval(int interval); void _glfwPlatformSwapInterval(int interval);
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window); void _glfwPlatformRefreshWindowParams(_GLFWwindow* window);
int _glfwPlatformExtensionSupported(const char* extension); int _glfwPlatformExtensionSupported(const char* extension);

View File

@ -541,21 +541,17 @@ GLFWAPI GLFWwindow glfwGetCurrentContext(void)
// Swap buffers (double-buffering) // Swap buffers (double-buffering)
//======================================================================== //========================================================================
GLFWAPI void glfwSwapBuffers(void) GLFWAPI void glfwSwapBuffers(GLFWwindow handle)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED, NULL); _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
return; return;
} }
if (!_glfwLibrary.currentWindow) _glfwPlatformSwapBuffers(window);
{
_glfwSetError(GLFW_NO_CURRENT_CONTEXT, NULL);
return;
}
_glfwPlatformSwapBuffers();
} }

View File

@ -545,10 +545,8 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
// Swap buffers (double-buffering) // Swap buffers (double-buffering)
//======================================================================== //========================================================================
void _glfwPlatformSwapBuffers(void) void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{ {
_GLFWwindow* window = _glfwLibrary.currentWindow;
SwapBuffers(window->WGL.DC); SwapBuffers(window->WGL.DC);
} }

View File

@ -344,7 +344,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
// Clearing the front buffer to black to avoid garbage pixels left over // Clearing the front buffer to black to avoid garbage pixels left over
// from previous uses of our bit of VRAM // from previous uses of our bit of VRAM
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
_glfwPlatformSwapBuffers(); _glfwPlatformSwapBuffers(window);
return window; return window;
} }

View File

@ -642,10 +642,9 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
// Swap OpenGL buffers // Swap OpenGL buffers
//======================================================================== //========================================================================
void _glfwPlatformSwapBuffers(void) void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{ {
glXSwapBuffers(_glfwLibrary.X11.display, glXSwapBuffers(_glfwLibrary.X11.display, window->X11.handle);
_glfwLibrary.currentWindow->X11.handle);
} }

View File

@ -113,7 +113,7 @@ int main(void)
glVertex2f((GLfloat) cursor_x, (GLfloat) window_height); glVertex2f((GLfloat) cursor_x, (GLfloat) window_height);
glEnd(); glEnd();
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -143,7 +143,7 @@ int main(int argc, char** argv)
glColor3f(0.8f, 0.2f, 0.4f); glColor3f(0.8f, 0.2f, 0.4f);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f); glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwWaitEvents(); glfwWaitEvents();
} }

View File

@ -239,7 +239,7 @@ static void window_refresh_callback(GLFWwindow window)
printf("%08x at %0.3f: Window refresh\n", counter++, glfwGetTime()); printf("%08x at %0.3f: Window refresh\n", counter++, glfwGetTime());
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers(window);
} }
static void window_focus_callback(GLFWwindow window, int activated) static void window_focus_callback(GLFWwindow window, int activated)

View File

@ -147,7 +147,7 @@ int main(int argc, char** argv)
glEnable(GL_MULTISAMPLE_ARB); glEnable(GL_MULTISAMPLE_ARB);
glRectf(-0.15f, -0.15f, 0.15f, 0.15f); glRectf(-0.15f, -0.15f, 0.15f, 0.15f);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -101,7 +101,7 @@ int main(void)
while (running) while (running)
{ {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwWaitEvents(); glfwWaitEvents();
} }

View File

@ -158,7 +158,7 @@ int main(int argc, char** argv)
glColor3f(0.8f, 0.2f, 0.4f); glColor3f(0.8f, 0.2f, 0.4f);
glRectf(-0.5f, -0.5f, 0.5f, 0.5f); glRectf(-0.5f, -0.5f, 0.5f, 0.5f);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -152,7 +152,7 @@ int main(int argc, char** argv)
glClearColor(1, 1, 1, 0); glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -205,7 +205,7 @@ int main(void)
refresh_joysticks(); refresh_joysticks();
draw_joysticks(); draw_joysticks();
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -148,7 +148,7 @@ static void test_modes(void)
while (glfwGetTime() < 5.0) while (glfwGetTime() < 5.0)
{ {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
if (!window) if (!window)

View File

@ -131,7 +131,7 @@ int main(void)
{ {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers(window_handle);
glfwWaitEvents(); glfwWaitEvents();
} }

View File

@ -147,7 +147,7 @@ int main(int argc, char** argv)
glRectf(-0.5f, -0.5f, 1.f, 1.f); glRectf(-0.5f, -0.5f, 1.f, 1.f);
glPopMatrix(); glPopMatrix();
glfwSwapBuffers(); glfwSwapBuffers(window_handle);
glfwPollEvents(); glfwPollEvents();
if (closed) if (closed)

View File

@ -172,11 +172,12 @@ int main(int argc, char** argv)
{ {
glfwMakeContextCurrent(windows[0]); glfwMakeContextCurrent(windows[0]);
draw_quad(texture); draw_quad(texture);
glfwSwapBuffers();
glfwMakeContextCurrent(windows[1]); glfwMakeContextCurrent(windows[1]);
draw_quad(texture); draw_quad(texture);
glfwSwapBuffers();
glfwSwapBuffers(windows[0]);
glfwSwapBuffers(windows[1]);
glfwWaitEvents(); glfwWaitEvents();
} }

View File

@ -97,7 +97,7 @@ int main(void)
position = cosf(glfwGetTime() * 4.f) * 0.75f; position = cosf(glfwGetTime() * 4.f) * 0.75f;
glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f); glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
} }

View File

@ -61,7 +61,7 @@ int main(void)
while (glfwGetCurrentContext()) while (glfwGetCurrentContext())
{ {
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers(window);
glfwWaitEvents(); glfwWaitEvents();
} }

View File

@ -87,7 +87,7 @@ int main(void)
{ {
glfwMakeContextCurrent(windows[i]); glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(); glfwSwapBuffers(windows[i]);
} }
glfwPollEvents(); glfwPollEvents();