mirror of
https://github.com/glfw/glfw.git
synced 2026-09-20 16:30:45 +00:00
Replaced automatic closing with window parameter.
This commit is contained in:
+4
-15
@@ -89,7 +89,6 @@ DRAW_BALL_ENUM drawBallHow;
|
||||
double t;
|
||||
double t_old = 0.f;
|
||||
double dt;
|
||||
static GLboolean running = GL_TRUE;
|
||||
|
||||
/* Random number generator */
|
||||
#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.
|
||||
*
|
||||
@@ -588,7 +577,6 @@ int main( void )
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
glfwSetWindowCloseCallback( window_close_callback );
|
||||
glfwSetWindowSizeCallback( reshape );
|
||||
|
||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||
@@ -611,7 +599,7 @@ int main( void )
|
||||
init();
|
||||
|
||||
/* Main loop */
|
||||
do
|
||||
for (;;)
|
||||
{
|
||||
/* Timing */
|
||||
t = glfwGetTime();
|
||||
@@ -627,9 +615,10 @@ int main( void )
|
||||
|
||||
/* Check if we are still running */
|
||||
if (glfwGetKey( window, GLFW_KEY_ESCAPE ))
|
||||
running = GL_FALSE;
|
||||
break;
|
||||
if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||
break;
|
||||
}
|
||||
while( running );
|
||||
|
||||
glfwTerminate();
|
||||
exit( EXIT_SUCCESS );
|
||||
|
||||
+6
-20
@@ -42,9 +42,6 @@ static int rot_x = 0, rot_y = 0, rot_z = 0;
|
||||
// Do redraw?
|
||||
static int do_redraw = 1;
|
||||
|
||||
// Keep running?
|
||||
static GLboolean running = GL_TRUE;
|
||||
|
||||
|
||||
//========================================================================
|
||||
// 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
|
||||
//========================================================================
|
||||
@@ -466,7 +452,6 @@ int main(void)
|
||||
}
|
||||
|
||||
// Set callback functions
|
||||
glfwSetWindowCloseCallback(windowCloseFun);
|
||||
glfwSetWindowSizeCallback(windowSizeFun);
|
||||
glfwSetWindowRefreshCallback(windowRefreshFun);
|
||||
glfwSetCursorPosCallback(cursorPosFun);
|
||||
@@ -495,7 +480,7 @@ int main(void)
|
||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||
|
||||
// Main loop
|
||||
do
|
||||
for (;;)
|
||||
{
|
||||
// Only redraw if we need to
|
||||
if (do_redraw)
|
||||
@@ -512,11 +497,12 @@ int main(void)
|
||||
// Wait for new events
|
||||
glfwWaitEvents();
|
||||
|
||||
// Check if the ESC key was pressed or the window should be closed
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
||||
running = GL_FALSE;
|
||||
|
||||
} // Check if the ESC key was pressed or the window was closed
|
||||
while (running);
|
||||
break;
|
||||
if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||
break;
|
||||
}
|
||||
|
||||
// Close OpenGL window and terminate GLFW
|
||||
glfwTerminate();
|
||||
|
||||
+6
-15
@@ -10,14 +10,6 @@
|
||||
#define GLFW_INCLUDE_GLU
|
||||
#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 width, height, x;
|
||||
@@ -44,9 +36,7 @@ int main(void)
|
||||
// Enable vertical sync (on cards that support it)
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
|
||||
do
|
||||
for (;;)
|
||||
{
|
||||
double t = glfwGetTime();
|
||||
glfwGetCursorPos(window, &x, NULL);
|
||||
@@ -92,11 +82,12 @@ int main(void)
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
|
||||
// Check if the ESC key was pressed or the window should be closed
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
||||
running = GL_FALSE;
|
||||
|
||||
} // Check if the ESC key was pressed or the window was closed
|
||||
while (running);
|
||||
break;
|
||||
if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED))
|
||||
break;
|
||||
}
|
||||
|
||||
// Close OpenGL window and terminate GLFW
|
||||
glfwTerminate();
|
||||
|
||||
Reference in New Issue
Block a user