mirror of
https://github.com/glfw/glfw.git
synced 2026-02-17 21:12:34 +01:00
Removed glfwIsWindow.
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
void init( void );
|
||||
void display( void );
|
||||
void reshape( GLFWwindow window, int w, int h );
|
||||
int window_close_callback(GLFWwindow window);
|
||||
void DrawBoingBall( void );
|
||||
void BounceBall( double dt );
|
||||
void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi );
|
||||
@@ -89,6 +90,7 @@ DRAW_BALL_ENUM drawBallHow;
|
||||
double t;
|
||||
double t_old = 0.f;
|
||||
double dt;
|
||||
static GLboolean running = GL_TRUE;
|
||||
|
||||
/* Random number generator */
|
||||
#ifndef RAND_MAX
|
||||
@@ -245,6 +247,16 @@ void reshape( GLFWwindow window, int w, int h )
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Window close callback
|
||||
*****************************************************************************/
|
||||
int window_close_callback(GLFWwindow window)
|
||||
{
|
||||
running = GL_FALSE;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Draw the Boing ball.
|
||||
*
|
||||
@@ -567,7 +579,6 @@ void DrawGrid( void )
|
||||
|
||||
int main( void )
|
||||
{
|
||||
int running;
|
||||
GLFWwindow window;
|
||||
|
||||
/* Init GLFW */
|
||||
@@ -587,6 +598,7 @@ int main( void )
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
glfwSetWindowCloseCallback( window_close_callback );
|
||||
glfwSetWindowSizeCallback( reshape );
|
||||
glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE );
|
||||
glfwSwapInterval( 1 );
|
||||
@@ -610,7 +622,8 @@ int main( void )
|
||||
glfwPollEvents();
|
||||
|
||||
/* Check if we are still running */
|
||||
running = glfwIsWindow(window) && !glfwGetKey( window, GLFW_KEY_ESCAPE );
|
||||
if (glfwGetKey( window, GLFW_KEY_ESCAPE ))
|
||||
running = GL_FALSE;
|
||||
}
|
||||
while( running );
|
||||
|
||||
|
||||
@@ -267,6 +267,14 @@ void reshape( GLFWwindow window, int width, int height )
|
||||
}
|
||||
|
||||
|
||||
/* close callback */
|
||||
int window_close_callback(GLFWwindow window)
|
||||
{
|
||||
running = 0;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* program & OpenGL initialization */
|
||||
static void init(int argc, char *argv[])
|
||||
{
|
||||
@@ -346,6 +354,7 @@ int main(int argc, char *argv[])
|
||||
init(argc, argv);
|
||||
|
||||
// Set callback functions
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
glfwSetWindowSizeCallback( reshape );
|
||||
glfwSetKeyCallback( key );
|
||||
|
||||
@@ -361,12 +370,6 @@ int main(int argc, char *argv[])
|
||||
// Swap buffers
|
||||
glfwSwapBuffers();
|
||||
glfwPollEvents();
|
||||
|
||||
// Was the window closed?
|
||||
if( !glfwIsWindow( window ) )
|
||||
{
|
||||
running = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Terminate GLFW
|
||||
|
||||
@@ -42,6 +42,9 @@ 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)
|
||||
@@ -435,6 +438,17 @@ 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
|
||||
//========================================================================
|
||||
@@ -470,6 +484,7 @@ int main(void)
|
||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||
|
||||
// Set callback functions
|
||||
glfwSetWindowCloseCallback(windowCloseFun);
|
||||
glfwSetWindowSizeCallback(windowSizeFun);
|
||||
glfwSetWindowRefreshCallback(windowRefreshFun);
|
||||
glfwSetCursorPosCallback(cursorPosFun);
|
||||
@@ -493,9 +508,11 @@ int main(void)
|
||||
// Wait for new events
|
||||
glfwWaitEvents();
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
||||
running = GL_FALSE;
|
||||
|
||||
} // Check if the ESC key was pressed or the window was closed
|
||||
while (glfwIsWindow(window) &&
|
||||
glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS);
|
||||
while (running);
|
||||
|
||||
// Close OpenGL window and terminate GLFW
|
||||
glfwTerminate();
|
||||
|
||||
@@ -10,6 +10,14 @@
|
||||
#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;
|
||||
@@ -36,6 +44,8 @@ int main(void)
|
||||
// Enable vertical sync (on cards that support it)
|
||||
glfwSwapInterval(1);
|
||||
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
|
||||
do
|
||||
{
|
||||
double t = glfwGetTime();
|
||||
@@ -82,9 +92,11 @@ int main(void)
|
||||
glfwSwapBuffers();
|
||||
glfwPollEvents();
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE))
|
||||
running = GL_FALSE;
|
||||
|
||||
} // Check if the ESC key was pressed or the window was closed
|
||||
while (glfwIsWindow(window) &&
|
||||
glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS);
|
||||
while (running);
|
||||
|
||||
// Close OpenGL window and terminate GLFW
|
||||
glfwTerminate();
|
||||
|
||||
@@ -372,6 +372,17 @@ void window_resize_callback(GLFWwindow window, int width, int height)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Callback function for window close events
|
||||
//========================================================================
|
||||
|
||||
static int window_close_callback(GLFWwindow window)
|
||||
{
|
||||
running = GL_FALSE;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// main
|
||||
//========================================================================
|
||||
@@ -401,6 +412,7 @@ int main(int argc, char* argv[])
|
||||
glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE);
|
||||
|
||||
// Window resize handler
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
glfwSetWindowSizeCallback(window_resize_callback);
|
||||
glfwSetMouseButtonCallback(mouse_button_callback);
|
||||
glfwSetCursorPosCallback(cursor_position_callback);
|
||||
@@ -441,9 +453,6 @@ int main(int argc, char* argv[])
|
||||
draw_scene();
|
||||
|
||||
glfwPollEvents();
|
||||
|
||||
// Still running?
|
||||
running = running && glfwIsWindow(window);
|
||||
}
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
Reference in New Issue
Block a user