From 5df4df6ca49dc156556d177cf21c35e5f1545175 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Mon, 22 Oct 2012 02:59:05 +0200
Subject: [PATCH] Added glfwDefaultWindowHints.
---
include/GL/glfw3.h | 1 +
readme.html | 1 +
src/init.c | 6 ++---
src/internal.h | 3 ---
src/window.c | 61 ++++++++++++++++++++++++----------------------
5 files changed, 37 insertions(+), 35 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 968ab0db..df0ac6b1 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -529,6 +529,7 @@ GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp);
GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
/* Window handling */
+GLFWAPI void glfwDefaultWindowHints(void);
GLFWAPI void glfwWindowHint(int target, int hint);
GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, int mode, const char* title, GLFWwindow share);
GLFWAPI void glfwDestroyWindow(GLFWwindow window);
diff --git a/readme.html b/readme.html
index 22e2b6bb..a40e1d35 100644
--- a/readme.html
+++ b/readme.html
@@ -268,6 +268,7 @@ version of GLFW.
v3.0
- Added
GLFWwindow
window handle type and updated window-related functions and callbacks to take a window handle
+ - Added
glfwDefaultWindowHints
function for resetting all window hints to their default values
- Added
glfwMakeContextCurrent
function for making the context of the specified window current
- Added
glfwGetError
and glfwErrorString
error reporting functions and a number of error tokens
- Added
glfwSetErrorCallback
function and GLFWerrorfun
type for receiving more specific and/or nested errors
diff --git a/src/init.c b/src/init.c
index 7e9fe4e7..12d806cc 100644
--- a/src/init.c
+++ b/src/init.c
@@ -121,9 +121,6 @@ GLFWAPI int glfwInit(void)
memset(&_glfwLibrary, 0, sizeof(_glfwLibrary));
- // Not all window hints have zero as their default value
- _glfwSetDefaultWindowHints();
-
if (!_glfwPlatformInit())
{
_glfwPlatformTerminate();
@@ -134,6 +131,9 @@ GLFWAPI int glfwInit(void)
_glfwInitialized = GL_TRUE;
+ // Not all window hints have zero as their default value
+ glfwDefaultWindowHints();
+
return GL_TRUE;
}
diff --git a/src/internal.h b/src/internal.h
index 67aa3151..01767c96 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -350,9 +350,6 @@ void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
// Error handling (init.c)
void _glfwSetError(int error, const char* format, ...);
-// Window management (window.c)
-void _glfwSetDefaultWindowHints(void);
-
// OpenGL context helpers (opengl.c)
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
diff --git a/src/window.c b/src/window.c
index bb1093f5..c48fceb6 100644
--- a/src/window.c
+++ b/src/window.c
@@ -68,32 +68,6 @@ static void clearScrollOffsets(void)
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
-//========================================================================
-// Reset all window hints to their default values
-//========================================================================
-
-void _glfwSetDefaultWindowHints(void)
-{
- memset(&_glfwLibrary.hints, 0, sizeof(_glfwLibrary.hints));
-
- // The default is OpenGL with minimum version 1.0
- _glfwLibrary.hints.clientAPI = GLFW_OPENGL_API;
- _glfwLibrary.hints.glMajor = 1;
- _glfwLibrary.hints.glMinor = 0;
-
- // The default is to show the window and allow window resizing
- _glfwLibrary.hints.resizable = GL_TRUE;
- _glfwLibrary.hints.visible = GL_TRUE;
-
- // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
- _glfwLibrary.hints.redBits = 8;
- _glfwLibrary.hints.greenBits = 8;
- _glfwLibrary.hints.blueBits = 8;
- _glfwLibrary.hints.depthBits = 24;
- _glfwLibrary.hints.stencilBits = 8;
-}
-
-
//========================================================================
// Register window focus events
//========================================================================
@@ -273,9 +247,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
wndconfig.glRobustness = _glfwLibrary.hints.glRobustness ? GL_TRUE : GL_FALSE;
wndconfig.share = (_GLFWwindow*) share;
- // Reset to default values for the next call
- _glfwSetDefaultWindowHints();
-
// Check the OpenGL bits of the window config
if (!_glfwIsValidContextConfig(&wndconfig))
return GL_FALSE;
@@ -375,6 +346,38 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
}
+//========================================================================
+// Reset all window hints to their default values
+//========================================================================
+
+void glfwDefaultWindowHints(void)
+{
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
+ return;
+ }
+
+ memset(&_glfwLibrary.hints, 0, sizeof(_glfwLibrary.hints));
+
+ // The default is OpenGL with minimum version 1.0
+ _glfwLibrary.hints.clientAPI = GLFW_OPENGL_API;
+ _glfwLibrary.hints.glMajor = 1;
+ _glfwLibrary.hints.glMinor = 0;
+
+ // The default is to show the window and allow window resizing
+ _glfwLibrary.hints.resizable = GL_TRUE;
+ _glfwLibrary.hints.visible = GL_TRUE;
+
+ // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
+ _glfwLibrary.hints.redBits = 8;
+ _glfwLibrary.hints.greenBits = 8;
+ _glfwLibrary.hints.blueBits = 8;
+ _glfwLibrary.hints.depthBits = 24;
+ _glfwLibrary.hints.stencilBits = 8;
+}
+
+
//========================================================================
// Set hints for creating the window
//========================================================================