mirror of
				https://github.com/glfw/glfw.git
				synced 2025-10-31 20:52:38 +00:00 
			
		
		
		
	Merge branch 'utf8' into multi-monitor
Conflicts: src/CMakeLists.txt
This commit is contained in:
		
						commit
						6b98a04d17
					
				| @ -166,12 +166,9 @@ install(FILES COPYING.txt readme.html | ||||
| #-------------------------------------------------------------------- | ||||
| # -- Documentation generation  | ||||
| #-------------------------------------------------------------------- | ||||
| #include("${GLFW_SOURCE_DIR}/documentation.cmake") | ||||
| #configure_file("${GLFW_SOURCE_DIR}/Doxyfile.in" | ||||
| #               "${GLFW_BINARY_DIR}/Doxyfile" | ||||
| #               IMMEDIATE @ONLY) | ||||
| #add_doxygen_target("${GLFW_BINARY_DIR}/Doxyfile") | ||||
| #add_subdirectory(docs) | ||||
| configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in" | ||||
|                "${GLFW_BINARY_DIR}/docs/Doxyfile" | ||||
|                @ONLY) | ||||
| 
 | ||||
| #-------------------------------------------------------------------- | ||||
| # Uninstall operation | ||||
|  | ||||
							
								
								
									
										1687
									
								
								docs/Doxyfile.in
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1687
									
								
								docs/Doxyfile.in
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -569,7 +569,7 @@ int main( void ) | ||||
|    GLFWwindow window; | ||||
| 
 | ||||
|    /* Init GLFW */ | ||||
|    if( !glfwInit() ) | ||||
|    if( !glfwInit(NULL) ) | ||||
|    { | ||||
|       fprintf( stderr, "Failed to initialize GLFW\n" ); | ||||
|       exit( EXIT_FAILURE ); | ||||
| @ -586,7 +586,7 @@ int main( void ) | ||||
|    } | ||||
| 
 | ||||
|    glfwSetWindowSizeCallback( reshape ); | ||||
|    glfwEnable( window, GLFW_STICKY_KEYS ); | ||||
|    glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE ); | ||||
|    glfwSwapInterval( 1 ); | ||||
|    glfwSetTime( 0.0 ); | ||||
| 
 | ||||
|  | ||||
| @ -323,7 +323,7 @@ int main(int argc, char *argv[]) | ||||
| { | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     if( !glfwInit() ) | ||||
|     if( !glfwInit(NULL) ) | ||||
|     { | ||||
|         fprintf( stderr, "Failed to initialize GLFW\n" ); | ||||
|         exit( EXIT_FAILURE ); | ||||
| @ -339,7 +339,7 @@ int main(int argc, char *argv[]) | ||||
|         exit( EXIT_FAILURE ); | ||||
|     } | ||||
| 
 | ||||
|     glfwEnable( window, GLFW_KEY_REPEAT ); | ||||
|     glfwSetInputMode( window, GLFW_KEY_REPEAT, GL_TRUE ); | ||||
|     glfwSwapInterval( 1 ); | ||||
| 
 | ||||
|     // Parse command-line options
 | ||||
|  | ||||
| @ -573,7 +573,7 @@ int main(int argc, char** argv) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (GL_TRUE != glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "ERROR: Unable to initialize GLFW\n"); | ||||
|         usage(); | ||||
|  | ||||
| @ -442,7 +442,7 @@ int main(void) | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     // Initialise GLFW
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW\n"); | ||||
|         exit(EXIT_FAILURE); | ||||
| @ -462,10 +462,10 @@ int main(void) | ||||
|     glfwSwapInterval(1); | ||||
| 
 | ||||
|     // Enable sticky keys
 | ||||
|     glfwEnable(window, GLFW_STICKY_KEYS); | ||||
|     glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); | ||||
| 
 | ||||
|     // Enable mouse cursor (only needed for fullscreen mode)
 | ||||
|     glfwSetCursorMode(window, GLFW_CURSOR_NORMAL); | ||||
|     glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); | ||||
| 
 | ||||
|     // Set callback functions
 | ||||
|     glfwSetWindowSizeCallback(windowSizeFun); | ||||
|  | ||||
| @ -15,7 +15,7 @@ int main(void) | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     // Initialise GLFW
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW\n"); | ||||
|         exit(EXIT_FAILURE); | ||||
| @ -30,7 +30,7 @@ int main(void) | ||||
|     } | ||||
| 
 | ||||
|     // Ensure we can capture the escape key being pressed below
 | ||||
|     glfwEnable(window, GLFW_STICKY_KEYS); | ||||
|     glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); | ||||
| 
 | ||||
|     // Enable vertical sync (on cards that support it)
 | ||||
|     glfwSwapInterval(1); | ||||
|  | ||||
| @ -309,13 +309,13 @@ void mouse_button_callback(GLFWwindow window, int button, int action) | ||||
| 
 | ||||
|     if (action == GLFW_PRESS) | ||||
|     { | ||||
|         glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED); | ||||
|         glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED); | ||||
|         locked = GL_TRUE; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         locked = GL_FALSE; | ||||
|         glfwSetCursorMode(window, GLFW_CURSOR_NORMAL); | ||||
|         glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -379,7 +379,7 @@ int main(int argc, char* argv[]) | ||||
|     GLFWwindow window; | ||||
|     double t, dt_total, t_old; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "GLFW initialization failed\n"); | ||||
|         exit(EXIT_FAILURE); | ||||
| @ -396,7 +396,7 @@ int main(int argc, char* argv[]) | ||||
| 
 | ||||
|     // Keyboard handler
 | ||||
|     glfwSetKeyCallback(key_callback); | ||||
|     glfwEnable(window, GLFW_KEY_REPEAT); | ||||
|     glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE); | ||||
| 
 | ||||
|     // Window resize handler
 | ||||
|     glfwSetWindowSizeCallback(window_resize_callback); | ||||
|  | ||||
| @ -427,13 +427,14 @@ extern "C" { | ||||
| #define GLFW_OPENGL_COMPAT_PROFILE 0x00000002 | ||||
| #define GLFW_OPENGL_ES2_PROFILE   0x00000004 | ||||
| 
 | ||||
| /* glfwEnable/glfwDisable tokens */ | ||||
| /* glfwGetInputMode/glfwSetInputMode tokens */ | ||||
| #define GLFW_CURSOR_MODE          0x00030001 | ||||
| #define GLFW_STICKY_KEYS          0x00030002 | ||||
| #define GLFW_STICKY_MOUSE_BUTTONS 0x00030003 | ||||
| #define GLFW_SYSTEM_KEYS          0x00030004 | ||||
| #define GLFW_KEY_REPEAT           0x00030005 | ||||
| 
 | ||||
| /* glfwSetCursorMode tokens */ | ||||
| /* GLFW_CURSOR_MODE values */ | ||||
| #define GLFW_CURSOR_NORMAL       0x00040001 | ||||
| #define GLFW_CURSOR_HIDDEN       0x00040002 | ||||
| #define GLFW_CURSOR_CAPTURED     0x00040003 | ||||
| @ -518,20 +519,13 @@ typedef struct | ||||
|     GLFWfreefun free; | ||||
| } GLFWallocator; | ||||
| 
 | ||||
| /* Custom threading model interface */ | ||||
| typedef struct | ||||
| { | ||||
|     int dummy; | ||||
| } GLFWthreadmodel; | ||||
| 
 | ||||
| 
 | ||||
| /*************************************************************************
 | ||||
|  * Prototypes | ||||
|  *************************************************************************/ | ||||
| 
 | ||||
| /* Initialization, termination and version querying */ | ||||
| GLFWAPI int  glfwInit(void); | ||||
| GLFWAPI int  glfwInitWithModels(GLFWthreadmodel* threading, GLFWallocator* allocator); | ||||
| GLFWAPI int  glfwInit(GLFWallocator* allocator); | ||||
| GLFWAPI void glfwTerminate(void); | ||||
| GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); | ||||
| GLFWAPI const char* glfwGetVersionString(void); | ||||
| @ -588,11 +582,12 @@ GLFWAPI void glfwPollEvents(void); | ||||
| GLFWAPI void glfwWaitEvents(void); | ||||
| 
 | ||||
| /* Input handling */ | ||||
| GLFWAPI int  glfwGetInputMode(GLFWwindow window, int mode); | ||||
| GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value); | ||||
| GLFWAPI int  glfwGetKey(GLFWwindow window, int key); | ||||
| GLFWAPI int  glfwGetMouseButton(GLFWwindow window, int button); | ||||
| GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos); | ||||
| GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos); | ||||
| GLFWAPI void glfwSetCursorMode(GLFWwindow window, int mode); | ||||
| GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* xoffset, int* yoffset); | ||||
| GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun); | ||||
| GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun); | ||||
| @ -618,10 +613,6 @@ GLFWAPI int   glfwExtensionSupported(const char* extension); | ||||
| GLFWAPI void* glfwGetProcAddress(const char* procname); | ||||
| GLFWAPI void  glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask); | ||||
| 
 | ||||
| /* Enable/disable functions */ | ||||
| GLFWAPI void glfwEnable(GLFWwindow window, int token); | ||||
| GLFWAPI void glfwDisable(GLFWwindow window, int token); | ||||
| 
 | ||||
| 
 | ||||
