Updated example and test programs to new API.

This commit is contained in:
Camilla Berglund 2010-09-14 03:10:59 +02:00
parent 0f80e066ea
commit e244ad3d41
15 changed files with 17 additions and 48 deletions

View File

@ -577,7 +577,7 @@ int main( void )
glfwOpenWindowHint(GLFW_DEPTH_BITS, 16);
window = glfwOpenWindow( 400, 400, GLFW_WINDOWED );
window = glfwOpenWindow( 400, 400, GLFW_WINDOWED, "Boing (classic Amiga demo)" );
if (!window)
{
fprintf( stderr, "Failed to open GLFW window\n" );
@ -585,7 +585,6 @@ int main( void )
exit( EXIT_FAILURE );
}
glfwSetWindowTitle( window, "Boing (classic Amiga demo)" );
glfwSetWindowSizeCallback( window, reshape );
glfwEnable( window, GLFW_STICKY_KEYS );
glfwSwapInterval( 1 );

View File

@ -331,7 +331,7 @@ int main(int argc, char *argv[])
glfwOpenWindowHint(GLFW_DEPTH_BITS, 16);
window = glfwOpenWindow( 300, 300, GLFW_WINDOWED );
window = glfwOpenWindow( 300, 300, GLFW_WINDOWED, "Gears" );
if (!window)
{
fprintf( stderr, "Failed to open GLFW window\n" );
@ -339,7 +339,6 @@ int main(int argc, char *argv[])
exit( EXIT_FAILURE );
}
glfwSetWindowTitle( window, "Gears" );
glfwEnable( window, GLFW_KEY_REPEAT );
glfwSwapInterval( 1 );

View File

@ -460,7 +460,7 @@ int main( void )
glfwOpenWindowHint(GLFW_DEPTH_BITS, 16);
// Open OpenGL window
window = glfwOpenWindow( 500, 500, GLFW_WINDOWED );
window = glfwOpenWindow( 500, 500, GLFW_WINDOWED, "Split view demo" );
if (!window)
{
fprintf( stderr, "Failed to open GLFW window\n" );
@ -471,9 +471,6 @@ int main( void )
// Enable vsync
glfwSwapInterval( 1 );
// Set window title
glfwSetWindowTitle( window, "Split view demo" );
// Enable sticky keys
glfwEnable( window, GLFW_STICKY_KEYS );

View File

@ -23,7 +23,7 @@ int main( void )
}
// Open a window and create its OpenGL context
window = glfwOpenWindow( 640, 480, GLFW_WINDOWED );
window = glfwOpenWindow( 640, 480, GLFW_WINDOWED, "Spinning Triangle" );
if (!window)
{
fprintf( stderr, "Failed to open GLFW window\n" );
@ -32,8 +32,6 @@ int main( void )
exit( EXIT_FAILURE );
}
glfwSetWindowTitle( window, "Spinning Triangle" );
// Ensure we can capture the escape key being pressed below
glfwEnable( window, GLFW_STICKY_KEYS );

View File

@ -337,7 +337,7 @@ int main(int argc, char* argv[])
glfwOpenWindowHint(GLFW_DEPTH_BITS, 16);
/* Open window */
window = glfwOpenWindow(width,height,mode);
window = glfwOpenWindow(width, height, mode, "Wave Simulation");
if (!window)
{
fprintf(stderr, "Could not open window\n");
@ -345,9 +345,6 @@ int main(int argc, char* argv[])
exit(-1);
}
/* Set title */
glfwSetWindowTitle( window, "Wave Simulation" );
glfwSwapInterval( 1 );
/* Keyboard handler */

View File

@ -65,7 +65,7 @@ int main(void)
exit(EXIT_FAILURE);
}
window = glfwOpenWindow(window_width, window_height, GLFW_WINDOWED);
window = glfwOpenWindow(window_width, window_height, GLFW_WINDOWED, "Cursor Inaccuracy Detector");
if (!window)
{
glfwTerminate();
@ -74,7 +74,6 @@ int main(void)
exit(EXIT_FAILURE);
}
glfwSetWindowTitle(window, "Cursor Inaccuracy Detector");
glfwSetMousePosCallback(window, mouse_position_callback);
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSwapInterval(1);

View File

