From 1f622adf0a379fc942a6d3d0706cb11bb41d2aa2 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 17 Nov 2010 16:06:15 +0100 Subject: [PATCH 1/3] Replaced inline declarations with glext.h use. --- tests/fsaa.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/fsaa.c b/tests/fsaa.c index e5a187a0..73a20563 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -30,14 +30,11 @@ //======================================================================== #include +#include #include #include -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#endif - static void window_size_callback(GLFWwindow window, int width, int height) { glViewport(0, 0, width, height); From 940b69816c68b828c8046d67d1c296f1aaab91fa Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 17 Nov 2010 16:14:27 +0100 Subject: [PATCH 2/3] Made rendering and window size more sane. --- tests/fsaa.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/fsaa.c b/tests/fsaa.c index 73a20563..36ba09a4 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -53,7 +53,7 @@ int main(void) glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); - window = glfwOpenWindow(400, 400, GLFW_WINDOWED, "Aliasing Detector", NULL); + window = glfwOpenWindow(800, 400, GLFW_WINDOWED, "Aliasing Detector", NULL); if (!window) { glfwTerminate(); @@ -72,7 +72,8 @@ int main(void) printf("Context reports FSAA is unsupported\n"); glMatrixMode(GL_PROJECTION); - gluOrtho2D(0.f, 1.f, 0.f, 1.f); + gluOrtho2D(0.f, 1.f, 0.f, 0.5f); + glMatrixMode(GL_MODELVIEW); while (glfwIsWindow(window)) { @@ -80,21 +81,21 @@ int main(void) glClear(GL_COLOR_BUFFER_BIT); - glLoadIdentity(); - glTranslatef(0.5f, 0.f, 0.f); - glRotatef(time, 0.f, 0.f, 1.f); - - glEnable(GL_MULTISAMPLE_ARB); glColor3f(1.f, 1.f, 1.f); - glRectf(-0.25f, -0.25f, 0.25f, 0.25f); glLoadIdentity(); - glTranslatef(-0.5f, 0.f, 0.f); + glTranslatef(0.25f, 0.25f, 0.f); glRotatef(time, 0.f, 0.f, 1.f); glDisable(GL_MULTISAMPLE_ARB); - glColor3f(1.f, 1.f, 1.f); - glRectf(-0.25f, -0.25f, 0.25f, 0.25f); + glRectf(-0.15f, -0.15f, 0.15f, 0.15f); + + glLoadIdentity(); + glTranslatef(0.75f, 0.25f, 0.f); + glRotatef(time, 0.f, 0.f, 1.f); + + glEnable(GL_MULTISAMPLE_ARB); + glRectf(-0.15f, -0.15f, 0.15f, 0.15f); glfwSwapBuffers(); glfwPollEvents(); From 57e14372f22de2d733930558da3a4f35a65c6462 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Wed, 17 Nov 2010 16:26:32 +0100 Subject: [PATCH 3/3] Added getopt and sample count switch to FSAA test. --- tests/CMakeLists.txt | 3 +-- tests/fsaa.c | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9d53b9f2..dbb20116 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include ${OPENGL_INCLUDE_DIR} add_executable(defaults defaults.c) add_executable(events events.c) +add_executable(fsaa fsaa.c getopt.c) add_executable(fsfocus fsfocus.c) add_executable(gamma gamma.c getopt.c) add_executable(iconify iconify.c getopt.c) @@ -17,7 +18,6 @@ add_executable(version version.c getopt.c) if(APPLE) # Set fancy names for bundles add_executable(Accuracy MACOSX_BUNDLE accuracy.c) - add_executable(FSAA MACOSX_BUNDLE fsaa.c) add_executable(Sharing MACOSX_BUNDLE sharing.c) add_executable(Tearing MACOSX_BUNDLE tearing.c) add_executable(Windows MACOSX_BUNDLE windows.c) @@ -26,7 +26,6 @@ else() add_executable(accuracy WIN32 accuracy.c) add_executable(sharing WIN32 sharing.c) add_executable(tearing WIN32 tearing.c) - add_executable(fsaa WIN32 fsaa.c) add_executable(windows WIN32 windows.c) endif(APPLE) diff --git a/tests/fsaa.c b/tests/fsaa.c index 36ba09a4..afc2729a 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -35,23 +35,51 @@ #include #include +#include "getopt.h" + static void window_size_callback(GLFWwindow window, int width, int height) { glViewport(0, 0, width, height); } -int main(void) +static void usage(void) { - int samples; + printf("Usage: fsaa [-h] [-s SAMPLES]\n"); +} + +int main(int argc, char** argv) +{ + int ch, samples = 4; GLFWwindow window; + while ((ch = getopt(argc, argv, "hs:")) != -1) + { + switch (ch) + { + case 'h': + usage(); + exit(EXIT_SUCCESS); + case 's': + samples = atoi(optarg); + break; + default: + usage(); + exit(EXIT_FAILURE); + } + } + if (!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); exit(EXIT_FAILURE); } - glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); + if (samples) + printf("Requesting FSAA with %i samples\n", samples); + else + printf("Requesting that FSAA not be available\n"); + + glfwOpenWindowHint(GLFW_FSAA_SAMPLES, samples); window = glfwOpenWindow(800, 400, GLFW_WINDOWED, "Aliasing Detector", NULL); if (!window) @@ -67,9 +95,9 @@ int main(void) samples = glfwGetWindowParam(window, GLFW_FSAA_SAMPLES); if (samples) - printf("Context reports FSAA is supported with %i samples\n", samples); + printf("Context reports FSAA is available with %i samples\n", samples); else - printf("Context reports FSAA is unsupported\n"); + printf("Context reports FSAA is unavailable\n"); glMatrixMode(GL_PROJECTION); gluOrtho2D(0.f, 1.f, 0.f, 0.5f);