Added GLFW error strings to test programs, various tweaks.

This commit is contained in:
Camilla Berglund 2010-09-11 14:32:05 +02:00
parent a79a6eb82a
commit abaac3ea99
11 changed files with 38 additions and 34 deletions

View File

@ -61,7 +61,7 @@ int main(void)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -70,7 +70,7 @@ int main(void)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW window\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -71,7 +71,7 @@ int main(void)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(1);
} }
@ -80,7 +80,7 @@ int main(void)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW default window\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(1);
} }

View File

@ -268,7 +268,7 @@ int main(void)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(1);
} }
@ -279,7 +279,7 @@ int main(void)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to create GLFW window"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(1);
} }

View File

@ -49,7 +49,7 @@ int main(void)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -60,7 +60,7 @@ int main(void)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW window\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -91,7 +91,7 @@ int main(int argc, char** argv)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -112,7 +112,7 @@ int main(int argc, char** argv)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW window\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -6,6 +6,7 @@
#include <GL/glfw3.h> #include <GL/glfw3.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <math.h> #include <math.h>
#define MAX_AXES 10 #define MAX_AXES 10
@ -93,7 +94,12 @@ int main(void)
double update; double update;
/* Initialise GLFW */ /* Initialise GLFW */
glfwInit(); if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE);
}
printf("The program will work for 20 seconds and display every seconds the state of the joysticks\n"); printf("The program will work for 20 seconds and display every seconds the state of the joysticks\n");
printf("Your computer is going to be very slow as the program is doing an active loop .....\n"); printf("Your computer is going to be very slow as the program is doing an active loop .....\n");

View File

@ -110,16 +110,16 @@ int main(void)
{ {
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(EXIT_FAILURE);
} }
if (!open_window()) if (!open_window())
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW window\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(EXIT_FAILURE);
} }
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
@ -133,6 +133,6 @@ int main(void)
} }
glfwTerminate(); glfwTerminate();
exit(0); exit(EXIT_SUCCESS);
} }

View File

@ -84,12 +84,10 @@ static int open_window(int width, int height, int mode)
{ {
double base = glfwGetTime(); double base = glfwGetTime();
glfwOpenWindowHint(GLFW_DEPTH_BITS, 16);
window_handle = glfwOpenWindow(width, height, mode); window_handle = glfwOpenWindow(width, height, mode);
if (!window_handle) if (!window_handle)
{ {
fprintf(stderr, "Failed to create %s mode GLFW window\n", get_mode_name(mode)); fprintf(stderr, "Failed to open %s mode GLFW window: %s\n", get_mode_name(mode), glfwErrorString(glfwGetError()));
return 0; return 0;
} }
@ -122,8 +120,8 @@ int main(int argc, char** argv)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(EXIT_FAILURE);
} }
for (;;) for (;;)
@ -131,7 +129,7 @@ int main(int argc, char** argv)
if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED)) if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED))
{ {
glfwTerminate(); glfwTerminate();
exit(1); exit(EXIT_FAILURE);
} }
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
@ -163,7 +161,7 @@ int main(int argc, char** argv)
printf("User closed window\n"); printf("User closed window\n");
glfwTerminate(); glfwTerminate();
exit(0); exit(EXIT_SUCCESS);
} }
} }

View File

@ -46,8 +46,8 @@ int main(void)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(EXIT_FAILURE);
} }
window = glfwOpenWindow(0, 0, GLFW_WINDOWED); window = glfwOpenWindow(0, 0, GLFW_WINDOWED);
@ -55,8 +55,8 @@ int main(void)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW window\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(1); exit(EXIT_FAILURE);
} }
glfwSetWindowTitle(window, "Tearing Detector"); glfwSetWindowTitle(window, "Tearing Detector");
@ -82,6 +82,6 @@ int main(void)
} }
glfwTerminate(); glfwTerminate();
exit(0); exit(EXIT_SUCCESS);
} }

View File

@ -58,7 +58,7 @@ typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGI) (GLenum, GLuint);
static void usage(void) static void usage(void)
{ {
printf("version [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE]\n"); printf("Usage: version [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE]\n");
printf("available profiles: core compat\n"); printf("available profiles: core compat\n");
} }
@ -85,7 +85,7 @@ static void list_extensions(int major, int minor)
PFNGLGETSTRINGI glGetStringi = (PFNGLGETSTRINGI) glfwGetProcAddress("glGetStringi"); PFNGLGETSTRINGI glGetStringi = (PFNGLGETSTRINGI) glfwGetProcAddress("glGetStringi");
if (!glGetStringi) if (!glGetStringi)
{ {
fprintf(stderr, "Failed to retrieve glGetStringi entry point"); fprintf(stderr, "Failed to retrieve glGetStringi entry point: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -161,7 +161,7 @@ int main(int argc, char** argv)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -187,7 +187,7 @@ int main(int argc, char** argv)
{ {
glfwTerminate(); glfwTerminate();
fprintf(stderr, "Failed to open GLFW window\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

View File

@ -45,7 +45,7 @@ static GLFWwindow open_window(int width, int height, const char* title)
GLFWwindow window = glfwOpenWindow(width, height, GLFW_WINDOWED); GLFWwindow window = glfwOpenWindow(width, height, GLFW_WINDOWED);
if (!window) if (!window)
{ {
fprintf(stderr, "Failed to open GLFW default window\n"); fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
return NULL; return NULL;
} }
@ -62,7 +62,7 @@ int main(void)
if (!glfwInit()) if (!glfwInit())
{ {
fprintf(stderr, "Failed to initialize GLFW\n"); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }