mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
Removed glfwIsWindow.
This commit is contained in:
parent
1736132bb2
commit
2972cdfeb1
|
@ -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);
|
||||
|
|
|
@ -529,7 +529,6 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
|
|||
/* Window handling */
|
||||
GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share);
|
||||
GLFWAPI void glfwOpenWindowHint(int target, int hint);
|
||||
GLFWAPI int glfwIsWindow(GLFWwindow window);
|
||||
GLFWAPI void glfwCloseWindow(GLFWwindow window);
|
||||
GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title);
|
||||
GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height);
|
||||
|
|
|
@ -268,7 +268,6 @@ version of GLFW.</p>
|
|||
<h3>v3.0</h3>
|
||||
<ul>
|
||||
<li>Added <code>GLFWwindow</code> window handle type and updated window-related functions and callbacks to take a window handle</li>
|
||||
<li>Added <code>glfwIsWindow</code> function for verifying that a given window handle is (still) valid</li>
|
||||
<li>Added <code>glfwMakeContextCurrent</code> function for making the context of the specified window current</li>
|
||||
<li>Added <code>glfwGetError</code> and <code>glfwErrorString</code> error reporting functions and a number of error tokens</li>
|
||||
<li>Added <code>glfwSetErrorCallback</code> function and <code>GLFWerrorfun</code> type for receiving more specific and/or nested errors</li>
|
||||
|
|
28
src/window.c
28
src/window.c
|
@ -350,34 +350,6 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
|||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Returns GL_TRUE if the specified window handle is an actual window
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI int glfwIsWindow(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* entry;
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (window == NULL)
|
||||
return GL_FALSE;
|
||||
|
||||
for (entry = _glfwLibrary.windowListHead; entry; entry = entry->next)
|
||||
{
|
||||
if (entry == window)
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set hints for opening the window
|
||||
//========================================================================
|
||||
|
|
|
@ -79,7 +79,7 @@ int main(void)
|
|||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
while (glfwIsWindow(window))
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ int main(int argc, char** argv)
|
|||
|
||||
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
||||
|
||||
while (glfwIsWindow(window))
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ int main(void)
|
|||
|
||||
printf("Main loop starting\n");
|
||||
|
||||
while (glfwIsWindow(window) == GL_TRUE)
|
||||
while (glfwGetCurrentContext())
|
||||
glfwWaitEvents();
|
||||
|
||||
glfwTerminate();
|
||||
|
|
|
@ -127,7 +127,7 @@ int main(int argc, char** argv)
|
|||
gluOrtho2D(0.f, 1.f, 0.f, 0.5f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
while (glfwIsWindow(window))
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
GLfloat time = (GLfloat) glfwGetTime();
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ static void window_key_callback(GLFWwindow window, int key, int action)
|
|||
static int window_close_callback(GLFWwindow window)
|
||||
{
|
||||
printf("%0.3f: User closed window\n", glfwGetTime());
|
||||
running = GL_FALSE;
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ int main(void)
|
|||
glfwSetKeyCallback(window_key_callback);
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
|
||||
while (running && glfwIsWindow(window) == GL_TRUE)
|
||||
while (running)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glfwSwapBuffers();
|
||||
|
|
|
@ -151,7 +151,7 @@ int main(int argc, char** argv)
|
|||
|
||||
glClearColor(0.5f, 0.5f, 0.5f, 0);
|
||||
|
||||
while (glfwIsWindow(window))
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ int main(int argc, char** argv)
|
|||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
while (glfwIsWindow(window))
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
int width, height;
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ typedef struct Joystick
|
|||
} Joystick;
|
||||
|
||||
static Joystick joysticks[GLFW_JOYSTICK_LAST - GLFW_JOYSTICK_1 + 1];
|
||||
|
||||
static int joystick_count = 0;
|
||||
|
||||
static void window_size_callback(GLFWwindow window, int width, int height)
|
||||
|
@ -199,7 +198,7 @@ int main(void)
|
|||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
while (glfwIsWindow(window))
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ int main(void)
|
|||
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
while (glfwIsWindow(window_handle))
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -36,12 +36,30 @@
|
|||
#define WIDTH 400
|
||||
#define HEIGHT 400
|
||||
|
||||
static GLFWwindow windows[2];
|
||||
|
||||
static void key_callback(GLFWwindow window, int key, int action)
|
||||
{
|
||||
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)
|
||||
glfwCloseWindow(window);
|
||||
}
|
||||
|
||||
static int window_close_callback(GLFWwindow window)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (windows[i] == window)
|
||||
{
|
||||
windows[i] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
static GLFWwindow open_window(const char* title, GLFWwindow share)
|
||||
{
|
||||
GLFWwindow window;
|
||||
|
@ -50,6 +68,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share)
|
|||
if (!window)
|
||||
return NULL;
|
||||
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
glfwSetKeyCallback(key_callback);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
|
@ -112,7 +131,6 @@ static void draw_quad(GLuint texture)
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GLFWwindow windows[2];
|
||||
GLuint texture;
|
||||
int x, y;
|
||||
|
||||
|
@ -150,7 +168,7 @@ int main(int argc, char** argv)
|
|||
glfwGetWindowPos(windows[0], &x, &y);
|
||||
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
|
||||
|
||||
while (glfwIsWindow(windows[0]) && glfwIsWindow(windows[1]))
|
||||
while (windows[0] && windows[1])
|
||||
{
|
||||
glfwMakeContextCurrent(windows[0]);
|
||||
draw_quad(texture);
|
||||
|
|
|
@ -87,7 +87,7 @@ int main(void)
|
|||
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
while (glfwIsWindow(window) == GL_TRUE)
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ int main(void)
|
|||
|
||||
glfwSetWindowSizeCallback(window_size_callback);
|
||||
|
||||
while (glfwIsWindow(window) == GL_TRUE)
|
||||
while (glfwGetCurrentContext())
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glfwSwapBuffers();
|
||||
|
|
|
@ -32,6 +32,14 @@
|
|||
#include <stdio.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[] =
|
||||
{
|
||||
"Foo",
|
||||
|
@ -43,7 +51,6 @@ static const char* titles[] =
|
|||
int main(void)
|
||||
{
|
||||
int i;
|
||||
GLboolean running = GL_TRUE;
|
||||
GLFWwindow windows[4];
|
||||
|
||||
if (!glfwInit())
|
||||
|
@ -53,6 +60,8 @@ int main(void)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
glfwSetWindowCloseCallback(window_close_callback);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
windows[i] = glfwOpenWindow(200, 200, GLFW_WINDOWED, titles[i], NULL);
|
||||
|
@ -82,12 +91,6 @@ int main(void)
|
|||
}
|
||||
|
||||
glfwPollEvents();
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (!glfwIsWindow(windows[i]))
|
||||
running = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
glfwTerminate();
|
||||
|
|
Loading…
Reference in New Issue
Block a user