| /*************************************************************************
 | ||||
|  * Global definition cleanup | ||||
|  | ||||
							
								
								
									
										10
									
								
								readme.html
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								readme.html
									
									
									
									
									
								
							| @ -272,9 +272,8 @@ version of GLFW.</p> | ||||
|   <li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li> | ||||
|   <li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li> | ||||
|   <li>Added <code>glfwGetCurrentContext</code> function for retrieving the window whose OpenGL context is current</li> | ||||
|   <li>Added <code>glfwInitWithModels</code> function and <code>GLFWallocator</code> and <code>GLFWthreadmodel</code> types for pluggable memory allocation and threading models</li> | ||||
|   <li>Added <code>GLFWallocator</code> type and <code>glfwInit</code> parameter for pluggable memory allocator</li> | ||||
|   <li>Added <code>glfwCopyContext</code> function for copying OpenGL state categories between contexts</li> | ||||
|   <li>Added <code>glfwSetCursorMode</code> function for controlling per-window cursor mode, replacing <code>GLFW_MOUSE_CURSOR</code></li> | ||||
|   <li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li> | ||||
|   <li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li> | ||||
|   <li>Added <code>GLFW_OPENGL_REVISION</code> window parameter to make up for removal of <code>glfwGetGLVersion</code></li> | ||||
| @ -286,6 +285,7 @@ version of GLFW.</p> | ||||
|   <li>Added initial window title parameter to <code>glfwOpenWindow</code></li> | ||||
|   <li>Added <code>glfwSetGamma</code>, <code>glfwSetGammaRamp</code> and <code>glfwGetGammaRamp</code> functions and <code>GLFWgammaramp</code> type for monitor gamma ramp control</li> | ||||
|   <li>Changed buffer bit depth parameters of <code>glfwOpenWindow</code> to window hints</li> | ||||
|   <li>Changed <code>glfwOpenWindow</code> and <code>glfwSetWindowTitle</code> to use UTF-8 encoded strings</li> | ||||
|   <li>Renamed <code>glfw.h</code> to <code>glfw3.h</code> to avoid conflicts with 2.x series</li> | ||||
|   <li>Renamed <code>GLFW_WINDOW</code> token to <code>GLFW_WINDOWED</code></li> | ||||
|   <li>Renamed <code>GLFW_WINDOW_NO_RESIZE</code> to <code>GLFW_WINDOW_RESIZABLE</code></li> | ||||
| @ -293,6 +293,7 @@ version of GLFW.</p> | ||||
|   <li>Replaced ad hoc build system with CMake</li> | ||||
|   <li>Replaced layout-dependent key codes with single, platform-independent set based on US layout</li> | ||||
|   <li>Replaced mouse wheel interface with two-dimensional scrolling interface</li> | ||||
|   <li>Replaced <code>glfwEnable</code> and <code>glfwDisable</code> with <code>glfwGetInputMode</code> and <code>glfwSetInputMode</code></li> | ||||
|   <li>Made Unicode character input unaffected by <code>GLFW_KEY_REPEAT</code></li> | ||||
|   <li>Removed event auto-polling and the <code>GLFW_AUTO_POLL_EVENTS</code> window enable</li> | ||||
|   <li>Removed the Win32 port .def files</li> | ||||
| @ -315,8 +316,11 @@ version of GLFW.</p> | ||||
|   <li>[X11] Added support for the <code>GLX_EXT_swap_control</code> extension as an alternative to <code>GLX_SGI_swap_control</code></li> | ||||
|   <li>[X11] Added the POSIX <code>CLOCK_MONOTONIC</code> time source as the preferred method</li> | ||||
|   <li>[X11] Added dependency on libm, where present</li> | ||||
|   <li>[X11] Added support for the <code>_NET_WM_NAME</code> and <code>_NET_WM_ICON_NAME</code> EWMH window properties</li> | ||||
|   <li>[X11] Bugfix: Some window properties required by the ICCCM were not set</li> | ||||
|   <li>[X11] Bugfix: Calling <code>glXCreateContextAttribsARB</code> with an unavailable OpenGL version caused the application to terminate with a <code>BadMatch</code> Xlib error</li> | ||||
|   <li>[X11] Bugfix: A synchronization point necessary for jitter-free locked cursor mode was incorrectly removed</li> | ||||
|   <li>[Win32] Changed port to use Unicode mode only</li> | ||||
|   <li>[Win32] Removed explicit support for versions of Windows older than Windows XP</li> | ||||
|   <li>[Win32] Bugfix: Window activation and iconification did not work as expected</li> | ||||
|   <li>[Win32] Bugfix: Software rasterizer pixel formats were not discarded by the WGL_ARB_pixel_format code path</li> | ||||
| @ -862,6 +866,8 @@ their skills.  Special thanks go out to:</p> | ||||
| 
 | ||||
|   <li>Tristam MacDonald, for his bug reports and feedback on the Cocoa port</li> | ||||
| 
 | ||||
|   <li>Hans 'Hanmac' Mackowiak, for adding UTF-8 window title support on X11</li> | ||||
| 
 | ||||
|   <li>David Medlock, for doing the initial Lua port</li> | ||||
| 
 | ||||
|   <li>Marcel Metz, for the initial implementation of multi-monitor support on | ||||
|  | ||||
| @ -19,26 +19,26 @@ include_directories(${GLFW_SOURCE_DIR}/src | ||||
|                     ${GLFW_BINARY_DIR}/src | ||||
|                     ${GLFW_INCLUDE_DIR}) | ||||
| 
 | ||||
| set(common_SOURCES monitor.c enable.c error.c fullscreen.c gamma.c init.c input.c | ||||
|                    joystick.c opengl.c time.c window.c) | ||||
| set(common_SOURCES error.c fullscreen.c gamma.c init.c input.c | ||||
|                    joystick.c monitor.c opengl.c time.c window.c) | ||||
| 
 | ||||
| if(_GLFW_COCOA_NSGL) | ||||
|     set(libglfw_SOURCES ${common_SOURCES} cocoa_enable.m cocoa_fullscreen.m | ||||
|                         cocoa_gamma.m cocoa_init.m cocoa_joystick.m | ||||
|     set(libglfw_SOURCES ${common_SOURCES} cocoa_fullscreen.m cocoa_gamma.m | ||||
|                         cocoa_init.m cocoa_input.m cocoa_joystick.m | ||||
|                         cocoa_opengl.m cocoa_time.m cocoa_window.m) | ||||
| 
 | ||||
|     # For some reason, CMake doesn't know about .m | ||||
|     set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C) | ||||
| elseif(_GLFW_WIN32_WGL) | ||||
|     set(libglfw_SOURCES ${common_SOURCES} win32_enable.c win32_fullscreen.c | ||||
|                         win32_gamma.c win32_init.c win32_joystick.c | ||||
|     set(libglfw_SOURCES ${common_SOURCES} win32_fullscreen.c win32_gamma.c | ||||
|                         win32_init.c win32_input.c win32_joystick.c | ||||
|                         win32_opengl.c win32_time.c win32_window.c | ||||
|                         win32_dllmain.c win32_monitor.c) | ||||
| elseif(_GLFW_X11_GLX) | ||||
|     set(libglfw_SOURCES ${common_SOURCES} x11_monitor.c x11_enable.c | ||||
|                         x11_fullscreen.c x11_gamma.c x11_init.c x11_joystick.c | ||||
|                         x11_keysym2unicode.c x11_opengl.c x11_time.c | ||||
|                         x11_window.c) | ||||
|     set(libglfw_SOURCES ${common_SOURCES} x11_fullscreen.c x11_gamma.c | ||||
|                         x11_init.c x11_input.c x11_joystick.c | ||||
|                         x11_keysym2unicode.c x11_monitor.c x11_opengl.c | ||||
|                         x11_time.c x11_window.c) | ||||
| else() | ||||
|     message(FATAL_ERROR "No supported platform was selected") | ||||
| endif(_GLFW_COCOA_NSGL) | ||||
|  | ||||
| @ -232,11 +232,13 @@ static long getElementValue(_glfwJoystick* joystick, _glfwJoystickElement* eleme | ||||
| 
 | ||||
| static void removeJoystick(_glfwJoystick* joystick) | ||||
| { | ||||
|     int i; | ||||
| 
 | ||||
|     if (joystick->present) | ||||
|     { | ||||
|         joystick->present = GL_FALSE; | ||||
| 
 | ||||
|         for (int i = 0;  i < joystick->numAxes;  i++) | ||||
|         for (i = 0;  i < joystick->numAxes;  i++) | ||||
|         { | ||||
|             _glfwJoystickElement* axes = | ||||
|                 (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->axes, i); | ||||
| @ -245,7 +247,7 @@ static void removeJoystick(_glfwJoystick* joystick) | ||||
|         CFArrayRemoveAllValues(joystick->axes); | ||||
|         joystick->numAxes = 0; | ||||
| 
 | ||||
|         for (int i = 0;  i < joystick->numButtons;  i++) | ||||
|         for (i = 0;  i < joystick->numButtons;  i++) | ||||
|         { | ||||
|             _glfwJoystickElement* button = | ||||
|                 (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->buttons, i); | ||||
| @ -254,7 +256,7 @@ static void removeJoystick(_glfwJoystick* joystick) | ||||
|         CFArrayRemoveAllValues(joystick->buttons); | ||||
|         joystick->numButtons = 0; | ||||
| 
 | ||||
|         for (int i = 0;  i < joystick->numHats;  i++) | ||||
|         for (i = 0;  i < joystick->numHats;  i++) | ||||
|         { | ||||
|             _glfwJoystickElement* hat = | ||||
|                 (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->hats, i); | ||||
| @ -287,23 +289,26 @@ static void removalCallback(void* target, IOReturn result, void* refcon, void* s | ||||
| 
 | ||||
| static void pollJoystickEvents(void) | ||||
| { | ||||
|     for (int i = 0;  i < GLFW_JOYSTICK_LAST + 1;  i++) | ||||
|     int i; | ||||
|     CFIndex j; | ||||
| 
 | ||||
|     for (i = 0;  i < GLFW_JOYSTICK_LAST + 1;  i++) | ||||
|     { | ||||
|         _glfwJoystick* joystick = &_glfwJoysticks[i]; | ||||
| 
 | ||||
|         if (joystick->present) | ||||
|         { | ||||
|             for (CFIndex i = 0;  i < joystick->numButtons;  i++) | ||||
|             for (j = 0;  j < joystick->numButtons;  j++) | ||||
|             { | ||||
|                 _glfwJoystickElement* button = | ||||
|                     (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->buttons, i); | ||||
|                     (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->buttons, j); | ||||
|                 button->value = getElementValue(joystick, button); | ||||
|             } | ||||
| 
 | ||||
|             for (CFIndex i = 0;  i < joystick->numAxes;  i++) | ||||
|             for (j = 0;  j < joystick->numAxes;  j++) | ||||
|             { | ||||
|                 _glfwJoystickElement* axes = | ||||
|                     (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->axes, i); | ||||
|                     (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->axes, j); | ||||
|                 axes->value = getElementValue(joystick, axes); | ||||
|             } | ||||
|         } | ||||
| @ -449,7 +454,9 @@ void _glfwInitJoysticks(void) | ||||
| 
 | ||||
| void _glfwTerminateJoysticks(void) | ||||
| { | ||||
|     for (int i = 0;  i < GLFW_JOYSTICK_LAST + 1;  i++) | ||||
|     int i; | ||||
| 
 | ||||
|     for (i = 0;  i < GLFW_JOYSTICK_LAST + 1;  i++) | ||||
|     { | ||||
|         _glfwJoystick* joystick = &_glfwJoysticks[i]; | ||||
|         removeJoystick(joystick); | ||||
| @ -498,6 +505,8 @@ int _glfwPlatformGetJoystickParam(int joy, int param) | ||||
| 
 | ||||
| int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes) | ||||
| { | ||||
|     int i; | ||||
| 
 | ||||
|     if (joy < GLFW_JOYSTICK_1 || joy > GLFW_JOYSTICK_LAST) | ||||
|         return 0; | ||||
| 
 | ||||
| @ -514,7 +523,7 @@ int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes) | ||||
|     // Update joystick state | ||||
|     pollJoystickEvents(); | ||||
| 
 | ||||
|     for (int i = 0;  i < numaxes;  i++) | ||||
|     for (i = 0;  i < numaxes;  i++) | ||||
|     { | ||||
|         _glfwJoystickElement* axes = | ||||
|             (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick.axes, i); | ||||
| @ -543,6 +552,8 @@ int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes) | ||||
| int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons, | ||||
|                                     int numbuttons) | ||||
| { | ||||
|     int i; | ||||
| 
 | ||||
|     if (joy < GLFW_JOYSTICK_1 || joy > GLFW_JOYSTICK_LAST) | ||||
|         return 0; | ||||
| 
 | ||||
| @ -559,7 +570,7 @@ int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons, | ||||
|     // Update joystick state | ||||
|     pollJoystickEvents(); | ||||
| 
 | ||||
|     for (int i = 0;  i < numbuttons;  i++) | ||||
|     for (i = 0;  i < numbuttons;  i++) | ||||
|     { | ||||
|         _glfwJoystickElement* button = (_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick.buttons, i); | ||||
|         buttons[i] = button->value ? GLFW_PRESS : GLFW_RELEASE; | ||||
|  | ||||
| @ -147,7 +147,7 @@ static const unsigned int MAC_TO_GLFW_KEYCODE_MAPPING[128] = | ||||
|     /* 07 */ GLFW_KEY_X, | ||||
|     /* 08 */ GLFW_KEY_C, | ||||
|     /* 09 */ GLFW_KEY_V, | ||||
|     /* 0a */ -1, | ||||
|     /* 0a */ GLFW_KEY_GRAVE_ACCENT, | ||||
|     /* 0b */ GLFW_KEY_B, | ||||
|     /* 0c */ GLFW_KEY_Q, | ||||
|     /* 0d */ GLFW_KEY_W, | ||||
| @ -187,7 +187,7 @@ static const unsigned int MAC_TO_GLFW_KEYCODE_MAPPING[128] = | ||||
|     /* 2f */ GLFW_KEY_PERIOD, | ||||
|     /* 30 */ GLFW_KEY_TAB, | ||||
|     /* 31 */ GLFW_KEY_SPACE, | ||||
|     /* 32 */ GLFW_KEY_GRAVE_ACCENT, | ||||
|     /* 32 */ GLFW_KEY_WORLD_1, | ||||
|     /* 33 */ GLFW_KEY_BACKSPACE, | ||||
|     /* 34 */ -1, | ||||
|     /* 35 */ GLFW_KEY_ESCAPE, | ||||
| @ -393,7 +393,7 @@ static int convertMacKeyCode(unsigned int macKeyCode) | ||||
| 
 | ||||
