mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Replaced automatic closing with window parameter.
This commit is contained in:
parent
2212cd94bf
commit
2410e2aaf4
@ -89,7 +89,6 @@ DRAW_BALL_ENUM drawBallHow;
|
|||||||
double t;
|
double t;
|
||||||
double t_old = 0.f;
|
double t_old = 0.f;
|
||||||
double dt;
|
double dt;
|
||||||
static GLboolean running = GL_TRUE;
|
|
||||||
|
|
||||||
/* Random number generator */
|
/* Random number generator */
|
||||||
#ifndef RAND_MAX
|
#ifndef RAND_MAX
|
||||||
@ -246,16 +245,6 @@ void reshape( GLFWwindow window, int w, int h )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* Window close callback
|
|
||||||
*****************************************************************************/
|
|
||||||
static int window_close_callback(GLFWwindow window)
|
|
||||||
{
|
|
||||||
running = GL_FALSE;
|
|
||||||
return GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Draw the Boing ball.
|
* Draw the Boing ball.
|
||||||
*
|
*
|
||||||
@ -588,7 +577,6 @@ int main( void )
|
|||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowCloseCallback( window_close_callback );
|
|
||||||
glfwSetWindowSizeCallback( reshape );
|
glfwSetWindowSizeCallback( reshape );
|
||||||
|
|
||||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||||
@ -611,7 +599,7 @@ int main( void )
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
/* Main loop */
|
/* Main loop */
|
||||||
do
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Timing */
|
/* Timing */
|
||||||
t = glfwGetTime();
|
t = glfwGetTime();
|
||||||
@ -627,9 +615,10 @@ int main( void )
|
|||||||
|
|
||||||
/* Check if we are still running */
|
/* Check if we are still running */
|
||||||
if (glfwGetKey( window, GLFW_KEY_ESCAPE ))
|
if (glfwGetKey( window, GLFW_KEY_ESCAPE ))
|
||||||
running = GL_FALSE;
|
break;
|
||||||
|
if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
while( running );
|
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
exit( EXIT_SUCCESS );
|
exit( EXIT_SUCCESS );
|
||||||
|
@ -42,9 +42,6 @@ static int rot_x = 0, rot_y = 0, rot_z = 0;
|
|||||||
// Do redraw?
|
// Do redraw?
|
||||||
static int do_redraw = 1;
|
static int do_redraw = 1;
|
||||||
|
|
||||||
// Keep running?
|
|
||||||
static GLboolean running = GL_TRUE;
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Draw a solid torus (use a display list for the model)
|
// Draw a solid torus (use a display list for the model)
|
||||||
@ -438,17 +435,6 @@ static void mouseButtonFun(GLFWwindow window, int button, int action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Window close callback function
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static int windowCloseFun(GLFWwindow window)
|
|
||||||
{
|
|
||||||
running = GL_FALSE;
|
|
||||||
return GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// main
|
// main
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -466,7 +452,6 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set callback functions
|
// Set callback functions
|
||||||
glfwSetWindowCloseCallback(windowCloseFun);
|
|
||||||
glfwSetWindowSizeCallback(windowSizeFun);
|
glfwSetWindowSizeCallback(windowSizeFun);
|
||||||
glfwSetWindowRefreshCallback(windowRefreshFun);
|
glfwSetWindowRefreshCallback(windowRefreshFun);
|
||||||
glfwSetCursorPosCallback(cursorPosFun);
|
glfwSetCursorPosCallback(cursorPosFun);
|
||||||
@ -495,7 +480,7 @@ int main(void)
|
|||||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
do
|
for (;;)
|
||||||
{
|
{
|
||||||
// Only redraw if we need to
|
// Only redraw if we need to
|
||||||
if (do_redraw)
|
if (do_redraw)
|
||||||
@ -512,11 +497,12 @@ int main(void)
|
|||||||
// Wait for new events
|
// Wait for new events
|
||||||
glfwWaitEvents();
|
glfwWaitEvents();
|
||||||
|
|
||||||
|
// Check if the ESC key was pressed or the window should be closed
|
||||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
||||||
running = GL_FALSE;
|
break;
|
||||||
|
if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
} // Check if the ESC key was pressed or the window was closed
|
break;
|
||||||
while (running);
|
}
|
||||||
|
|
||||||
// Close OpenGL window and terminate GLFW
|
// Close OpenGL window and terminate GLFW
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
@ -10,14 +10,6 @@
|
|||||||
#define GLFW_INCLUDE_GLU
|
#define GLFW_INCLUDE_GLU
|
||||||
#include <GL/glfw3.h>
|
#include <GL/glfw3.h>
|
||||||
|
|
||||||
static GLboolean running = GL_TRUE;
|
|
||||||
|
|
||||||
static int window_close_callback(GLFWwindow window)
|
|
||||||
{
|
|
||||||
running = GL_FALSE;
|
|
||||||
return GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int width, height, x;
|
int width, height, x;
|
||||||
@ -44,9 +36,7 @@ int main(void)
|
|||||||
// Enable vertical sync (on cards that support it)
|
// Enable vertical sync (on cards that support it)
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
glfwSetWindowCloseCallback(window_close_callback);
|
for (;;)
|
||||||
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
double t = glfwGetTime();
|
double t = glfwGetTime();
|
||||||
glfwGetCursorPos(window, &x, NULL);
|
glfwGetCursorPos(window, &x, NULL);
|
||||||
@ -92,11 +82,12 @@ int main(void)
|
|||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
|
||||||
|
// Check if the ESC key was pressed or the window should be closed
|
||||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
||||||
running = GL_FALSE;
|
break;
|
||||||
|
if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
} // Check if the ESC key was pressed or the window was closed
|
break;
|
||||||
while (running);
|
}
|
||||||
|
|
||||||
// Close OpenGL window and terminate GLFW
|
// Close OpenGL window and terminate GLFW
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
@ -388,6 +388,7 @@ extern "C" {
|
|||||||
/* glfwGetWindowParam tokens */
|
/* glfwGetWindowParam tokens */
|
||||||
#define GLFW_ACTIVE 0x00020001
|
#define GLFW_ACTIVE 0x00020001
|
||||||
#define GLFW_ICONIFIED 0x00020002
|
#define GLFW_ICONIFIED 0x00020002
|
||||||
|
#define GLFW_CLOSE_REQUESTED 0x00020003
|
||||||
#define GLFW_OPENGL_REVISION 0x00020004
|
#define GLFW_OPENGL_REVISION 0x00020004
|
||||||
|
|
||||||
/* glfwWindowHint tokens */
|
/* glfwWindowHint tokens */
|
||||||
|
@ -307,6 +307,7 @@ version of GLFW.</p>
|
|||||||
<li>Replaced mouse wheel interface with two-dimensional, floating point scrolling interface</li>
|
<li>Replaced mouse wheel interface with two-dimensional, floating point scrolling interface</li>
|
||||||
<li>Replaced <code>glfwEnable</code> and <code>glfwDisable</code> with <code>glfwGetInputMode</code> and <code>glfwSetInputMode</code></li>
|
<li>Replaced <code>glfwEnable</code> and <code>glfwDisable</code> with <code>glfwGetInputMode</code> and <code>glfwSetInputMode</code></li>
|
||||||
<li>Replaced <code>joystick</code> test with graphical version</li>
|
<li>Replaced <code>joystick</code> test with graphical version</li>
|
||||||
|
<li>Replaced automatic closing of windows with <code>GLFW_CLOSE_REQUESTED</code> window parameter</li>
|
||||||
<li>Made Unicode character input unaffected by <code>GLFW_KEY_REPEAT</code></li>
|
<li>Made Unicode character input unaffected by <code>GLFW_KEY_REPEAT</code></li>
|
||||||
<li>Removed event auto-polling and the <code>GLFW_AUTO_POLL_EVENTS</code> window enable</li>
|
<li>Removed event auto-polling and the <code>GLFW_AUTO_POLL_EVENTS</code> window enable</li>
|
||||||
<li>Removed the Win32 port .def files</li>
|
<li>Removed the Win32 port .def files</li>
|
||||||
|
@ -59,8 +59,7 @@
|
|||||||
|
|
||||||
- (BOOL)windowShouldClose:(id)sender
|
- (BOOL)windowShouldClose:(id)sender
|
||||||
{
|
{
|
||||||
window->closeRequested = GL_TRUE;
|
_glfwInputWindowCloseRequest(window);
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +126,7 @@
|
|||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
|
|
||||||
for (window = _glfwLibrary.windowListHead; window; window = window->next)
|
for (window = _glfwLibrary.windowListHead; window; window = window->next)
|
||||||
window->closeRequested = GL_TRUE;
|
_glfwInputWindowCloseRequest(window);
|
||||||
|
|
||||||
return NSTerminateCancel;
|
return NSTerminateCancel;
|
||||||
}
|
}
|
||||||
|
@ -337,6 +337,7 @@ void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
|
|||||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
||||||
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
||||||
void _glfwInputWindowDamage(_GLFWwindow* window);
|
void _glfwInputWindowDamage(_GLFWwindow* window);
|
||||||
|
void _glfwInputWindowCloseRequest(_GLFWwindow* window);
|
||||||
|
|
||||||
// Input event notification (input.c)
|
// Input event notification (input.c)
|
||||||
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
||||||
|
@ -532,8 +532,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
|
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
{
|
{
|
||||||
// Flag this window for closing (handled in glfwPollEvents)
|
_glfwInputWindowCloseRequest(window);
|
||||||
window->closeRequested = GL_TRUE;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,7 +1248,7 @@ void _glfwPlatformPollEvents(void)
|
|||||||
window = _glfwLibrary.windowListHead;
|
window = _glfwLibrary.windowListHead;
|
||||||
while (window)
|
while (window)
|
||||||
{
|
{
|
||||||
window->closeRequested = GL_TRUE;
|
_glfwInputWindowCloseRequest(window);
|
||||||
window = window->next;
|
window = window->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
src/window.c
44
src/window.c
@ -44,31 +44,6 @@ static int Max(int a, int b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Close all GLFW windows with the closed flag set
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
static void closeFlaggedWindows(void)
|
|
||||||
{
|
|
||||||
_GLFWwindow* window;
|
|
||||||
|
|
||||||
for (window = _glfwLibrary.windowListHead; window; )
|
|
||||||
{
|
|
||||||
if (window->closeRequested && _glfwLibrary.windowCloseCallback)
|
|
||||||
window->closeRequested = _glfwLibrary.windowCloseCallback(window);
|
|
||||||
|
|
||||||
if (window->closeRequested)
|
|
||||||
{
|
|
||||||
_GLFWwindow* next = window->next;
|
|
||||||
glfwDestroyWindow(window);
|
|
||||||
window = next;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
window = window->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Clear scroll offsets for all windows
|
// Clear scroll offsets for all windows
|
||||||
//========================================================================
|
//========================================================================
|
||||||
@ -206,6 +181,19 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Register window close request events
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
if (_glfwLibrary.windowCloseCallback)
|
||||||
|
window->closeRequested = _glfwLibrary.windowCloseCallback(window);
|
||||||
|
else
|
||||||
|
window->closeRequested = GL_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -662,6 +650,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
|||||||
return window == _glfwLibrary.activeWindow;
|
return window == _glfwLibrary.activeWindow;
|
||||||
case GLFW_ICONIFIED:
|
case GLFW_ICONIFIED:
|
||||||
return window->iconified;
|
return window->iconified;
|
||||||
|
case GLFW_CLOSE_REQUESTED:
|
||||||
|
return window->closeRequested;
|
||||||
case GLFW_REFRESH_RATE:
|
case GLFW_REFRESH_RATE:
|
||||||
return window->refreshRate;
|
return window->refreshRate;
|
||||||
case GLFW_WINDOW_RESIZABLE:
|
case GLFW_WINDOW_RESIZABLE:
|
||||||
@ -818,8 +808,6 @@ GLFWAPI void glfwPollEvents(void)
|
|||||||
clearScrollOffsets();
|
clearScrollOffsets();
|
||||||
|
|
||||||
_glfwPlatformPollEvents();
|
_glfwPlatformPollEvents();
|
||||||
|
|
||||||
closeFlaggedWindows();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -838,7 +826,5 @@ GLFWAPI void glfwWaitEvents(void)
|
|||||||
clearScrollOffsets();
|
clearScrollOffsets();
|
||||||
|
|
||||||
_glfwPlatformWaitEvents();
|
_glfwPlatformWaitEvents();
|
||||||
|
|
||||||
closeFlaggedWindows();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,7 +711,7 @@ static void processSingleEvent(void)
|
|||||||
// The window manager was asked to close the window, for example by
|
// The window manager was asked to close the window, for example by
|
||||||
// the user pressing a 'close' window decoration button
|
// the user pressing a 'close' window decoration button
|
||||||
|
|
||||||
window->closeRequested = GL_TRUE;
|
_glfwInputWindowCloseRequest(window);
|
||||||
}
|
}
|
||||||
else if (_glfwLibrary.X11.wmPing != None &&
|
else if (_glfwLibrary.X11.wmPing != None &&
|
||||||
(Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing)
|
(Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing)
|
||||||
|
@ -106,7 +106,7 @@ int main(void)
|
|||||||
|
|
||||||
set_swap_interval(window, swap_interval);
|
set_swap_interval(window, swap_interval);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -48,9 +48,6 @@ static GLboolean closeable = GL_TRUE;
|
|||||||
// Event index
|
// Event index
|
||||||
static unsigned int counter = 0;
|
static unsigned int counter = 0;
|
||||||
|
|
||||||
// Should we keep running?
|
|
||||||
static GLboolean running = GL_TRUE;
|
|
||||||
|
|
||||||
static const char* get_key_name(int key)
|
static const char* get_key_name(int key)
|
||||||
{
|
{
|
||||||
switch (key)
|
switch (key)
|
||||||
@ -238,9 +235,6 @@ static int window_close_callback(GLFWwindow window)
|
|||||||
{
|
{
|
||||||
printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime());
|
printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime());
|
||||||
|
|
||||||
if (closeable)
|
|
||||||
running = GL_FALSE;
|
|
||||||
|
|
||||||
return closeable;
|
return closeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,7 +393,7 @@ int main(void)
|
|||||||
|
|
||||||
printf("Main loop starting\n");
|
printf("Main loop starting\n");
|
||||||
|
|
||||||
while (running)
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
glfwWaitEvents();
|
glfwWaitEvents();
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
@ -127,7 +127,7 @@ int main(int argc, char** argv)
|
|||||||
gluOrtho2D(0.f, 1.f, 0.f, 0.5f);
|
gluOrtho2D(0.f, 1.f, 0.f, 0.5f);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
GLfloat time = (GLfloat) glfwGetTime();
|
GLfloat time = (GLfloat) glfwGetTime();
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ int main(void)
|
|||||||
glfwSetWindowSizeCallback(window_size_callback);
|
glfwSetWindowSizeCallback(window_size_callback);
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ int main(void)
|
|||||||
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window_handle, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ int main(void)
|
|||||||
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ int main(void)
|
|||||||
|
|
||||||
glfwSetWindowSizeCallback(window_size_callback);
|
glfwSetWindowSizeCallback(window_size_callback);
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||||
{
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
@ -32,14 +32,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static GLboolean running = GL_TRUE;
|
|
||||||
|
|
||||||
static int window_close_callback(GLFWwindow window)
|
|
||||||
{
|
|
||||||
running = GL_FALSE;
|
|
||||||
return GL_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char* titles[] =
|
static const char* titles[] =
|
||||||
{
|
{
|
||||||
"Foo",
|
"Foo",
|
||||||
@ -51,6 +43,7 @@ static const char* titles[] =
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
GLboolean running = GL_TRUE;
|
||||||
GLFWwindow windows[4];
|
GLFWwindow windows[4];
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
@ -60,8 +53,6 @@ int main(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowCloseCallback(window_close_callback);
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL);
|
windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL);
|
||||||
@ -88,6 +79,9 @@ int main(void)
|
|||||||
glfwMakeContextCurrent(windows[i]);
|
glfwMakeContextCurrent(windows[i]);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glfwSwapBuffers(windows[i]);
|
glfwSwapBuffers(windows[i]);
|
||||||
|
|
||||||
|
if (glfwGetWindowParam(windows[i], GLFW_CLOSE_REQUESTED))
|
||||||
|
running = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
Loading…
Reference in New Issue
Block a user