Fixed and separated GLFW version check.

This commit is contained in:
Camilla Berglund 2012-08-30 02:17:08 +02:00
parent 2502e4d6f3
commit 733cd5372f

View File

@ -119,6 +119,32 @@ static void list_extensions(int major, int minor)
putchar('\n'); putchar('\n');
} }
static GLboolean valid_version(void)
{
int major, minor, revision;
glfwGetVersion(&major, &minor, &revision);
printf("GLFW header version: %u.%u.%u\n",
GLFW_VERSION_MAJOR,
GLFW_VERSION_MINOR,
GLFW_VERSION_REVISION);
printf("GLFW library version: %u.%u.%u\n", major, minor, revision);
if (major != GLFW_VERSION_MAJOR)
{
printf("*** ERROR: GLFW major version mismatch! ***\n");
return GL_FALSE;
}
if (minor != GLFW_VERSION_MINOR || revision != GLFW_VERSION_REVISION)
printf("*** WARNING: GLFW version mismatch! ***\n");
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
return GL_TRUE;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int ch, profile = 0, strategy = 0, major = 1, minor = 0, revision; int ch, profile = 0, strategy = 0, major = 1, minor = 0, revision;
@ -126,6 +152,9 @@ int main(int argc, char** argv)
GLint flags, mask; GLint flags, mask;
GLFWwindow window; GLFWwindow window;
if (!valid_version())
exit(EXIT_FAILURE);
while ((ch = getopt(argc, argv, "dfhlm:n:p:r:")) != -1) while ((ch = getopt(argc, argv, "dfhlm:n:p:r:")) != -1)
{ {
switch (ch) switch (ch)
@ -181,26 +210,6 @@ int main(int argc, char** argv)
argc -= optind; argc -= optind;
argv += optind; argv += optind;
// Report GLFW version
glfwGetVersion(&major, &minor, &revision);
printf("GLFW header version: %u.%u.%u\n",
GLFW_VERSION_MAJOR,
GLFW_VERSION_MINOR,
GLFW_VERSION_REVISION);
printf("GLFW library version: %u.%u.%u\n", major, minor, revision);
if (major != GLFW_VERSION_MAJOR ||
minor != GLFW_VERSION_MINOR ||
revision != GLFW_VERSION_REVISION)
{
printf("*** WARNING: GLFW version mismatch! ***\n");
}
printf("GLFW library version string: \"%s\"\n", glfwGetVersionString());
// Initialize GLFW and create window // Initialize GLFW and create window
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);