|         if ([event modifierFlags] & NSCommandKeyMask) | ||||
|         { | ||||
|             if (!window->sysKeysDisabled) | ||||
|             if (window->systemKeys) | ||||
|                 [super keyDown:event]; | ||||
|         } | ||||
|         else | ||||
| @ -443,20 +443,66 @@ static int convertMacKeyCode(unsigned int macKeyCode) | ||||
| 
 | ||||
| @end | ||||
| 
 | ||||
| 
 | ||||
| ////////////////////////////////////////////////////////////////////////// | ||||
| //////                       GLFW platform API                      ////// | ||||
| ////////////////////////////////////////////////////////////////////////// | ||||
| 
 | ||||
| //======================================================================== | ||||
| // Here is where the window is created, and the OpenGL rendering context is | ||||
| // created | ||||
| // Create the Cocoa window | ||||
| //======================================================================== | ||||
| 
 | ||||
| int _glfwPlatformOpenWindow(_GLFWwindow* window, | ||||
| static GLboolean createWindow(_GLFWwindow* window, | ||||
|                               const _GLFWwndconfig* wndconfig) | ||||
| { | ||||
|     unsigned int styleMask = 0; | ||||
| 
 | ||||
|     if (wndconfig->mode == GLFW_WINDOWED) | ||||
|     { | ||||
|         styleMask = NSTitledWindowMask | NSClosableWindowMask | | ||||
|                     NSMiniaturizableWindowMask; | ||||
| 
 | ||||
|         if (wndconfig->resizable) | ||||
|             styleMask |= NSResizableWindowMask; | ||||
|     } | ||||
|     else | ||||
|         styleMask = NSBorderlessWindowMask; | ||||
| 
 | ||||
|     window->NS.window = [[NSWindow alloc] | ||||
|         initWithContentRect:NSMakeRect(0, 0, window->width, window->height) | ||||
|                   styleMask:styleMask | ||||
|                     backing:NSBackingStoreBuffered | ||||
|                       defer:NO]; | ||||
| 
 | ||||
|     if (window->NS.window == nil) | ||||
|     { | ||||
|         _glfwSetError(GLFW_PLATFORM_ERROR, | ||||
|                       "Cocoa/NSOpenGL: Failed to create window"); | ||||
|         return GL_FALSE; | ||||
|     } | ||||
| 
 | ||||
|     [window->NS.window setTitle:[NSString stringWithUTF8String:wndconfig->title]]; | ||||
|     [window->NS.window setContentView:[[GLFWContentView alloc] | ||||
|                    initWithGlfwWindow:window]]; | ||||
|     [window->NS.window setDelegate:window->NS.delegate]; | ||||
|     [window->NS.window setAcceptsMouseMovedEvents:YES]; | ||||
|     [window->NS.window center]; | ||||
| 
 | ||||
|     return GL_TRUE; | ||||
| } | ||||
| 
 | ||||
| //======================================================================== | ||||
| // Create the OpenGL context | ||||
| //======================================================================== | ||||
| 
 | ||||
| static GLboolean createContext(_GLFWwindow* window, | ||||
|                                const _GLFWwndconfig* wndconfig, | ||||
|                                const _GLFWfbconfig* fbconfig) | ||||
| { | ||||
|     unsigned int attributeCount = 0; | ||||
| 
 | ||||
|     // Mac OS X needs non-zero color size, so set resonable values | ||||
|     int colorBits = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits; | ||||
|     if (colorBits == 0) | ||||
|         colorBits = 24; | ||||
|     else if (colorBits < 15) | ||||
|         colorBits = 15; | ||||
| 
 | ||||
| #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 | ||||
|     // Fail if any OpenGL version above 2.1 other than 3.2 was requested | ||||
|     if (wndconfig->glMajor > 3 || | ||||
| @ -499,104 +545,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, | ||||
|         return GL_FALSE; | ||||
|     } | ||||
| 
 | ||||
|     // We can only have one application delegate, but we only allocate it the | ||||
|     // first time we create a window to keep all window code in this file | ||||
|     if (_glfwLibrary.NS.delegate == nil) | ||||
|     { | ||||
|         _glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init]; | ||||
|         if (_glfwLibrary.NS.delegate == nil) | ||||
|         { | ||||
|             _glfwSetError(GLFW_PLATFORM_ERROR, | ||||
|                           "Cocoa/NSOpenGL: Failed to create application " | ||||
|                           "delegate"); | ||||
|             return GL_FALSE; | ||||
|         } | ||||
| 
 | ||||
|         [NSApp setDelegate:_glfwLibrary.NS.delegate]; | ||||
|     } | ||||
| 
 | ||||
|     window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window]; | ||||
|     if (window->NS.delegate == nil) | ||||
|     { | ||||
|         _glfwSetError(GLFW_PLATFORM_ERROR, | ||||
|                       "Cocoa/NSOpenGL: Failed to create window delegate"); | ||||
|         return GL_FALSE; | ||||
|     } | ||||
| 
 | ||||
|     // Mac OS X needs non-zero color size, so set resonable values | ||||
|     int colorBits = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits; | ||||
|     if (colorBits == 0) | ||||
|         colorBits = 24; | ||||
|     else if (colorBits < 15) | ||||
|         colorBits = 15; | ||||
| 
 | ||||
|     // Ignored hints: | ||||
|     // OpenGLMajor, OpenGLMinor, OpenGLForward: | ||||
|     //     pending Mac OS X support for OpenGL 3.x | ||||
|     // OpenGLDebug | ||||
|     //     pending it meaning anything on Mac OS X | ||||
| 
 | ||||
|     // Don't use accumulation buffer support; it's not accelerated | ||||
|     // Aux buffers probably aren't accelerated either | ||||
| 
 | ||||