@ -75,7 +75,7 @@ int main(void)
exit(1);
}
window = glfwOpenWindow(0, 0, GLFW_WINDOWED);
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Defaults");
if (!window)
{
glfwTerminate();

View File

@ -274,7 +274,7 @@ int main(void)
printf("Library initialized\n");
window = glfwOpenWindow(0, 0, GLFW_WINDOWED);
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Event Linter");
if (!window)
{
glfwTerminate();
@ -285,7 +285,6 @@ int main(void)
printf("Window opened\n");
glfwSetWindowTitle(window, "Event Linter");
glfwSwapInterval(1);
glfwSetWindowSizeCallback(window, window_size_callback);

View File

@ -56,7 +56,7 @@ int main(void)
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
window = glfwOpenWindow(400, 400, GLFW_WINDOWED);
window = glfwOpenWindow(400, 400, GLFW_WINDOWED, "Aliasing Detector");
if (!window)
{
glfwTerminate();
@ -65,7 +65,6 @@ int main(void)
exit(EXIT_FAILURE);
}
glfwSetWindowTitle(window, "Aliasing Detector");
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSwapInterval(1);

View File

@ -109,7 +109,7 @@ int main(int argc, char** argv)
height = 0;
}
window = glfwOpenWindow(width, height, mode);
window = glfwOpenWindow(width, height, mode, "Iconify");
if (!window)
{
glfwTerminate();
@ -118,7 +118,6 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE);
}
glfwSetWindowTitle(window, "Iconify");
glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback);
glfwSetWindowSizeCallback(window, size_callback);

View File

@ -89,12 +89,10 @@ static GLboolean open_window(void)
{
int x, y;
window_handle = glfwOpenWindow(0, 0, GLFW_WINDOWED);
window_handle = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Peter Detector");
if (!window_handle)
return GL_FALSE;
glfwSetWindowTitle(window_handle, "Peter Detector");
glfwGetMousePos(window_handle, &x, &y);
printf("Mouse position: %i %i\n", x, y);

View File

@ -84,14 +84,13 @@ static int open_window(int width, int height, int mode)
{
double base = glfwGetTime();
window_handle = glfwOpenWindow(width, height, mode);
window_handle = glfwOpenWindow(width, height, mode, "Window Re-opener");
if (!window_handle)
{
fprintf(stderr, "Failed to open %s mode GLFW window: %s\n", get_mode_name(mode), glfwErrorString(glfwGetError()));
return 0;
}
glfwSetWindowTitle(window_handle, "Window Re-opener");
glfwSetWindowSizeCallback(window_handle, window_size_callback);
glfwSetWindowCloseCallback(window_handle, window_close_callback);
glfwSetKeyCallback(window_handle, key_callback);

View File

@ -50,7 +50,7 @@ int main(void)
exit(EXIT_FAILURE);
}
window = glfwOpenWindow(0, 0, GLFW_WINDOWED);
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Tearing Detector");
if (!window)
{
glfwTerminate();
@ -59,7 +59,6 @@ int main(void)
exit(EXIT_FAILURE);
}
glfwSetWindowTitle(window, "Tearing Detector");
glfwSetWindowSizeCallback(window, window_size_callback);
glfwSwapInterval(1);

View File

@ -183,7 +183,7 @@ int main(int argc, char** argv)
// We assume here that we stand a better chance of success by leaving all
// possible details of pixel format selection to GLFW
if (!glfwOpenWindow(0, 0, GLFW_WINDOWED))
if (!glfwOpenWindow(0, 0, GLFW_WINDOWED, "Version"))
{
glfwTerminate();

View File

@ -40,20 +40,6 @@ static const char* titles[] =
"Quux"
};
static GLFWwindow open_window(int width, int height, const char* title)
{
GLFWwindow window = glfwOpenWindow(width, height, GLFW_WINDOWED);
if (!window)
{
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
return NULL;
}
glfwSetWindowTitle(window, title);
return window;
}
int main(void)
{
int i;
@ -62,16 +48,17 @@ int main(void)
if (!glfwInit())
{
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE);
}
for (i = 0; i < 4; i++)
{
windows[i] = open_window(200, 200, titles[i]);
windows[i] = glfwOpenWindow(200, 200, GLFW_WINDOWED, titles[i]);
if (!windows[i])
{
glfwTerminate();
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE);
}