diff --git a/examples/boing.c b/examples/boing.c index 452695b7..8c4db2fc 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -574,7 +574,9 @@ int main( void ) exit( EXIT_FAILURE ); } - GLFWwindow window = glfwOpenWindow( 400,400, 0,0,0,0, 16,0, GLFW_WINDOW ); + glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + + GLFWwindow window = glfwOpenWindow( 400, 400, GLFW_WINDOW ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/gears.c b/examples/gears.c index 4cf12411..16bf14d9 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -329,7 +329,9 @@ int main(int argc, char *argv[]) exit( EXIT_FAILURE ); } - window = glfwOpenWindow( 300,300, 0,0,0,0, 16,0, GLFW_WINDOW ); + glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + + window = glfwOpenWindow( 300, 300, GLFW_WINDOW ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/splitview.c b/examples/splitview.c index 20e40eb9..cc178c86 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -457,8 +457,10 @@ int main( void ) exit( EXIT_FAILURE ); } + glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + // Open OpenGL window - window = glfwOpenWindow( 500, 500, 0,0,0,0, 16,0, GLFW_WINDOW ); + window = glfwOpenWindow( 500, 500, GLFW_WINDOW ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/triangle.c b/examples/triangle.c index beac3967..b17c2daa 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -23,7 +23,7 @@ int main( void ) } // Open a window and create its OpenGL context - window = glfwOpenWindow( 640, 480, 0,0,0,0, 0,0, GLFW_WINDOW ); + window = glfwOpenWindow( 640, 480, GLFW_WINDOW ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/wave.c b/examples/wave.c index ade50e84..dbb38b31 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -334,8 +334,10 @@ int main(int argc, char* argv[]) height = 480; mode = GLFW_WINDOW; + glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + /* Open window */ - window = glfwOpenWindow(width,height,0,0,0,0,16,0,mode); + window = glfwOpenWindow(width,height,mode); if (!window) { fprintf(stderr, "Could not open window\n"); diff --git a/include/GL/glfw.h b/include/GL/glfw.h index 443e3a83..46f54555 100644 --- a/include/GL/glfw.h +++ b/include/GL/glfw.h @@ -309,16 +309,16 @@ extern "C" { #define GLFW_ACTIVE 0x00020002 #define GLFW_ICONIFIED 0x00020003 #define GLFW_ACCELERATED 0x00020004 + +/* The following constants are used for both glfwGetWindowParam + * and glfwOpenWindowHint + */ #define GLFW_RED_BITS 0x00020005 #define GLFW_GREEN_BITS 0x00020006 #define GLFW_BLUE_BITS 0x00020007 #define GLFW_ALPHA_BITS 0x00020008 #define GLFW_DEPTH_BITS 0x00020009 #define GLFW_STENCIL_BITS 0x0002000A - -/* The following constants are used for both glfwGetWindowParam - * and glfwOpenWindowHint - */ #define GLFW_REFRESH_RATE 0x0002000B #define GLFW_ACCUM_RED_BITS 0x0002000C #define GLFW_ACCUM_GREEN_BITS 0x0002000D @@ -392,7 +392,7 @@ GLFWAPI int glfwGetVideoModes(GLFWvidmode* list, int maxcount); GLFWAPI void glfwGetDesktopMode(GLFWvidmode* mode); /* Window handling */ -GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode); +GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode); GLFWAPI void glfwOpenWindowHint(int target, int hint); GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window); GLFWAPI int glfwIsWindow(GLFWwindow window); diff --git a/lib/internal.h b/lib/internal.h index 297a5995..0cba1881 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -66,6 +66,12 @@ // parameters passed to us by glfwOpenWindowHint //------------------------------------------------------------------------ typedef struct { + int redBits; + int greenBits; + int blueBits; + int alphaBits; + int depthBits; + int stencilBits; int refreshRate; int accumRedBits; int accumGreenBits; diff --git a/lib/window.c b/lib/window.c index ab683074..65705545 100644 --- a/lib/window.c +++ b/lib/window.c @@ -365,10 +365,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, // Create the GLFW window and its associated context //======================================================================== -GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, - int redbits, int greenbits, int bluebits, - int alphabits, int depthbits, int stencilbits, - int mode) +GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode) { _GLFWfbconfig fbconfig; _GLFWwndconfig wndconfig; @@ -386,12 +383,12 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, memset(window, 0, sizeof(_GLFWwindow)); // Set up desired framebuffer config - fbconfig.redBits = Max(redbits, 0); - fbconfig.greenBits = Max(greenbits, 0); - fbconfig.blueBits = Max(bluebits, 0); - fbconfig.alphaBits = Max(alphabits, 0); - fbconfig.depthBits = Max(depthbits, 0); - fbconfig.stencilBits = Max(stencilbits, 0); + fbconfig.redBits = Max(_glfwLibrary.hints.redBits, 0); + fbconfig.greenBits = Max(_glfwLibrary.hints.greenBits, 0); + fbconfig.blueBits = Max(_glfwLibrary.hints.blueBits, 0); + fbconfig.alphaBits = Max(_glfwLibrary.hints.alphaBits, 0); + fbconfig.depthBits = Max(_glfwLibrary.hints.depthBits, 0); + fbconfig.stencilBits = Max(_glfwLibrary.hints.stencilBits, 0); fbconfig.accumRedBits = Max(_glfwLibrary.hints.accumRedBits, 0); fbconfig.accumGreenBits = Max(_glfwLibrary.hints.accumGreenBits, 0); fbconfig.accumBlueBits = Max(_glfwLibrary.hints.accumBlueBits, 0); @@ -572,6 +569,24 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint) switch (target) { + case GLFW_RED_BITS: + _glfwLibrary.hints.redBits = hint; + break; + case GLFW_GREEN_BITS: + _glfwLibrary.hints.greenBits = hint; + break; + case GLFW_BLUE_BITS: + _glfwLibrary.hints.blueBits = hint; + break; + case GLFW_ALPHA_BITS: + _glfwLibrary.hints.alphaBits = hint; + break; + case GLFW_DEPTH_BITS: + _glfwLibrary.hints.depthBits = hint; + break; + case GLFW_STENCIL_BITS: + _glfwLibrary.hints.stencilBits = hint; + break; case GLFW_REFRESH_RATE: _glfwLibrary.hints.refreshRate = hint; break; diff --git a/tests/accuracy.c b/tests/accuracy.c index b379d87e..6ae4379a 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -65,7 +65,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(window_width, window_height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); + window = glfwOpenWindow(window_width, window_height, GLFW_WINDOW); if (!window) { glfwTerminate(); diff --git a/tests/defaults.c b/tests/defaults.c index fe4b1535..14d85de0 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -75,7 +75,7 @@ int main(void) exit(1); } - window = glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); + window = glfwOpenWindow(0, 0, GLFW_WINDOW); if (!window) { glfwTerminate(); diff --git a/tests/events.c b/tests/events.c index bc892b4f..e2f095c0 100644 --- a/tests/events.c +++ b/tests/events.c @@ -274,7 +274,7 @@ int main(void) printf("Library initialized\n"); - window = glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); + window = glfwOpenWindow(0, 0, GLFW_WINDOW); if (!window) { glfwTerminate(); diff --git a/tests/fsaa.c b/tests/fsaa.c index c562bf3c..4095b650 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -55,7 +55,7 @@ int main(void) glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); - window = glfwOpenWindow(400, 400, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); + window = glfwOpenWindow(400, 400, GLFW_WINDOW); if (!window) { glfwTerminate(); diff --git a/tests/peter.c b/tests/peter.c index 16eae882..4cd5cb45 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -89,7 +89,7 @@ static GLboolean open_window(void) { int x, y; - window_handle = glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); + window_handle = glfwOpenWindow(0, 0, GLFW_WINDOW); if (!window_handle) return GL_FALSE; diff --git a/tests/reopen.c b/tests/reopen.c index 829f68ae..9d6ffe5b 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -84,7 +84,9 @@ static int open_window(int width, int height, int mode) { double base = glfwGetTime(); - window_handle = glfwOpenWindow(width, height, 0, 0, 0, 0, 16, 0, mode); + glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + + window_handle = glfwOpenWindow(width, height, mode); if (!window_handle) { fprintf(stderr, "Failed to create %s mode GLFW window\n", get_mode_name(mode)); diff --git a/tests/tearing.c b/tests/tearing.c index 0d9de6e6..9824c800 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -50,7 +50,7 @@ int main(void) exit(1); } - window = glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW); + window = glfwOpenWindow(0, 0, GLFW_WINDOW); if (!window) { glfwTerminate(); diff --git a/tests/version.c b/tests/version.c index 28f41b76..ef91a1f2 100644 --- a/tests/version.c +++ b/tests/version.c @@ -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, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) + if (!glfwOpenWindow(0, 0, GLFW_WINDOW)) { glfwTerminate();