|     CFDictionaryRef fullscreenMode = NULL; | ||||
|     if (wndconfig->mode == GLFW_FULLSCREEN) | ||||
|     { | ||||
|         // I think it's safe to pass 0 to the refresh rate for this function | ||||
|         // rather than conditionalizing the code to call the version which | ||||
|         // doesn't specify refresh... | ||||
|         fullscreenMode = | ||||
|             CGDisplayBestModeForParametersAndRefreshRateWithProperty( | ||||
|                 CGMainDisplayID(), | ||||
|                 colorBits + fbconfig->alphaBits, | ||||
|                 window->width, window->height, | ||||
|                 wndconfig->refreshRate, | ||||
|                 // Controversial, see macosx_fullscreen.m for discussion | ||||
|                 kCGDisplayModeIsSafeForHardware, | ||||
|                 NULL); | ||||
| 
 | ||||
|         window->width = | ||||
|             [[(id)fullscreenMode objectForKey:(id)kCGDisplayWidth] intValue]; | ||||
|         window->height = | ||||
|             [[(id)fullscreenMode objectForKey:(id)kCGDisplayHeight] intValue]; | ||||
|     } | ||||
| 
 | ||||
|     unsigned int styleMask = 0; | ||||
| 
 | ||||
|     if (wndconfig->mode == GLFW_WINDOWED) | ||||
|     { | ||||
|         styleMask = NSTitledWindowMask | NSClosableWindowMask | | ||||
|                     NSMiniaturizableWindowMask; | ||||
| 
 | ||||
|         if (wndconfig->resizable) | ||||
|             styleMask |= NSResizableWindowMask; | ||||
|     } | ||||
|     else | ||||
|         styleMask = NSBorderlessWindowMask; | ||||
| 
 | ||||
|     window->NS.window = [[NSWindow alloc] | ||||
|         initWithContentRect:NSMakeRect(0, 0, window->width, window->height) | ||||
|                   styleMask:styleMask | ||||
|                     backing:NSBackingStoreBuffered | ||||
|                       defer:NO]; | ||||
| 
 | ||||
|     [window->NS.window setTitle:[NSString stringWithCString:wndconfig->title | ||||
|                                                    encoding:NSISOLatin1StringEncoding]]; | ||||
| 
 | ||||
|     [window->NS.window setContentView:[[GLFWContentView alloc] initWithGlfwWindow:window]]; | ||||
|     [window->NS.window setDelegate:window->NS.delegate]; | ||||
|     [window->NS.window setAcceptsMouseMovedEvents:YES]; | ||||
|     [window->NS.window center]; | ||||
| 
 | ||||
|     if (wndconfig->mode == GLFW_FULLSCREEN) | ||||
|     { | ||||
|         CGCaptureAllDisplays(); | ||||
|         CGDisplaySwitchToMode(CGMainDisplayID(), fullscreenMode); | ||||
|     } | ||||
| 
 | ||||
|     unsigned int attribute_count = 0; | ||||
| 
 | ||||
| #define ADD_ATTR(x) { attributes[attribute_count++] = x; } | ||||
| #define ADD_ATTR(x) { attributes[attributeCount++] = x; } | ||||
| #define ADD_ATTR2(x, y) { ADD_ATTR(x); ADD_ATTR(y); } | ||||
| 
 | ||||
|     // Arbitrary array size here | ||||
| @ -675,9 +624,100 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, | ||||
|         return GL_FALSE; | ||||
|     } | ||||
| 
 | ||||
|     return GL_TRUE; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| ////////////////////////////////////////////////////////////////////////// | ||||
| //////                       GLFW platform API                      ////// | ||||
| ////////////////////////////////////////////////////////////////////////// | ||||
| 
 | ||||
| //======================================================================== | ||||
| // Here is where the window is created, and the OpenGL rendering context is | ||||
| // created | ||||
| //======================================================================== | ||||
| 
 | ||||
| int _glfwPlatformOpenWindow(_GLFWwindow* window, | ||||
|                             const _GLFWwndconfig *wndconfig, | ||||
|                             const _GLFWfbconfig *fbconfig) | ||||
| { | ||||
|     // We can only have one application delegate, but we only allocate it the | ||||
|     // first time we create a window to keep all window code in this file | ||||
|     if (_glfwLibrary.NS.delegate == nil) | ||||
|     { | ||||
|         _glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init]; | ||||
|         if (_glfwLibrary.NS.delegate == nil) | ||||
|         { | ||||
|             _glfwSetError(GLFW_PLATFORM_ERROR, | ||||
|                           "Cocoa/NSOpenGL: Failed to create application " | ||||
|                           "delegate"); | ||||
|             return GL_FALSE; | ||||
|         } | ||||
| 
 | ||||
|         [NSApp setDelegate:_glfwLibrary.NS.delegate]; | ||||
|     } | ||||
| 
 | ||||
|     window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window]; | ||||
|     if (window->NS.delegate == nil) | ||||
|     { | ||||
|         _glfwSetError(GLFW_PLATFORM_ERROR, | ||||
|                       "Cocoa/NSOpenGL: Failed to create window delegate"); | ||||
|         return GL_FALSE; | ||||
|     } | ||||
| 
 | ||||
|     // Mac OS X needs non-zero color size, so set resonable values | ||||
|     int colorBits = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits; | ||||
|     if (colorBits == 0) | ||||
|         colorBits = 24; | ||||
|     else if (colorBits < 15) | ||||
|         colorBits = 15; | ||||
| 
 | ||||
|     // Ignored hints: | ||||
|     // OpenGLMajor, OpenGLMinor, OpenGLForward: | ||||
|     //     pending Mac OS X support for OpenGL 3.x | ||||
|     // OpenGLDebug | ||||
|     //     pending it meaning anything on Mac OS X | ||||
| 
 | ||||
|     // Don't use accumulation buffer support; it's not accelerated | ||||
|     // Aux buffers probably aren't accelerated either | ||||
| 
 | ||||
|     CFDictionaryRef fullscreenMode = NULL; | ||||
|     if (wndconfig->mode == GLFW_FULLSCREEN) | ||||
|     { | ||||
|         // I think it's safe to pass 0 to the refresh rate for this function | ||||
|         // rather than conditionalizing the code to call the version which | ||||
|         // doesn't specify refresh... | ||||
|         fullscreenMode = | ||||
|             CGDisplayBestModeForParametersAndRefreshRateWithProperty( | ||||
|                 CGMainDisplayID(), | ||||
|                 colorBits + fbconfig->alphaBits, | ||||
|                 window->width, window->height, | ||||
|                 wndconfig->refreshRate, | ||||
|                 // Controversial, see macosx_fullscreen.m for discussion | ||||
|                 kCGDisplayModeIsSafeForHardware, | ||||
|                 NULL); | ||||
| 
 | ||||
|         window->width = | ||||
|             [[(id)fullscreenMode objectForKey:(id)kCGDisplayWidth] intValue]; | ||||
|         window->height = | ||||
|             [[(id)fullscreenMode objectForKey:(id)kCGDisplayHeight] intValue]; | ||||
|     } | ||||
| 
 | ||||
|     if (!createWindow(window, wndconfig)) | ||||
|         return GL_FALSE; | ||||
| 
 | ||||
|     if (!createContext(window, wndconfig, fbconfig)) | ||||
|         return GL_FALSE; | ||||
| 
 | ||||
|     [window->NS.window makeKeyAndOrderFront:nil]; | ||||
|     [window->NSGL.context setView:[window->NS.window contentView]]; | ||||
| 
 | ||||
|     if (wndconfig->mode == GLFW_FULLSCREEN) | ||||
|     { | ||||
|         CGCaptureAllDisplays(); | ||||
|         CGDisplaySwitchToMode(CGMainDisplayID(), fullscreenMode); | ||||
|     } | ||||
| 
 | ||||
|     if (wndconfig->mode == GLFW_FULLSCREEN) | ||||
|     { | ||||
|         // TODO: Make this work on pre-Leopard systems | ||||
| @ -737,8 +777,7 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window) | ||||
| 
 | ||||
| void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title) | ||||
| { | ||||
|     [window->NS.window setTitle:[NSString stringWithCString:title | ||||
|                        encoding:NSISOLatin1StringEncoding]]; | ||||
|     [window->NS.window setTitle:[NSString stringWithUTF8String:title]]; | ||||
| } | ||||
| 
 | ||||
| //======================================================================== | ||||
|  | ||||
							
								
								
									
										192
									
								
								src/enable.c
									
									
									
									
									
								
							
							
						
						
									
										192
									
								
								src/enable.c
									
									
									
									
									
								
							| @ -1,192 +0,0 @@ | ||||
| //========================================================================
 | ||||
| // GLFW - An OpenGL library
 | ||||
| // Platform:    Any
 | ||||
| // API version: 3.0
 | ||||
| // WWW:         http://www.glfw.org/
 | ||||
| //------------------------------------------------------------------------
 | ||||
| // Copyright (c) 2002-2006 Marcus Geelnard
 | ||||
| // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
 | ||||
| //
 | ||||
| // This software is provided 'as-is', without any express or implied
 | ||||
| // warranty. In no event will the authors be held liable for any damages
 | ||||
| // arising from the use of this software.
 | ||||
| //
 | ||||
| // Permission is granted to anyone to use this software for any purpose,
 | ||||
| // including commercial applications, and to alter it and redistribute it
 | ||||
| // freely, subject to the following restrictions:
 | ||||
| //
 | ||||
| // 1. The origin of this software must not be misrepresented; you must not
 | ||||
| //    claim that you wrote the original software. If you use this software
 | ||||
| //    in a product, an acknowledgment in the product documentation would
 | ||||
| //    be appreciated but is not required.
 | ||||
| //
 | ||||
| // 2. Altered source versions must be plainly marked as such, and must not
 | ||||
| //    be misrepresented as being the original software.
 | ||||
| //
 | ||||
| // 3. This notice may not be removed or altered from any source
 | ||||
| //    distribution.
 | ||||
| //
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| #include "internal.h" | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Enable and disable sticky keys mode
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void enableStickyKeys(_GLFWwindow* window) | ||||
| { | ||||
|     window->stickyKeys = GL_TRUE; | ||||
| } | ||||
| 
 | ||||
| static void disableStickyKeys(_GLFWwindow* window) | ||||
| { | ||||
|     int i; | ||||
| 
 | ||||
|     window->stickyKeys = GL_FALSE; | ||||
| 
 | ||||
|     // Release all sticky keys
 | ||||
|     for (i = 0;  i <= GLFW_KEY_LAST;  i++) | ||||
|     { | ||||
|         if (window->key[i] == GLFW_STICK) | ||||
|             window->key[i] = GLFW_RELEASE; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Enable and disable sticky mouse buttons mode
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void enableStickyMouseButtons(_GLFWwindow* window) | ||||
| { | ||||
|     window->stickyMouseButtons = GL_TRUE; | ||||
| } | ||||
| 
 | ||||
| static void disableStickyMouseButtons(_GLFWwindow* window) | ||||
| { | ||||
|     int i; | ||||
| 
 | ||||
|     window->stickyMouseButtons = GL_FALSE; | ||||
| 
 | ||||
|     // Release all sticky mouse buttons
 | ||||
|     for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++) | ||||
|     { | ||||
|         if (window->mouseButton[i] == GLFW_STICK) | ||||
|             window->mouseButton[i] = GLFW_RELEASE; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Enable and disable system keys
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void enableSystemKeys(_GLFWwindow* window) | ||||
| { | ||||
|     if (!window->sysKeysDisabled) | ||||
|         return; | ||||
| 
 | ||||
|     _glfwPlatformEnableSystemKeys(window); | ||||
| 
 | ||||
|     // Indicate that system keys are no longer disabled
 | ||||
|     window->sysKeysDisabled = GL_FALSE; | ||||
| } | ||||
| 
 | ||||
| static void disableSystemKeys(_GLFWwindow* window) | ||||
| { | ||||
|     if (window->sysKeysDisabled) | ||||
|         return; | ||||
| 
 | ||||
|     _glfwPlatformDisableSystemKeys(window); | ||||
| 
 | ||||
|     // Indicate that system keys are now disabled
 | ||||
|     window->sysKeysDisabled = GL_TRUE; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Enable and disable key repeat
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void enableKeyRepeat(_GLFWwindow* window) | ||||
| { | ||||
|     window->keyRepeat = GL_TRUE; | ||||
| } | ||||
| 
 | ||||
| static void disableKeyRepeat(_GLFWwindow* window) | ||||
| { | ||||
|     window->keyRepeat = GL_FALSE; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //////////////////////////////////////////////////////////////////////////
 | ||||
| //////                        GLFW public API                       //////
 | ||||
| //////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Enable certain GLFW/window/system functions
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| GLFWAPI void glfwEnable(GLFWwindow window, int token) | ||||
| { | ||||
|     if (!_glfwInitialized) | ||||
|     { | ||||
|         _glfwSetError(GLFW_NOT_INITIALIZED, NULL); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     switch (token) | ||||
|     { | ||||
|         case GLFW_STICKY_KEYS: | ||||
|             enableStickyKeys(window); | ||||
|             break; | ||||
|         case GLFW_STICKY_MOUSE_BUTTONS: | ||||
|             enableStickyMouseButtons(window); | ||||
|             break; | ||||
|         case GLFW_SYSTEM_KEYS: | ||||
|             enableSystemKeys(window); | ||||
|             break; | ||||
|         case GLFW_KEY_REPEAT: | ||||
|             enableKeyRepeat(window); | ||||
|             break; | ||||
|         default: | ||||
|             _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Disable certain GLFW/window/system functions
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| GLFWAPI void glfwDisable(GLFWwindow window, int token) | ||||
| { | ||||
|     if (!_glfwInitialized) | ||||
|     { | ||||
|         _glfwSetError(GLFW_NOT_INITIALIZED, NULL); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     switch (token) | ||||
|     { | ||||
|         case GLFW_STICKY_KEYS: | ||||
|             disableStickyKeys(window); | ||||
|             break; | ||||
|         case GLFW_STICKY_MOUSE_BUTTONS: | ||||
|             disableStickyMouseButtons(window); | ||||
|             break; | ||||
|         case GLFW_SYSTEM_KEYS: | ||||
|             disableSystemKeys(window); | ||||
|             break; | ||||
|         case GLFW_KEY_REPEAT: | ||||
|             disableKeyRepeat(window); | ||||
|             break; | ||||
|         default: | ||||
|             _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
							
								
								
									
										15
									
								
								src/init.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/init.c
									
									
									
									
									
								
							| @ -67,26 +67,13 @@ void _glfwFree(void* ptr) | ||||
| // Initialize various GLFW state
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| GLFWAPI int glfwInit(void) | ||||
| { | ||||
|     return glfwInitWithModels(NULL, NULL); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Initialize various GLFW state using custom model interfaces
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| GLFWAPI int glfwInitWithModels(GLFWthreadmodel* threading, GLFWallocator* allocator) | ||||
| GLFWAPI int glfwInit(GLFWallocator* allocator) | ||||
| { | ||||
|     if (_glfwInitialized) | ||||
|         return GL_TRUE; | ||||
| 
 | ||||
|     memset(&_glfwLibrary, 0, sizeof(_glfwLibrary)); | ||||
| 
 | ||||
|     if (threading) | ||||
|         _glfwLibrary.threading = *threading; | ||||
| 
 | ||||
|     if (allocator) | ||||
|     { | ||||
|         // Verify that the specified model is complete
 | ||||
|  | ||||
							
								
								
									
										238
									
								
								src/input.c
									
									
									
									
									
								
							
							
						
						
									
										238
									
								
								src/input.c
									
									
									
									
									
								
							| @ -31,6 +31,122 @@ | ||||
| #include "internal.h" | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Sets the cursor mode for the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void setCursorMode(_GLFWwindow* window, int mode) | ||||
| { | ||||
|     int centerPosX, centerPosY; | ||||
| 
 | ||||
|     if (mode != GLFW_CURSOR_NORMAL && | ||||
|         mode != GLFW_CURSOR_HIDDEN && | ||||
|         mode != GLFW_CURSOR_CAPTURED) | ||||
|     { | ||||
|         _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (window->cursorMode == mode) | ||||
|         return; | ||||
| 
 | ||||
|     centerPosX = window->width / 2; | ||||
|     centerPosY = window->height / 2; | ||||
| 
 | ||||
|     if (mode == GLFW_CURSOR_CAPTURED) | ||||
|         _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY); | ||||
|     else if (window->cursorMode == GLFW_CURSOR_CAPTURED) | ||||
|     { | ||||
|         _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY); | ||||
|         _glfwInputCursorMotion(window, | ||||
|                                centerPosX - window->cursorPosX, | ||||
|                                centerPosY - window->cursorPosY); | ||||
|     } | ||||
| 
 | ||||
|     _glfwPlatformSetCursorMode(window, mode); | ||||
| 
 | ||||
|     window->cursorMode = mode; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Set sticky keys mode for the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void setStickyKeys(_GLFWwindow* window, int enabled) | ||||
| { | ||||
|     if (window->stickyKeys == enabled) | ||||
|         return; | ||||
| 
 | ||||
|     if (!enabled) | ||||
|     { | ||||
|         int i; | ||||
| 
 | ||||
|         // Release all sticky keys
 | ||||
|         for (i = 0;  i <= GLFW_KEY_LAST;  i++) | ||||
|         { | ||||
|             if (window->key[i] == GLFW_STICK) | ||||
|                 window->key[i] = GLFW_RELEASE; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     window->stickyKeys = enabled; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Set sticky mouse buttons mode for the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void setStickyMouseButtons(_GLFWwindow* window, int enabled) | ||||
| { | ||||
|     if (window->stickyMouseButtons == enabled) | ||||
|         return; | ||||
| 
 | ||||
|     if (!enabled) | ||||
|     { | ||||
|         int i; | ||||
| 
 | ||||
|         // Release all sticky mouse buttons
 | ||||
|         for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++) | ||||
|         { | ||||
|             if (window->mouseButton[i] == GLFW_STICK) | ||||
|                 window->mouseButton[i] = GLFW_RELEASE; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     window->stickyMouseButtons = enabled; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Set system keys for the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void setSystemKeys(_GLFWwindow* window, int enabled) | ||||
| { | ||||
|     if (window->systemKeys == enabled) | ||||
|         return; | ||||
| 
 | ||||
|     if (enabled) | ||||
|         _glfwPlatformEnableSystemKeys(window); | ||||
|     else | ||||
|         _glfwPlatformDisableSystemKeys(window); | ||||
| 
 | ||||
|     window->systemKeys = enabled; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Set key repeat for the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static void setKeyRepeat(_GLFWwindow* window, int enabled) | ||||
| { | ||||
|     window->keyRepeat = enabled; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //////////////////////////////////////////////////////////////////////////
 | ||||
| //////                       GLFW internal API                      //////
 | ||||
| //////////////////////////////////////////////////////////////////////////
 | ||||
| @ -41,7 +157,7 @@ | ||||
| 
 | ||||
| void _glfwInputKey(_GLFWwindow* window, int key, int action) | ||||
| { | ||||
|     GLboolean keyrepeat = GL_FALSE; | ||||
|     GLboolean repeated = GL_FALSE; | ||||
| 
 | ||||
|     if (key < 0 || key > GLFW_KEY_LAST) | ||||
|         return; | ||||
| @ -55,12 +171,12 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action) | ||||
|         window->key[key] = GLFW_STICK; | ||||
|     else | ||||
|     { | ||||
|         keyrepeat = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS); | ||||
|         repeated = (window->key[key] == GLFW_PRESS) && (action == GLFW_PRESS); | ||||
|         window->key[key] = (char) action; | ||||
|     } | ||||
| 
 | ||||
|     // Call user callback function
 | ||||
|     if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat)) | ||||
|     if (_glfwLibrary.keyCallback && (window->keyRepeat || !repeated)) | ||||
|         _glfwLibrary.keyCallback(window, key, action); | ||||
| } | ||||
| 
 | ||||
| @ -150,6 +266,77 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y) | ||||
| //////                        GLFW public API                       //////
 | ||||
| //////////////////////////////////////////////////////////////////////////
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Returns the specified input mode of the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| GLFWAPI int glfwGetInputMode(GLFWwindow handle, int mode) | ||||
| { | ||||
|     _GLFWwindow* window = (_GLFWwindow*) handle; | ||||
| 
 | ||||
|     if (!_glfwInitialized) | ||||
|     { | ||||
|         _glfwSetError(GLFW_NOT_INITIALIZED, NULL); | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     switch (mode) | ||||
|     { | ||||
|         case GLFW_CURSOR_MODE: | ||||
|             return window->cursorMode; | ||||
|         case GLFW_STICKY_KEYS: | ||||
|             return window->stickyKeys; | ||||
|         case GLFW_STICKY_MOUSE_BUTTONS: | ||||
|             return window->stickyMouseButtons; | ||||
|         case GLFW_SYSTEM_KEYS: | ||||
|             return window->systemKeys; | ||||
|         case GLFW_KEY_REPEAT: | ||||
|             return window->keyRepeat; | ||||
|         default: | ||||
|             _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||
|             return 0; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Sets the specified input mode of the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| GLFWAPI void glfwSetInputMode(GLFWwindow handle, int mode, int value) | ||||
| { | ||||
|     _GLFWwindow* window = (_GLFWwindow*) handle; | ||||
| 
 | ||||
|     if (!_glfwInitialized) | ||||
|     { | ||||
|         _glfwSetError(GLFW_NOT_INITIALIZED, NULL); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     switch (mode) | ||||
|     { | ||||
|         case GLFW_CURSOR_MODE: | ||||
|             setCursorMode(window, value); | ||||
|             break; | ||||
|         case GLFW_STICKY_KEYS: | ||||
|             setStickyKeys(window, value ? GL_TRUE : GL_FALSE); | ||||
|             break; | ||||
|         case GLFW_STICKY_MOUSE_BUTTONS: | ||||
|             setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE); | ||||
|             break; | ||||
|         case GLFW_SYSTEM_KEYS: | ||||
|             setSystemKeys(window, value ? GL_TRUE : GL_FALSE); | ||||
|             break; | ||||
|         case GLFW_KEY_REPEAT: | ||||
|             setKeyRepeat(window, value ? GL_TRUE : GL_FALSE); | ||||
|             break; | ||||
|         default: | ||||
|             _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||
|             break; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Returns the state of the specified key for the specified window
 | ||||
| //========================================================================
 | ||||
| @ -300,51 +487,6 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Sets the cursor mode for the specified window
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| GLFWAPI void glfwSetCursorMode(GLFWwindow handle, int mode) | ||||
| { | ||||
|     int centerPosX, centerPosY; | ||||
|     _GLFWwindow* window = (_GLFWwindow*) handle; | ||||
| 
 | ||||
|     if (!_glfwInitialized) | ||||
|     { | ||||
|         _glfwSetError(GLFW_NOT_INITIALIZED, NULL); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (mode != GLFW_CURSOR_NORMAL && | ||||
|         mode != GLFW_CURSOR_HIDDEN && | ||||
|         mode != GLFW_CURSOR_CAPTURED) | ||||
|     { | ||||
|         _glfwSetError(GLFW_INVALID_ENUM, NULL); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (window->cursorMode == mode) | ||||
|         return; | ||||
| 
 | ||||
|     centerPosX = window->width / 2; | ||||
|     centerPosY = window->height / 2; | ||||
| 
 | ||||
|     if (mode == GLFW_CURSOR_CAPTURED) | ||||
|         _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY); | ||||
|     else if (window->cursorMode == GLFW_CURSOR_CAPTURED) | ||||
|     { | ||||
|         _glfwPlatformSetMouseCursorPos(window, centerPosX, centerPosY); | ||||
|         _glfwInputCursorMotion(window, | ||||
|                                centerPosX - window->cursorPosX, | ||||
|                                centerPosY - window->cursorPosY); | ||||
|     } | ||||
| 
 | ||||
|     _glfwPlatformSetCursorMode(window, mode); | ||||
| 
 | ||||
|     window->cursorMode = mode; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Set callback function for keyboard input
 | ||||
| //========================================================================
 | ||||
|  | ||||
| @ -184,7 +184,7 @@ struct _GLFWwindow | ||||
|     GLboolean stickyKeys; | ||||
|     GLboolean stickyMouseButtons; | ||||
|     GLboolean keyRepeat; | ||||
|     GLboolean sysKeysDisabled; // system keys disabled flag
 | ||||
|     GLboolean systemKeys;      // system keys enabled flag
 | ||||
|     int       cursorPosX, cursorPosY; | ||||
|     int       cursorMode; | ||||
|     int       scrollX, scrollY; | ||||
| @ -266,7 +266,6 @@ struct _GLFWlibrary | ||||
|     GLFWcharfun          charCallback; | ||||
|     GLFWmonitordevicefun monitorCallback; | ||||
| 
 | ||||
|     GLFWthreadmodel      threading; | ||||
|     GLFWallocator        allocator; | ||||
| 
 | ||||
|     GLFWgammaramp currentRamp; | ||||
| @ -301,7 +300,7 @@ int _glfwPlatformInit(void); | ||||
| int _glfwPlatformTerminate(void); | ||||
| const char* _glfwPlatformGetVersionString(void); | ||||
| 
 | ||||
| // Enable/Disable
 | ||||
| // Input
 | ||||
| void _glfwPlatformEnableSystemKeys(_GLFWwindow* window); | ||||
| void _glfwPlatformDisableSystemKeys(_GLFWwindow* window); | ||||
| 
 | ||||
| @ -365,14 +364,14 @@ void _glfwSetError(int error, const char* description); | ||||
| // Window management (window.c)
 | ||||
| void _glfwSetDefaultWindowHints(void); | ||||
| 
 | ||||
| // WIndow event notification
 | ||||
| // Window event notification (window.c)
 | ||||
| void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated); | ||||
| void _glfwInputWindowPos(_GLFWwindow* window, int x, int y); | ||||
| void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); | ||||
| void _glfwInputWindowIconify(_GLFWwindow* window, int iconified); | ||||
| void _glfwInputWindowDamage(_GLFWwindow* window); | ||||
| 
 | ||||
| // Input event notification
 | ||||
| // Input event notification (input.c)
 | ||||
| void _glfwInputKey(_GLFWwindow* window, int key, int action); | ||||
| void _glfwInputChar(_GLFWwindow* window, int character); | ||||
| void _glfwInputScroll(_GLFWwindow* window, int x, int y); | ||||
|  | ||||
| @ -47,7 +47,7 @@ static GLboolean initLibraries(void) | ||||
| #ifndef _GLFW_NO_DLOAD_GDI32 | ||||
|     // gdi32.dll (OpenGL pixel format functions & SwapBuffers)
 | ||||
| 
 | ||||
|     _glfwLibrary.Win32.gdi.instance = LoadLibrary("gdi32.dll"); | ||||
|     _glfwLibrary.Win32.gdi.instance = LoadLibrary(L"gdi32.dll"); | ||||
|     if (!_glfwLibrary.Win32.gdi.instance) | ||||
|         return GL_FALSE; | ||||
| 
 | ||||
| @ -81,12 +81,12 @@ static GLboolean initLibraries(void) | ||||
| #ifndef _GLFW_NO_DLOAD_WINMM | ||||
|     // winmm.dll (for joystick and timer support)
 | ||||
| 
 | ||||
|     _glfwLibrary.Win32.winmm.instance = LoadLibrary("winmm.dll"); | ||||
|     _glfwLibrary.Win32.winmm.instance = LoadLibrary(L"winmm.dll"); | ||||
|     if (!_glfwLibrary.Win32.winmm.instance) | ||||
|         return GL_FALSE; | ||||
| 
 | ||||
|     _glfwLibrary.Win32.winmm.joyGetDevCapsA = (JOYGETDEVCAPSA_T) | ||||
|         GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetDevCapsA"); | ||||
|     _glfwLibrary.Win32.winmm.joyGetDevCaps = (JOYGETDEVCAPS_T) | ||||
|         GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetDevCapsW"); | ||||
|     _glfwLibrary.Win32.winmm.joyGetPos = (JOYGETPOS_T) | ||||
|         GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetPos"); | ||||
|     _glfwLibrary.Win32.winmm.joyGetPosEx = (JOYGETPOSEX_T) | ||||
| @ -94,7 +94,7 @@ static GLboolean initLibraries(void) | ||||
|     _glfwLibrary.Win32.winmm.timeGetTime = (TIMEGETTIME_T) | ||||
|         GetProcAddress(_glfwLibrary.Win32.winmm.instance, "timeGetTime"); | ||||
| 
 | ||||
|     if (!_glfwLibrary.Win32.winmm.joyGetDevCapsA || | ||||
|     if (!_glfwLibrary.Win32.winmm.joyGetDevCaps || | ||||
|         !_glfwLibrary.Win32.winmm.joyGetPos || | ||||
|         !_glfwLibrary.Win32.winmm.joyGetPosEx || | ||||
|         !_glfwLibrary.Win32.winmm.timeGetTime) | ||||
|  | ||||
| @ -45,6 +45,8 @@ | ||||
| // thinks it is the only one that gets to do so
 | ||||
| #undef APIENTRY | ||||
| 
 | ||||
| #define UNICODE | ||||
| 
 | ||||
| #include <windows.h> | ||||
| #include <mmsystem.h> | ||||
| #include <Dbt.h> | ||||
| @ -163,7 +165,7 @@ typedef BOOL (WINAPI * SETDEVICEGAMMARAMP_T) (HDC,PVOID); | ||||
| 
 | ||||
| // winmm.dll function pointer typedefs
 | ||||
| #ifndef _GLFW_NO_DLOAD_WINMM | ||||
| typedef MMRESULT (WINAPI * JOYGETDEVCAPSA_T) (UINT,LPJOYCAPSA,UINT); | ||||
| typedef MMRESULT (WINAPI * JOYGETDEVCAPS_T) (UINT,LPJOYCAPS,UINT); | ||||
| typedef MMRESULT (WINAPI * JOYGETPOS_T) (UINT,LPJOYINFO); | ||||
| typedef MMRESULT (WINAPI * JOYGETPOSEX_T) (UINT,LPJOYINFOEX); | ||||
| typedef DWORD (WINAPI * TIMEGETTIME_T) (void); | ||||
| @ -191,12 +193,12 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void); | ||||
| 
 | ||||
| // winmm.dll shortcuts
 | ||||
| #ifndef _GLFW_NO_DLOAD_WINMM | ||||
| #define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCapsA | ||||
| #define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCaps | ||||
| #define _glfw_joyGetPos     _glfwLibrary.Win32.winmm.joyGetPos | ||||
| #define _glfw_joyGetPosEx   _glfwLibrary.Win32.winmm.joyGetPosEx | ||||
| #define _glfw_timeGetTime   _glfwLibrary.Win32.winmm.timeGetTime | ||||
| #else | ||||
| #define _glfw_joyGetDevCaps joyGetDevCapsA | ||||
| #define _glfw_joyGetDevCaps joyGetDevCaps | ||||
| #define _glfw_joyGetPos     joyGetPos | ||||
| #define _glfw_joyGetPosEx   joyGetPosEx | ||||
| #define _glfw_timeGetTime   timeGetTime | ||||
| @ -205,7 +207,7 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void); | ||||
| 
 | ||||
| // We use versioned window class names in order not to cause conflicts
 | ||||
| // between applications using different versions of GLFW
 | ||||
| #define _GLFW_WNDCLASSNAME "GLFW30" | ||||
| #define _GLFW_WNDCLASSNAME L"GLFW30" | ||||
| 
 | ||||
| 
 | ||||
| #define _GLFW_PLATFORM_WINDOW_STATE  _GLFWwindowWin32 Win32 | ||||
| @ -311,7 +313,7 @@ typedef struct _GLFWlibraryWin32 | ||||
|     // winmm.dll
 | ||||
|     struct { | ||||
|         HINSTANCE             instance; | ||||
|         JOYGETDEVCAPSA_T      joyGetDevCapsA; | ||||
|         JOYGETDEVCAPS_T       joyGetDevCaps; | ||||
|         JOYGETPOS_T           joyGetPos; | ||||
|         JOYGETPOSEX_T         joyGetPosEx; | ||||
|         TIMEGETTIME_T         timeGetTime; | ||||
|  | ||||
| @ -33,6 +33,31 @@ | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Convert the specified UTF-8 string to a wide string
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| static WCHAR* createWideStringFromUTF8(const char* source) | ||||
| { | ||||
|     WCHAR* target; | ||||
|     int length; | ||||
| 
 | ||||
|     length = MultiByteToWideChar(CP_UTF8, 0, source, -1, NULL, 0); | ||||
|     if (!length) | ||||
|         return NULL; | ||||
| 
 | ||||
|     target = (WCHAR*) _glfwMalloc(sizeof(WCHAR) * (length + 1)); | ||||
| 
 | ||||
|     if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1)) | ||||
|     { | ||||
|         _glfwFree(target); | ||||
|         return NULL; | ||||
|     } | ||||
| 
 | ||||
|     return target; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| //========================================================================
 | ||||
| // Convert BPP to RGB bits based on "best guess"
 | ||||
| //========================================================================
 | ||||
| @ -1229,7 +1254,7 @@ static ATOM registerWindowClass(void) | ||||
|     wc.lpszClassName = _GLFW_WNDCLASSNAME;            // Set class name
 | ||||
| 
 | ||||
|     // Load user-provided icon if available
 | ||||
|     wc.hIcon = LoadIcon(_glfwLibrary.Win32.instance, "GLFW_ICON"); | ||||
|     wc.hIcon = LoadIcon(_glfwLibrary.Win32.instance, L"GLFW_ICON"); | ||||
|     if (!wc.hIcon) | ||||
|     { | ||||
|         // Load default icon
 | ||||
| @ -1289,9 +1314,10 @@ static int createWindow(_GLFWwindow* window, | ||||
|                         const _GLFWfbconfig* fbconfig) | ||||
| { | ||||
|     DWORD dwStyle, dwExStyle; | ||||
|     int pixelFormat, fullWidth, fullHeight; | ||||
|     int length, pixelFormat, fullWidth, fullHeight; | ||||
|     RECT wa; | ||||
|     POINT pos; | ||||
|     WCHAR* wideTitle; | ||||
| 
 | ||||
|     // Set common window styles
 | ||||
|     dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE; | ||||
| @ -1340,9 +1366,17 @@ static int createWindow(_GLFWwindow* window, | ||||
|     else | ||||
|         SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0); | ||||
| 
 | ||||
|     wideTitle = createWideStringFromUTF8(wndconfig->title); | ||||
|     if (!wideTitle) | ||||
|     { | ||||
|         _glfwSetError(GLFW_PLATFORM_ERROR, | ||||
|                       "glfwOpenWindow: Failed to convert title to wide string"); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     window->Win32.handle = CreateWindowEx(window->Win32.dwExStyle, | ||||
|                                           _GLFW_WNDCLASSNAME, | ||||
|                                           wndconfig->title, | ||||
|                                           wideTitle, | ||||
|                                           window->Win32.dwStyle, | ||||
|                                           wa.left, wa.top,       // Window position
 | ||||
|                                           fullWidth,             // Decorated window width
 | ||||
| @ -1358,6 +1392,8 @@ static int createWindow(_GLFWwindow* window, | ||||
|         return GL_FALSE; | ||||
|     } | ||||
| 
 | ||||
|     _glfwFree(wideTitle); | ||||
| 
 | ||||
|     window->WGL.DC = GetDC(window->Win32.handle); | ||||
|     if (!window->WGL.DC) | ||||
|     { | ||||
| @ -1577,7 +1613,17 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window) | ||||
| 
 | ||||
| void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) | ||||
| { | ||||
|     SetWindowText(window->Win32.handle, title); | ||||
|     WCHAR* wideTitle = createWideStringFromUTF8(title); | ||||
|     if (!wideTitle) | ||||
|     { | ||||
|         _glfwSetError(GLFW_PLATFORM_ERROR, | ||||
|                       "glfwSetWindowTitle: Failed to convert title to wide string"); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     SetWindowText(window->Win32.handle, wideTitle); | ||||
| 
 | ||||
|     _glfwFree(wideTitle); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -309,6 +309,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, | ||||
|     window->height     = height; | ||||
|     window->mode       = mode; | ||||
|     window->cursorMode = GLFW_CURSOR_NORMAL; | ||||
|     window->systemKeys = GL_TRUE; | ||||
| 
 | ||||
|     // Open the actual window and create its context
 | ||||
|     if (!_glfwPlatformOpenWindow(window, &wndconfig, &fbconfig)) | ||||
| @ -330,7 +331,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, | ||||
|     // The GLFW specification states that fullscreen windows have the cursor
 | ||||
|     // captured by default
 | ||||
|     if (mode == GLFW_FULLSCREEN) | ||||
|         glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED); | ||||
|         glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED); | ||||
| 
 | ||||
|     // Clearing the front buffer to black to avoid garbage pixels left over
 | ||||
|     // from previous uses of our bit of VRAM
 | ||||
|  | ||||
| @ -31,8 +31,7 @@ | ||||
| #include "internal.h" | ||||
| 
 | ||||
| 
 | ||||
| void (*glXGetProcAddress(const GLubyte* procName))(); | ||||
| void (*glXGetProcAddressARB(const GLubyte* procName))(); | ||||
| // This is the only glXGetProcAddress variant not declared by glxext.h
 | ||||
| void (*glXGetProcAddressEXT(const GLubyte* procName))(); | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -46,13 +46,6 @@ | ||||
| // extensions and not all operating systems come with an up-to-date version
 | ||||
| #include "../support/GL/glxext.h" | ||||
| 
 | ||||
| 
 | ||||
| // We need declarations for GLX version 1.3 or above even if the server doesn't
 | ||||
| // support version 1.3
 | ||||
| #ifndef GLX_VERSION_1_3 | ||||
|  #error "GLX header version 1.3 or above is required" | ||||
| #endif | ||||
| 
 | ||||
| // With XFree86, we can use the XF86VidMode extension
 | ||||
| #if defined(_GLFW_HAS_XF86VIDMODE) | ||||
|  #include <X11/extensions/xf86vmode.h> | ||||
| @ -142,6 +135,8 @@ typedef struct _GLFWwindowX11 | ||||
|     Colormap      colormap;          // Window colormap
 | ||||
|     Window        handle;            // Window handle
 | ||||
|     Atom          wmDeleteWindow;    // WM_DELETE_WINDOW atom
 | ||||
|     Atom          wmName;            // _NET_WM_NAME atom
 | ||||
|     Atom          wmIconName;        // _NET_WM_ICON_NAME atom
 | ||||
|     Atom          wmPing;            // _NET_WM_PING atom
 | ||||
|     Atom          wmState;           // _NET_WM_STATE atom
 | ||||
|     Atom          wmStateFullscreen; // _NET_WM_STATE_FULLSCREEN atom
 | ||||
|  | ||||
| @ -195,6 +195,12 @@ static GLboolean hasEWMH(_GLFWwindow* window) | ||||
|     window->X11.wmStateFullscreen = | ||||
|         getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN"); | ||||
| 
 | ||||
|     window->X11.wmName = | ||||
|         getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_NAME"); | ||||
| 
 | ||||
|     window->X11.wmIconName = | ||||
|         getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_ICON_NAME"); | ||||
| 
 | ||||
|     window->X11.wmPing = | ||||
|         getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING"); | ||||
| 
 | ||||
| @ -1509,9 +1515,39 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window) | ||||
| 
 | ||||
| void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) | ||||
| { | ||||
|     // Set window & icon title
 | ||||
|     XStoreName(_glfwLibrary.X11.display, window->X11.handle, title); | ||||
|     XSetIconName(_glfwLibrary.X11.display, window->X11.handle, title); | ||||
|     Atom type = XInternAtom(_glfwLibrary.X11.display, "UTF8_STRING", False); | ||||
| 
 | ||||
| #if defined(X_HAVE_UTF8_STRING) | ||||
|     Xutf8SetWMProperties(_glfwLibrary.X11.display, | ||||
|                          window->X11.handle, | ||||
|                          title, title, | ||||
|                          NULL, 0, | ||||
|                          NULL, NULL, NULL); | ||||
| #else | ||||
|     // This may be a slightly better fallback than using XStoreName and
 | ||||
|     // XSetIconName, which always store their arguments using STRING
 | ||||
|     XmbSetWMProperties(_glfwLibrary.X11.display, | ||||
|                        window->X11.handle, | ||||
|                        title, title, | ||||
|                        NULL, 0, | ||||
|                        NULL, NULL, NULL); | ||||
| #endif | ||||
| 
 | ||||
|     if (window->X11.wmName != None) | ||||
|     { | ||||
|         XChangeProperty(_glfwLibrary.X11.display,  window->X11.handle, | ||||
|                         window->X11.wmName, type, 8, | ||||
|                         PropModeReplace, | ||||
|                         (unsigned char*) title, strlen(title)); | ||||
|     } | ||||
| 
 | ||||
|     if (window->X11.wmIconName != None) | ||||
|     { | ||||
|         XChangeProperty(_glfwLibrary.X11.display,  window->X11.handle, | ||||
|                         window->X11.wmIconName, type, 8, | ||||
|                         PropModeReplace, | ||||
|                         (unsigned char*) title, strlen(title)); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -51,10 +51,13 @@ target_link_libraries(sharing ${STATIC_DEPS}) | ||||
| add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c) | ||||
| target_link_libraries(tearing ${STATIC_DEPS}) | ||||
| 
 | ||||
| add_executable(title WIN32 MACOSX_BUNDLE title.c) | ||||
| target_link_libraries(title ${STATIC_DEPS}) | ||||
| 
 | ||||
| add_executable(windows WIN32 MACOSX_BUNDLE windows.c) | ||||
| target_link_libraries(windows ${STATIC_DEPS}) | ||||
| 
 | ||||
| set(WINDOWS_BINARIES accuracy sharing tearing windows) | ||||
| set(WINDOWS_BINARIES accuracy sharing tearing title windows) | ||||
| set(CONSOLE_BINARIES defaults events fsaa fsfocus gamma glfwinfo iconify | ||||
|                      joysticks listmodes peter reopen) | ||||
| 
 | ||||
|  | ||||
| @ -59,7 +59,7 @@ int main(void) | ||||
| { | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -69,7 +69,7 @@ int main(void) | ||||
|     int i, width, height; | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -59,7 +59,7 @@ int main(void) | ||||
|         exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW\n"); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -311,10 +311,7 @@ static void key_callback(GLFWwindow window, int key, int action) | ||||
|         case GLFW_KEY_R: | ||||
|         { | ||||
|             keyrepeat = !keyrepeat; | ||||
|             if (keyrepeat) | ||||
|                 glfwEnable(window, GLFW_KEY_REPEAT); | ||||
|             else | ||||
|                 glfwDisable(window, GLFW_KEY_REPEAT); | ||||
|             glfwSetInputMode(window, GLFW_KEY_REPEAT, keyrepeat); | ||||
| 
 | ||||
|             printf("(( key repeat %s ))\n", keyrepeat ? "enabled" : "disabled"); | ||||
|             break; | ||||
| @ -323,10 +320,7 @@ static void key_callback(GLFWwindow window, int key, int action) | ||||
|         case GLFW_KEY_S: | ||||
|         { | ||||
|             systemkeys = !systemkeys; | ||||
|             if (systemkeys) | ||||
|                 glfwEnable(window, GLFW_SYSTEM_KEYS); | ||||
|             else | ||||
|                 glfwDisable(window, GLFW_SYSTEM_KEYS); | ||||
|             glfwSetInputMode(window, GLFW_SYSTEM_KEYS, systemkeys); | ||||
| 
 | ||||
|             printf("(( system keys %s ))\n", systemkeys ? "enabled" : "disabled"); | ||||
|             break; | ||||
| @ -359,7 +353,7 @@ int main(void) | ||||
| 
 | ||||
|     setlocale(LC_ALL, ""); | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -81,7 +81,7 @@ int main(int argc, char** argv) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -75,7 +75,7 @@ int main(void) | ||||
| { | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
| @ -91,7 +91,7 @@ int main(void) | ||||
|     } | ||||
| 
 | ||||
|     glfwSwapInterval(1); | ||||
|     glfwSetCursorMode(window, GLFW_CURSOR_NORMAL); | ||||
|     glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); | ||||
| 
 | ||||
|     glfwSetWindowFocusCallback(window_focus_callback); | ||||
|     glfwSetKeyCallback(window_key_callback); | ||||
|  | ||||
| @ -96,7 +96,7 @@ int main(int argc, char** argv) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -183,7 +183,7 @@ int main(int argc, char** argv) | ||||
| 
 | ||||
|     glfwSetErrorCallback(error_callback); | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -90,7 +90,7 @@ int main(int argc, char** argv) | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -94,7 +94,7 @@ int main(void) | ||||
|     double update; | ||||
| 
 | ||||
|     /* Initialise GLFW */ | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -22,7 +22,7 @@ int main(void) | ||||
|     GLFWvidmode dtmode, modes[400]; | ||||
|     int modecount, i; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -35,7 +35,6 @@ | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| static GLboolean cursor_captured = GL_FALSE; | ||||
| static GLFWwindow window_handle = NULL; | ||||
| static int cursor_x; | ||||
| static int cursor_y; | ||||
| @ -44,18 +43,16 @@ static GLboolean open_window(void); | ||||
| 
 | ||||
| static void toggle_mouse_cursor(GLFWwindow window) | ||||
| { | ||||
|     if (cursor_captured) | ||||
|     if (glfwGetInputMode(window, GLFW_CURSOR_MODE) == GLFW_CURSOR_CAPTURED) | ||||
|     { | ||||
|         printf("Released cursor\n"); | ||||
|         glfwSetCursorMode(window, GLFW_CURSOR_NORMAL); | ||||
|         glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         printf("Captured cursor\n"); | ||||
|         glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED); | ||||
|         glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED); | ||||
|     } | ||||
| 
 | ||||
|     cursor_captured = !cursor_captured; | ||||
| } | ||||
| 
 | ||||
| static void mouse_position_callback(GLFWwindow window, int x, int y) | ||||
| @ -114,7 +111,7 @@ static GLboolean open_window(void) | ||||
| 
 | ||||
| int main(void) | ||||
| { | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -84,7 +84,7 @@ static GLboolean open_window(int width, int height, int mode) | ||||
| { | ||||
|     double base; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         return GL_FALSE; | ||||
|  | ||||
| @ -117,7 +117,7 @@ int main(int argc, char** argv) | ||||
|     GLuint texture; | ||||
|     int x, y; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
| @ -44,7 +44,7 @@ int main(void) | ||||
|     float position; | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|  | ||||
							
								
								
									
										70
									
								
								tests/title.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								tests/title.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | ||||
| //========================================================================
 | ||||
| // UTF-8 window title test
 | ||||
| // Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
 | ||||
| //
 | ||||
| // This software is provided 'as-is', without any express or implied
 | ||||
| // warranty. In no event will the authors be held liable for any damages
 | ||||
| // arising from the use of this software.
 | ||||
| //
 | ||||
| // Permission is granted to anyone to use this software for any purpose,
 | ||||
| // including commercial applications, and to alter it and redistribute it
 | ||||
| // freely, subject to the following restrictions:
 | ||||
| //
 | ||||
| // 1. The origin of this software must not be misrepresented; you must not
 | ||||
| //    claim that you wrote the original software. If you use this software
 | ||||
| //    in a product, an acknowledgment in the product documentation would
 | ||||
| //    be appreciated but is not required.
 | ||||
| //
 | ||||
| // 2. Altered source versions must be plainly marked as such, and must not
 | ||||
| //    be misrepresented as being the original software.
 | ||||
| //
 | ||||
| // 3. This notice may not be removed or altered from any source
 | ||||
| //    distribution.
 | ||||
| //
 | ||||
| //========================================================================
 | ||||
| //
 | ||||
| // This test sets a UTF-8 window title
 | ||||
| //
 | ||||
| //========================================================================
 | ||||
| 
 | ||||
| #include <GL/glfw3.h> | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| static void window_size_callback(GLFWwindow window, int width, int height) | ||||
| { | ||||
|     glViewport(0, 0, width, height); | ||||
| } | ||||
| 
 | ||||
| int main(void) | ||||
| { | ||||
|     GLFWwindow window; | ||||
| 
 | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL); | ||||
|     if (!window) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError())); | ||||
|         exit(EXIT_FAILURE); | ||||
|     } | ||||
| 
 | ||||
|     glfwSwapInterval(1); | ||||
| 
 | ||||
|     glfwSetWindowSizeCallback(window_size_callback); | ||||
| 
 | ||||
|     while (glfwIsWindow(window) == GL_TRUE) | ||||
|     { | ||||
|         glClear(GL_COLOR_BUFFER_BIT); | ||||
|         glfwSwapBuffers(); | ||||
|         glfwWaitEvents(); | ||||
|     } | ||||
| 
 | ||||
|     exit(EXIT_SUCCESS); | ||||
| } | ||||
| 
 | ||||
| @ -46,7 +46,7 @@ int main(void) | ||||
|     GLboolean running = GL_TRUE; | ||||
|     GLFWwindow windows[4]; | ||||
| 
 | ||||
|     if (!glfwInit()) | ||||
|     if (!glfwInit(NULL)) | ||||
|     { | ||||
|         fprintf(stderr, "Failed to initialize GLFW: %s\n", | ||||
|                 glfwErrorString(glfwGetError())); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user