Browse Source

Removed WindowGLUT, added WindowGLFW

Thomas Buck 10 years ago
parent
commit
6724d84f3b

+ 2
- 0
ChangeLog.md View File

@@ -5,6 +5,8 @@
5 5
     [ 20141217 ]
6 6
     * Introduced texel-offset in getUV() in an attempt to fix the texture-bleeding
7 7
     * Mesh is now called RoomMesh
8
+    * Removed non-functional GLUT windowing implementation
9
+    * Created new windowing implementation using GLFW3
8 10
 
9 11
     [ 20141216 ]
10 12
     * Allow navigation with a free-floating Camera

+ 2
- 2
README.md View File

@@ -68,7 +68,7 @@ Linux Distributions will probably provide an ALUT library ready to install with
68 68
 
69 69
 Sound support is optional, however. If cmake can’t find OpenAL and ALUT, Audio will be deactivated. If you want to explicitly deactivate it, call cmake with `-DENABLE_AUDIO=NO`.
70 70
 
71
-There is also a rudimentary windowing implementation using freeGLUT. It will be used if GLUT is found instead of SDL2, or if you call cmake with `-DFORCE_GLUT=YES`. Be aware that your experience will not be as nice as with SDL2...
71
+There is also a windowing implementation using GLFW. It will be used if GLFW is found instead of SDL2, or if you call cmake with `-DFORCE_GLFW=YES`. Be aware that your experience will not be as nice as with SDL2...
72 72
 
73 73
 ## Building
74 74
 
@@ -180,8 +180,8 @@ There are some included cmake scripts:
180 180
 * [FindSSE](https://gitorious.org/vc/vc/source/a1d8b9fc31060d870386613cc72319546c850b87:cmake/FindSSE.cmake)
181 181
 * [GetGitRevisionDescription.cmake](https://github.com/rpavlik/cmake-modules/blob/master/GetGitRevisionDescription.cmake)
182 182
 * [GetGitRevisionDescription.cmake.in](https://github.com/rpavlik/cmake-modules/blob/master/GetGitRevisionDescription.cmake.in)
183
-* [FindFreeGLUT](https://github.com/PDAL/PDAL/blob/master/cmake/modules/FindFreeGLUT.cmake)
184 183
 * [FindGLM] (https://github.com/g-truc/glm/blob/master/util/FindGLM.cmake)
184
+* [FindGLFW] (https://github.com/PixarAnimationStudios/OpenSubdiv/blob/master/cmake/FindGLFW.cmake)
185 185
 
186 186
 See the respective files in `cmake` for their licensing.
187 187
 

+ 0
- 50
cmake/FindFreeGLUT.cmake View File

@@ -1,50 +0,0 @@
1
-# Copyright (C) 2007-2009 LuaDist.
2
-# Created by Peter Kapec <kapecp@gmail.com>
3
-# Redistribution and use of this file is allowed according to the terms of the MIT license.
4
-# For details see the COPYRIGHT file distributed with LuaDist.
5
-#	Note:
6
-#		Searching headers and libraries is very simple and is NOT as powerful as scripts
7
-#		distributed with CMake, because LuaDist defines directories to search for.
8
-#		Everyone is encouraged to contact the author with improvements. Maybe this file
9
-#		becomes part of CMake distribution sometimes.
10
-
11
-# - Find FreeGLUT
12
-# Find the native FreeGLUT headers and libraries.
13
-#
14
-#  FREEGLUT_INCLUDE_DIRS - where to find freeglut.h, etc.
15
-#  FREEGLUT_LIBRARIES    - List of libraries when using FreeGLUT.
16
-#  FREEGLUT_FOUND        - True if FreeGLUT found.
17
-
18
-# 2014-10-08 Thomas Buck <xythobuz@xythobuz.de>:
19
-#   Fix to work on Mac OS X
20
-
21
-# Look for the header file.
22
-FIND_PATH(FREEGLUT_INCLUDE_DIR NAMES GL/freeglut.h
23
-    PATHS /opt/local/include
24
-)
25
-
26
-# Look for the library.
27
-IF(APPLE)
28
-    # We don't want to use the GLUT shipping with OS X
29
-    FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut glut
30
-        PATHS /opt/local/lib
31
-        NO_DEFAULT_PATH
32
-    )
33
-ELSE(APPLE)
34
-    FIND_LIBRARY(FREEGLUT_LIBRARY NAMES freeglut)
35
-ENDIF(APPLE)
36
-
37
-# Handle the QUIETLY and REQUIRED arguments and set FREEGLUT_FOUND to TRUE if all listed variables are TRUE.
38
-INCLUDE(FindPackageHandleStandardArgs)
39
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(FREEGLUT DEFAULT_MSG FREEGLUT_LIBRARY FREEGLUT_INCLUDE_DIR)
40
-
41
-# Copy the results to the output variables.
42
-IF(FREEGLUT_FOUND)
43
-	SET(FREEGLUT_LIBRARIES ${FREEGLUT_LIBRARY})
44
-	SET(FREEGLUT_INCLUDE_DIRS ${FREEGLUT_INCLUDE_DIR})
45
-ELSE(FREEGLUT_FOUND)
46
-	SET(FREEGLUT_LIBRARIES)
47
-	SET(FREEGLUT_INCLUDE_DIRS)
48
-ENDIF(FREEGLUT_FOUND)
49
-
50
-MARK_AS_ADVANCED(FREEGLUT_INCLUDE_DIRS FREEGLUT_LIBRARIES)

+ 221
- 0
cmake/FindGLFW.cmake View File

@@ -0,0 +1,221 @@
1
+#
2
+#   Copyright 2013 Pixar
3
+#
4
+#   Licensed under the Apache License, Version 2.0 (the "Apache License")
5
+#   with the following modification; you may not use this file except in
6
+#   compliance with the Apache License and the following modification to it:
7
+#   Section 6. Trademarks. is deleted and replaced with:
8
+#
9
+#   6. Trademarks. This License does not grant permission to use the trade
10
+#      names, trademarks, service marks, or product names of the Licensor
11
+#      and its affiliates, except as required to comply with Section 4(c) of
12
+#      the License and to reproduce the content of the NOTICE file.
13
+#
14
+#   You may obtain a copy of the Apache License at
15
+#
16
+#       http://www.apache.org/licenses/LICENSE-2.0
17
+#
18
+#   Unless required by applicable law or agreed to in writing, software
19
+#   distributed under the Apache License with the above modification is
20
+#   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21
+#   KIND, either express or implied. See the Apache License for the specific
22
+#   language governing permissions and limitations under the Apache License.
23
+#
24
+
25
+# Try to find GLFW library and include path.
26
+# Once done this will define
27
+#
28
+# GLFW_FOUND
29
+# GLFW_INCLUDE_DIR
30
+# GLFW_LIBRARIES
31
+#
32
+
33
+find_path( GLFW_INCLUDE_DIR 
34
+    NAMES
35
+        GL/glfw.h
36
+        GLFW/glfw3.h
37
+    PATHS
38
+        "${GLFW_LOCATION}/include"
39
+        "$ENV{GLFW_LOCATION}/include"
40
+        "$ENV{PROGRAMFILES}/GLFW/include"
41
+        "${OPENGL_INCLUDE_DIR}"
42
+        /usr/openwin/share/include
43
+        /usr/openwin/include
44
+        /usr/X11R6/include
45
+        /usr/include/X11
46
+        /opt/graphics/OpenGL/include
47
+        /opt/graphics/OpenGL/contrib/libglfw
48
+        /usr/local/include
49
+        /usr/include/GL
50
+        /usr/include
51
+    DOC 
52
+        "The directory where GL/glfw.h resides"
53
+)
54
+
55
+if (WIN32)
56
+    if(CYGWIN)
57
+        find_library( GLFW_glfw_LIBRARY 
58
+            NAMES
59
+                glfw32
60
+            PATHS
61
+                "${GLFW_LOCATION}/lib"
62
+                "${GLFW_LOCATION}/lib/x64"
63
+                "$ENV{GLFW_LOCATION}/lib"
64
+                "${OPENGL_LIBRARY_DIR}"
65
+                /usr/lib
66
+                /usr/lib/w32api
67
+                /usr/local/lib
68
+                /usr/X11R6/lib
69
+            DOC 
70
+                "The GLFW library"
71
+        )
72
+    else()
73
+        find_library( GLFW_glfw_LIBRARY
74
+            NAMES 
75
+                glfw32 
76
+                glfw32s 
77
+                glfw
78
+                glfw3
79
+            PATHS
80
+                "${GLFW_LOCATION}/lib"
81
+                "${GLFW_LOCATION}/lib/x64"
82
+                "${GLFW_LOCATION}/lib-msvc110"
83
+                "$ENV{GLFW_LOCATION}/lib"
84
+                "$ENV{GLFW_LOCATION}/lib/x64"
85
+                "$ENV{GLFW_LOCATION}/lib-msvc110"
86
+                "${PROJECT_SOURCE_DIR}/extern/glfw/bin"
87
+                "${PROJECT_SOURCE_DIR}/extern/glfw/lib"
88
+                "$ENV{PROGRAMFILES}/GLFW/lib"
89
+                "${OPENGL_LIBRARY_DIR}"
90
+            DOC 
91
+                "The GLFW library"
92
+        )
93
+    endif()
94
+else ()
95
+    if (APPLE)
96
+        find_library( GLFW_glfw_LIBRARY glfw
97
+            NAMES 
98
+                glfw
99
+                glfw3
100
+            PATHS
101
+                "${GLFW_LOCATION}/lib"
102
+                "${GLFW_LOCATION}/lib/cocoa"
103
+                "$ENV{GLFW_LOCATION}/lib"
104
+                "$ENV{GLFW_LOCATION}/lib/cocoa"
105
+                /usr/local/lib
106
+        )
107
+        set(GLFW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
108
+        set(GLFW_corevideo_LIBRARY "-framework CoreVideo" CACHE STRING "CoreVideo framework for OSX")
109
+        set(GLFW_iokit_LIBRARY "-framework IOKit" CACHE STRING "IOKit framework for OSX")
110
+    else ()
111
+        # (*)NIX
112
+        
113
+        find_package(X11 REQUIRED)
114
+        
115
+        if(NOT X11_Xrandr_FOUND)
116
+            message(FATAL_ERROR "Xrandr library not found - required for GLFW")
117
+        endif()
118
+
119
+        if(NOT X11_xf86vmode_FOUND)
120
+            message(FATAL_ERROR "xf86vmode library not found - required for GLFW")
121
+        endif()
122
+
123
+        if(NOT X11_Xcursor_FOUND)
124
+            message(FATAL_ERROR "Xcursor library not found - required for GLFW")
125
+        endif()
126
+
127
+        list(APPEND GLFW_x11_LIBRARY "${X11_Xrandr_LIB}" "${X11_Xxf86vm_LIB}" "${X11_Xcursor_LIB}" -lrt)
128
+
129
+        find_library( GLFW_glfw_LIBRARY
130
+            NAMES 
131
+                glfw
132
+                glfw3
133
+            PATHS
134
+                "${GLFW_LOCATION}/lib"
135
+                "$ENV{GLFW_LOCATION}/lib"
136
+                "${GLFW_LOCATION}/lib/x11"
137
+                "$ENV{GLFW_LOCATION}/lib/x11"
138
+                /usr/lib64
139
+                /usr/lib
140
+                /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
141
+                /usr/local/lib64
142
+                /usr/local/lib
143
+                /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
144
+                /usr/openwin/lib
145
+                /usr/X11R6/lib
146
+            DOC 
147
+                "The GLFW library"
148
+        )
149
+    endif (APPLE)
150
+endif (WIN32)
151
+
152
+set( GLFW_FOUND "NO" )
153
+
154
+if(GLFW_INCLUDE_DIR)
155
+
156
+    if(GLFW_glfw_LIBRARY)
157
+        set( GLFW_LIBRARIES "${GLFW_glfw_LIBRARY}"
158
+                            "${GLFW_x11_LIBRARY}"
159
+                            "${GLFW_cocoa_LIBRARY}"
160
+                            "${GLFW_iokit_LIBRARY}"
161
+                            "${GLFW_corevideo_LIBRARY}" )
162
+        set( GLFW_FOUND "YES" )
163
+        set (GLFW_LIBRARY "${GLFW_LIBRARIES}")
164
+        set (GLFW_INCLUDE_PATH "${GLFW_INCLUDE_DIR}")
165
+    endif(GLFW_glfw_LIBRARY)
166
+
167
+
168
+    # Tease the GLFW_VERSION numbers from the lib headers
169
+    function(parseVersion FILENAME VARNAME)
170
+            
171
+        set(PATTERN "^#define ${VARNAME}.*$")
172
+        
173
+        file(STRINGS "${GLFW_INCLUDE_DIR}/${FILENAME}" TMP REGEX ${PATTERN})
174
+        
175
+        string(REGEX MATCHALL "[0-9]+" TMP ${TMP})
176
+        
177
+        set(${VARNAME} ${TMP} PARENT_SCOPE)
178
+        
179
+    endfunction()
180
+
181
+
182
+    if(EXISTS "${GLFW_INCLUDE_DIR}/GL/glfw.h")
183
+
184
+        parseVersion(GL/glfw.h GLFW_VERSION_MAJOR)
185
+        parseVersion(GL/glfw.h GLFW_VERSION_MINOR)
186
+        parseVersion(GL/glfw.h GLFW_VERSION_REVISION)
187
+
188
+    elseif(EXISTS "${GLFW_INCLUDE_DIR}/GLFW/glfw3.h")
189
+
190
+        parseVersion(GLFW/glfw3.h GLFW_VERSION_MAJOR)
191
+        parseVersion(GLFW/glfw3.h GLFW_VERSION_MINOR)
192
+        parseVersion(GLFW/glfw3.h GLFW_VERSION_REVISION)
193
+ 
194
+    endif()
195
+
196
+    if(${GLFW_VERSION_MAJOR} OR ${GLFW_VERSION_MINOR} OR ${GLFW_VERSION_REVISION})
197
+        set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}.${GLFW_VERSION_REVISION}")
198
+        set(GLFW_VERSION_STRING "${GLFW_VERSION}")
199
+        mark_as_advanced(GLFW_VERSION)
200
+    endif()
201
+    
202
+endif(GLFW_INCLUDE_DIR)
203
+
204
+include(FindPackageHandleStandardArgs)
205
+
206
+find_package_handle_standard_args(GLFW 
207
+    REQUIRED_VARS
208
+        GLFW_INCLUDE_DIR
209
+        GLFW_LIBRARIES
210
+    VERSION_VAR
211
+        GLFW_VERSION
212
+)
213
+
214
+mark_as_advanced(
215
+  GLFW_INCLUDE_DIR
216
+  GLFW_LIBRARIES
217
+  GLFW_glfw_LIBRARY
218
+  GLFW_cocoa_LIBRARY
219
+)
220
+
221
+

+ 3
- 0
include/config.h.in View File

@@ -20,6 +20,9 @@ extern const char* INSTALL_PREFIX;
20 20
 
21 21
 #cmakedefine USING_AL
22 22
 #cmakedefine USING_PNG
23
+#cmakedefine USING_SDL
24
+#cmakedefine USING_SDL_FONT
25
+#cmakedefine USING_GLFW
23 26
 
24 27
 #cmakedefine HAVE_EXECINFO_H
25 28
 #cmakedefine HAVE_BACKTRACE

+ 4
- 3
include/global.h View File

@@ -70,13 +70,14 @@ typedef enum {
70 70
 // Globally include OpenGL header
71 71
 #ifdef __APPLE__
72 72
 #include <OpenGL/gl3.h>
73
-#else
73
+#else // __APPLE__
74 74
 #ifdef _WIN32
75 75
 #include <windows.h>
76
-#endif
76
+#endif // _WIN32
77
+//! \todo gl3 header?
77 78
 #include <GL/gl.h>
78 79
 #include <GL/glext.h>
79
-#endif
80
+#endif // __APPLE__
80 81
 
81 82
 // If available, use our own assert that prints the call stack
82 83
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && defined(HAVE_BACKTRACE_SYMBOLS)

+ 49
- 0
include/system/WindowGLFW.h View File

@@ -0,0 +1,49 @@
1
+/*!
2
+ * \file include/WindowGLFW.h
3
+ * \brief GLFW windowing implementation
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _WINDOW_GLFW_H_
9
+#define _WINDOW_GLFW_H_
10
+
11
+#include <GLFW/glfw3.h>
12
+
13
+#include "system/Window.h"
14
+
15
+class WindowGLFW : public Window {
16
+  public:
17
+
18
+    WindowGLFW();
19
+    virtual ~WindowGLFW();
20
+
21
+    virtual void setSize(unsigned int width, unsigned int height);
22
+
23
+    virtual void setFullscreen(bool fullscreen);
24
+
25
+    virtual void setMousegrab(bool grab);
26
+
27
+    virtual int initialize();
28
+
29
+    virtual void eventHandling();
30
+
31
+    virtual void setTextInput(bool on);
32
+
33
+    virtual void swapBuffersGL();
34
+
35
+  private:
36
+    static void errorCallback(int error, const char* desc);
37
+    static void sizeCallback(GLFWwindow* w, int width, int height);
38
+    static void cursorCallback(GLFWwindow* w, double xpos, double ypos);
39
+    static void keyCallback(GLFWwindow* w, int key, int scancode, int action, int mods);
40
+    static void buttonCallback(GLFWwindow* w, int button, int action, int mods);
41
+    static void scrollCallback(GLFWwindow* w, double xoffset, double yoffset);
42
+
43
+    static KeyboardButton convertAsciiButton(int key);
44
+
45
+    GLFWwindow* mWindow;
46
+};
47
+
48
+#endif
49
+

+ 0
- 50
include/system/WindowGLUT.h View File

@@ -1,50 +0,0 @@
1
-/*!
2
- * \file include/WindowGLUT.h
3
- * \brief GLUT windowing implementation
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#ifndef _WINDOW_GLUT_H_
9
-#define _WINDOW_GLUT_H_
10
-
11
-#include "system/Window.h"
12
-
13
-/*!
14
- * \brief GLUT windowing implementation
15
- */
16
-class WindowGLUT : public Window {
17
-  public:
18
-
19
-    WindowGLUT();
20
-
21
-    virtual void setSize(unsigned int width, unsigned int height);
22
-
23
-    virtual void setFullscreen(bool fullscreen);
24
-
25
-    virtual void setMousegrab(bool grab);
26
-
27
-    virtual int initialize();
28
-
29
-    virtual void eventHandling();
30
-
31
-    virtual void setTextInput(bool on);
32
-
33
-    virtual void swapBuffersGL();
34
-
35
-  private:
36
-    static void reshapeCallback(int width, int height);
37
-    static void keyboardCallback(unsigned char key, int x, int y);
38
-    static void keyboardUpCallback(unsigned char key, int x, int y);
39
-    static void specialCallback(int key, int x, int y);
40
-    static void specialUpCallback(int key, int x, int y);
41
-    static void mouseCallback(int button, int state, int x, int y);
42
-    static void motionCallback(int x, int y);
43
-    static void mouseWheelCallback(int wheel, int direction, int x, int y);
44
-
45
-    static KeyboardButton convertAsciiButton(unsigned char key);
46
-    static KeyboardButton convertKeyCode(int key);
47
-};
48
-
49
-#endif
50
-

+ 25
- 20
src/CMakeLists.txt View File

@@ -1,6 +1,6 @@
1 1
 # Options
2 2
 option (ENABLE_AUDIO "Enable Sound Output" YES)
3
-option (FORCE_GLUT "Use freeGLUT even if SDL2 was found" NO)
3
+option (FORCE_GLFW "Use GLFW even if SDL2 was found" NO)
4 4
 
5 5
 # Add OpenGL Library
6 6
 find_package (OpenGL REQUIRED)
@@ -14,7 +14,7 @@ set (LIBS ${LIBS} ${ZLIB_LIBRARIES})
14 14
 
15 15
 # Add SDL2 Library
16 16
 find_package (SDL2)
17
-if (SDL2_FOUND AND NOT FORCE_GLUT)
17
+if (SDL2_FOUND AND NOT FORCE_GLFW)
18 18
     include_directories (SYSTEM ${SDL2_INCLUDE_DIR})
19 19
     set (LIBS ${LIBS} ${SDL2_LIBRARY})
20 20
 
@@ -24,14 +24,13 @@ if (SDL2_FOUND AND NOT FORCE_GLUT)
24 24
         include_directories (SYSTEM ${SDL2TTF_INCLUDE_DIR})
25 25
         set (LIBS ${LIBS} ${SDL2TTF_LIBRARY})
26 26
     endif (SDL2TTF_FOUND)
27
-else (SDL2_FOUND AND NOT FORCE_GLUT)
28
-    # Add freeglut Library
29
-    find_package (FREEGLUT)
30
-    if (FREEGLUT_FOUND)
31
-        include_directories (SYSTEM ${FREEGLUT_INCLUDE_DIRS})
32
-        set (LIBS ${LIBS} ${FREEGLUT_LIBRARIES})
33
-    endif (FREEGLUT_FOUND)
34
-endif (SDL2_FOUND AND NOT FORCE_GLUT)
27
+else (SDL2_FOUND AND NOT FORCE_GLFW)
28
+    find_package (GLFW)
29
+    if (GLFW_FOUND)
30
+        include_directories (SYSTEM ${GLFW_INCLUDE_DIRS})
31
+        set (LIBS ${LIBS} ${GLFW_LIBRARIES})
32
+    endif (GLFW_FOUND)
33
+endif (SDL2_FOUND AND NOT FORCE_GLFW)
35 34
 
36 35
 # Add OpenAL Library
37 36
 find_package (OpenAL)
@@ -97,18 +96,24 @@ else (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
97 96
 endif (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
98 97
 
99 98
 # Select available Windowing library
100
-if (SDL2_FOUND AND NOT FORCE_GLUT)
101
-    set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUSING_SDL")
99
+if (SDL2_FOUND AND NOT FORCE_GLFW)
100
+    set (USING_GLFW FALSE)
101
+    set (USING_SDL TRUE)
102 102
     if (SDL2TTF_FOUND)
103
-        set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUSING_SDL_FONT")
103
+        set (USING_SDL_FONT TRUE)
104
+    else (SDL2TTF_FOUND)
105
+        set (USING_SDL_FONT FALSE)
104 106
     endif (SDL2TTF_FOUND)
105
-else (SDL2_FOUND AND NOT FORCE_GLUT)
106
-    if (FREEGLUT_FOUND)
107
-        set (OpenRaider_CXX_FLAGS "${OpenRaider_CXX_FLAGS} -DUSING_GLUT")
108
-    else (FREEGLUT_FOUND)
109
-        message (FATAL_ERROR "SDL2 or freeGLUT are required!")
110
-    endif (FREEGLUT_FOUND)
111
-endif (SDL2_FOUND AND NOT FORCE_GLUT)
107
+else (SDL2_FOUND AND NOT FORCE_GLFW)
108
+    set (USING_SDL FALSE)
109
+    set (USING_SDL_FONT FALSE)
110
+    if (GLFW_FOUND)
111
+        set (USING_GLFW TRUE)
112
+    else (GLFW_FOUND)
113
+        set (USING_GLFW FALSE)
114
+        message (FATAL_ERROR "SDL2 or GLFW are required!")
115
+    endif (GLFW_FOUND)
116
+endif (SDL2_FOUND AND NOT FORCE_GLFW)
112 117
 
113 118
 if (PNG_FOUND)
114 119
     set (USING_PNG TRUE)

+ 4
- 4
src/main.cpp View File

@@ -30,8 +30,8 @@
30 30
 
31 31
 #ifdef USING_SDL
32 32
 #include "system/WindowSDL.h"
33
-#elif defined(USING_GLUT)
34
-#include "system/WindowGLUT.h"
33
+#elif defined(USING_GLFW)
34
+#include "system/WindowGLFW.h"
35 35
 #else
36 36
 #error No Windowing Library selected!
37 37
 #endif
@@ -95,8 +95,8 @@ int main(int argc, char* argv[]) {
95 95
 
96 96
 #ifdef USING_SDL
97 97
     gWindow.reset(new WindowSDL());
98
-#elif defined(USING_GLUT)
99
-    gWindow.reset(new WindowGLUT());
98
+#elif defined(USING_GLFW)
99
+    gWindow.reset(new WindowGLFW());
100 100
 #endif
101 101
 
102 102
     Command::fillCommandList();

+ 13
- 15
src/system/CMakeLists.txt View File

@@ -6,25 +6,23 @@ set (SYS_SRCS ${SYS_SRCS} "Sound.cpp" "../../include/system/Sound.h")
6 6
 set (SYS_SRCS ${SYS_SRCS} "Window.cpp" "../../include/system/Window.h")
7 7
 
8 8
 # Select available Sound library
9
-if (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
9
+if (USING_AL AND ENABLE_AUDIO)
10 10
     set (SYS_SRCS ${SYS_SRCS} "SoundAL.cpp" "../../include/system/SoundAL.h")
11
-else (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
11
+else (USING_AL AND ENABLE_AUDIO)
12 12
     message (STATUS "Disabled Sound support (no OpenAL and ALUT)!")
13
-endif (OPENAL_FOUND AND ALUT_FOUND AND ENABLE_AUDIO)
13
+endif (USING_AL AND ENABLE_AUDIO)
14 14
 
15
-# Select available Windowing library
16
-if (SDL2_FOUND AND NOT FORCE_GLUT)
15
+if (USING_SDL)
17 16
     set (SYS_SRCS ${SYS_SRCS} "WindowSDL.cpp" "../../include/system/WindowSDL.h")
18
-    if (SDL2TTF_FOUND)
19
-        set (SYS_SRCS ${SYS_SRCS} "FontSDL.cpp" "../../include/system/FontSDL.h")
20
-    endif (SDL2TTF_FOUND)
21
-else (SDL2_FOUND AND NOT FORCE_GLUT)
22
-    if (FREEGLUT_FOUND)
23
-        set (SYS_SRCS ${SYS_SRCS} "WindowGLUT.cpp" "../../include/system/WindowGLUT.h")
24
-    else (FREEGLUT_FOUND)
25
-        message (FATAL_ERROR "SDL2 or freeGLUT are required!")
26
-    endif (FREEGLUT_FOUND)
27
-endif (SDL2_FOUND AND NOT FORCE_GLUT)
17
+endif (USING_SDL)
18
+
19
+if (USING_SDL_FONT)
20
+    set (SYS_SRCS ${SYS_SRCS} "FontSDL.cpp" "../../include/system/FontSDL.h")
21
+endif (USING_SDL_FONT)
22
+
23
+if (USING_GLFW)
24
+    set (SYS_SRCS ${SYS_SRCS} "WindowGLFW.cpp" "../../include/system/WindowGLFW.h")
25
+endif (USING_GLFW)
28 26
 
29 27
 # Add library
30 28
 add_library (OpenRaider_system OBJECT ${SYS_SRCS})

+ 400
- 0
src/system/WindowGLFW.cpp View File

@@ -0,0 +1,400 @@
1
+/*!
2
+ * \file src/WindowGLFW.cpp
3
+ * \brief GLFW windowing implementation
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include <cstring>
9
+
10
+#include "global.h"
11
+#include "Log.h"
12
+#include "RunTime.h"
13
+#include "UI.h"
14
+#include "utils/strings.h"
15
+#include "system/WindowGLFW.h"
16
+
17
+static int lastMouseX = 0;
18
+static int lastMouseY = 0;
19
+
20
+WindowGLFW::WindowGLFW() {
21
+    mInit = false;
22
+    mWidth = DEFAULT_WIDTH;
23
+    mHeight = DEFAULT_HEIGHT;
24
+    mFullscreen = false;
25
+    mMousegrab = false;
26
+    mTextInput = false;
27
+    mWindow = nullptr;
28
+}
29
+
30
+WindowGLFW::~WindowGLFW() {
31
+    if (mInit) {
32
+        if (mWindow) {
33
+            glfwDestroyWindow(mWindow);
34
+        }
35
+
36
+        glfwTerminate();
37
+    }
38
+}
39
+
40
+int WindowGLFW::initialize() {
41
+    assert(mInit == false);
42
+
43
+    glfwSetErrorCallback(WindowGLFW::errorCallback);
44
+    if (!glfwInit()) {
45
+        return -1;
46
+    }
47
+
48
+    glfwWindowHint(GLFW_SAMPLES, 4);
49
+    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
50
+    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
51
+    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
52
+    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
53
+
54
+    mWindow = glfwCreateWindow(mWidth, mHeight, VERSION,
55
+                               mFullscreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
56
+    if (!mWindow) {
57
+        glfwTerminate();
58
+        return -2;
59
+    }
60
+
61
+    glfwMakeContextCurrent(mWindow);
62
+
63
+    glfwSetWindowSizeCallback(mWindow, WindowGLFW::sizeCallback);
64
+    glfwSetCursorPosCallback(mWindow, WindowGLFW::cursorCallback);
65
+    glfwSetKeyCallback(mWindow, WindowGLFW::keyCallback);
66
+    glfwSetMouseButtonCallback(mWindow, WindowGLFW::buttonCallback);
67
+    glfwSetScrollCallback(mWindow, WindowGLFW::scrollCallback);
68
+
69
+    mInit = true;
70
+    return 0;
71
+}
72
+
73
+void WindowGLFW::eventHandling() {
74
+    assert(mInit == true);
75
+
76
+    glfwPollEvents();
77
+
78
+    if (glfwWindowShouldClose(mWindow)) {
79
+        getRunTime().setRunning(false);
80
+    }
81
+
82
+    UI::eventsFinished();
83
+}
84
+
85
+void WindowGLFW::setSize(unsigned int width, unsigned int height) {
86
+    assert(width > 0);
87
+    assert(height > 0);
88
+
89
+    if (mInit) {
90
+        if ((mWidth != width) || (mHeight != height)) {
91
+            glfwSetWindowSize(mWindow, width, height);
92
+            getWindow().resizeGL();
93
+        }
94
+    }
95
+
96
+    mWidth = width;
97
+    mHeight = height;
98
+}
99
+
100
+void WindowGLFW::setFullscreen(bool fullscreen) {
101
+    mFullscreen = fullscreen;
102
+
103
+    //! \todo GLFW does not support toggling fullscreen?!
104
+}
105
+
106
+void WindowGLFW::setMousegrab(bool grab) {
107
+    mMousegrab = grab;
108
+
109
+    if (mInit == true) {
110
+        if (mMousegrab)
111
+            glfwSetInputMode(mWindow, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
112
+        else
113
+            glfwSetInputMode(mWindow, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
114
+    }
115
+}
116
+
117
+void WindowGLFW::setTextInput(bool on) {
118
+    assert(mInit == true);
119
+    mTextInput = on;
120
+}
121
+
122
+void WindowGLFW::swapBuffersGL() {
123
+    assert(mInit == true);
124
+    glfwSwapBuffers(mWindow);
125
+}
126
+
127
+void WindowGLFW::errorCallback(int error, const char* desc) {
128
+    getLog() << "GLFW Error (" << error << "): " << desc << Log::endl;
129
+}
130
+
131
+void WindowGLFW::sizeCallback(GLFWwindow* w, int width, int height) {
132
+    getWindow().setSize(width, height);
133
+}
134
+
135
+void WindowGLFW::cursorCallback(GLFWwindow* w, double xpos, double ypos) {
136
+    int xrel = xpos - lastMouseX;
137
+    int yrel = ypos - lastMouseY;
138
+    UI::handleMouseMotion(xrel, yrel, xpos, ypos);
139
+    lastMouseX = xpos;
140
+    lastMouseY = ypos;
141
+}
142
+
143
+static bool modShift = false;
144
+static bool modControl = false;
145
+static bool modAlt = false;
146
+static bool modSuper = false;
147
+
148
+void WindowGLFW::keyCallback(GLFWwindow* w, int key, int scancode, int action, int mods) {
149
+    if (((mods & GLFW_MOD_SHIFT) != 0) != modShift) {
150
+        modShift = (mods & GLFW_MOD_SHIFT) != 0;
151
+        UI::handleKeyboard(leftshiftKey, modShift);
152
+    }
153
+
154
+    if (((mods & GLFW_MOD_CONTROL) != 0) != modControl) {
155
+        modControl = (mods & GLFW_MOD_CONTROL) != 0;
156
+        UI::handleKeyboard(leftctrlKey, modControl);
157
+    }
158
+
159
+    if (((mods & GLFW_MOD_ALT) != 0) != modAlt) {
160
+        modAlt = (mods & GLFW_MOD_ALT) != 0;
161
+        UI::handleKeyboard(leftaltKey, modAlt);
162
+    }
163
+
164
+    if (((mods & GLFW_MOD_SUPER) != 0) != modSuper) {
165
+        modSuper = (mods & GLFW_MOD_SUPER) != 0;
166
+        UI::handleKeyboard(leftguiKey, modSuper);
167
+    }
168
+
169
+    if (getWindow().getTextInput() && (action != GLFW_RELEASE)) {
170
+        //! \todo Handle text input properly!
171
+        if ((key >= '0') && (key <= '9')) {
172
+            char s[2] = { (char)key, '\0' };
173
+            UI::handleText(s, false);
174
+        } else if ((key >= 'A') && (key <= 'Z')) {
175
+            key = key - 'A' + 'a';
176
+            char s[2] = { (char)key, '\0' };
177
+            UI::handleText(s, false);
178
+            key = key - 'a' + 'A';
179
+        }
180
+    }
181
+
182
+    KeyboardButton b = convertAsciiButton(key);
183
+    UI::handleKeyboard(b, (action != GLFW_RELEASE));
184
+}
185
+
186
+void WindowGLFW::buttonCallback(GLFWwindow* w, int button, int action, int mods) {
187
+    if (((mods & GLFW_MOD_SHIFT) != 0) != modShift) {
188
+        modShift = (mods & GLFW_MOD_SHIFT) != 0;
189
+        UI::handleKeyboard(leftshiftKey, modShift);
190
+    }
191
+
192
+    if (((mods & GLFW_MOD_CONTROL) != 0) != modControl) {
193
+        modControl = (mods & GLFW_MOD_CONTROL) != 0;
194
+        UI::handleKeyboard(leftctrlKey, modControl);
195
+    }
196
+
197
+    if (((mods & GLFW_MOD_ALT) != 0) != modAlt) {
198
+        modAlt = (mods & GLFW_MOD_ALT) != 0;
199
+        UI::handleKeyboard(leftaltKey, modAlt);
200
+    }
201
+
202
+    if (((mods & GLFW_MOD_SUPER) != 0) != modSuper) {
203
+        modSuper = (mods & GLFW_MOD_SUPER) != 0;
204
+        UI::handleKeyboard(leftguiKey, modSuper);
205
+    }
206
+
207
+    KeyboardButton b;
208
+    switch (button) {
209
+        case GLFW_MOUSE_BUTTON_LEFT:
210
+            b = leftmouseKey;
211
+            break;
212
+
213
+        case GLFW_MOUSE_BUTTON_RIGHT:
214
+            b = rightmouseKey;
215
+            break;
216
+
217
+        case GLFW_MOUSE_BUTTON_MIDDLE:
218
+            b = middlemouseKey;
219
+            break;
220
+
221
+        default:
222
+            b = unknownKey;
223
+            break;
224
+    }
225
+
226
+    UI::handleMouseClick(lastMouseX, lastMouseY, b, (action == GLFW_RELEASE));
227
+}
228
+
229
+void WindowGLFW::scrollCallback(GLFWwindow* w, double xoffset, double yoffset) {
230
+    UI::handleMouseScroll(xoffset, yoffset);
231
+}
232
+
233
+KeyboardButton WindowGLFW::convertAsciiButton(int key) {
234
+    // Alphanumerics can be returned as is
235
+    if ((key >= '0') && (key <= '9')) {
236
+        return static_cast<KeyboardButton>(key);
237
+    } else if ((key >= 'A') && (key <= 'Z')) {
238
+        key = key - 'A' + 'a';
239
+        return static_cast<KeyboardButton>(key);
240
+    }
241
+
242
+    //! \fixme GLFW requires keyboard layout? Currently US is hard coded
243
+    switch (key) {
244
+        case ' ':
245
+            return spaceKey;
246
+
247
+        case '!':
248
+            return oneKey;
249
+
250
+        case '@':
251
+            return twoKey;
252
+
253
+        case '#':
254
+            return threeKey;
255
+
256
+        case '$':
257
+            return fourKey;
258
+
259
+        case '%':
260
+            return fiveKey;
261
+
262
+        case '^':
263
+            return sixKey;
264
+
265
+        case '&':
266
+            return sevenKey;
267
+
268
+        case '*':
269
+            return eightKey;
270
+
271
+        case '(':
272
+            return nineKey;
273
+
274
+        case ')':
275
+            return zeroKey;
276
+
277
+        case '"':
278
+        case '\'':
279
+            return quoteKey;
280
+
281
+        case '+':
282
+        case '=':
283
+            return equalsKey;
284
+
285
+        case ',':
286
+        case '<':
287
+            return commaKey;
288
+
289
+        case '-':
290
+        case '_':
291
+            return minusKey;
292
+
293
+        case '.':
294
+        case '>':
295
+            return dotKey;
296
+
297
+        case '/':
298
+        case '?':
299
+            return slashKey;
300
+
301
+        case ':':
302
+        case ';':
303
+            return semicolonKey;
304
+
305
+        case '[':
306
+        case '{':
307
+            return leftbracketKey;
308
+
309
+        case ']':
310
+        case '}':
311
+            return rightbracketKey;
312
+
313
+        case '\\':
314
+        case '|':
315
+            return backslashKey;
316
+
317
+        case '`':
318
+        case '~':
319
+            return backquoteKey;
320
+
321
+        case GLFW_KEY_TAB:
322
+            return tabKey;
323
+
324
+        case GLFW_KEY_BACKSPACE:
325
+            return backspaceKey;
326
+
327
+        case GLFW_KEY_ENTER:
328
+            return enterKey;
329
+
330
+        case GLFW_KEY_ESCAPE:
331
+            return escapeKey;
332
+
333
+        case GLFW_KEY_F1:
334
+            return f1Key;
335
+
336
+        case GLFW_KEY_F2:
337
+            return f2Key;
338
+
339
+        case GLFW_KEY_F3:
340
+            return f3Key;
341
+
342
+        case GLFW_KEY_F4:
343
+            return f4Key;
344
+
345
+        case GLFW_KEY_F5:
346
+            return f5Key;
347
+
348
+        case GLFW_KEY_F6:
349
+            return f6Key;
350
+
351
+        case GLFW_KEY_F7:
352
+            return f7Key;
353
+
354
+        case GLFW_KEY_F8:
355
+            return f8Key;
356
+
357
+        case GLFW_KEY_F9:
358
+            return f9Key;
359
+
360
+        case GLFW_KEY_F10:
361
+            return f10Key;
362
+
363
+        case GLFW_KEY_F11:
364
+            return f11Key;
365
+
366
+        case GLFW_KEY_F12:
367
+            return f12Key;
368
+
369
+        case GLFW_KEY_LEFT:
370
+            return leftKey;
371
+
372
+        case GLFW_KEY_UP:
373
+            return upKey;
374
+
375
+        case GLFW_KEY_RIGHT:
376
+            return rightKey;
377
+
378
+        case GLFW_KEY_DOWN:
379
+            return downKey;
380
+
381
+        case GLFW_KEY_PAGE_UP:
382
+            return pageupKey;
383
+
384
+        case GLFW_KEY_PAGE_DOWN:
385
+            return pagedownKey;
386
+
387
+        case GLFW_KEY_HOME:
388
+            return homeKey;
389
+
390
+        case GLFW_KEY_END:
391
+            return endKey;
392
+
393
+        case GLFW_KEY_INSERT:
394
+            return insertKey;
395
+
396
+        default:
397
+            return unknownKey;
398
+    }
399
+}
400
+

+ 0
- 372
src/system/WindowGLUT.cpp View File

@@ -1,372 +0,0 @@
1
-/*!
2
- * \file src/WindowGLUT.cpp
3
- * \brief GLUT windowing implementation
4
- *
5
- * \author xythobuz
6
- */
7
-
8
-#include <cstring>
9
-
10
-#include <GL/freeglut.h>
11
-
12
-#include "global.h"
13
-#include "RunTime.h"
14
-#include "UI.h"
15
-#include "utils/strings.h"
16
-#include "system/WindowGLUT.h"
17
-
18
-//! \todo Modifier keys currently don't create keyboard events...
19
-
20
-static int lastMouseX = 0;
21
-static int lastMouseY = 0;
22
-
23
-WindowGLUT::WindowGLUT() {
24
-    mInit = false;
25
-    mWidth = DEFAULT_WIDTH;
26
-    mHeight = DEFAULT_HEIGHT;
27
-    mFullscreen = false;
28
-    mMousegrab = false;
29
-    mTextInput = false;
30
-}
31
-
32
-void WindowGLUT::setSize(unsigned int width, unsigned int height) {
33
-    assert(width > 0);
34
-    assert(height > 0);
35
-
36
-    mWidth = width;
37
-    mHeight = height;
38
-
39
-    if (mInit == true) {
40
-        glutReshapeWindow(width, height);
41
-    }
42
-}
43
-
44
-void WindowGLUT::setFullscreen(bool fullscreen) {
45
-    mFullscreen = fullscreen;
46
-
47
-    if (mInit == true) {
48
-        if (mFullscreen)
49
-            glutFullScreen();
50
-        else
51
-            glutLeaveFullScreen();
52
-    }
53
-}
54
-
55
-void WindowGLUT::setMousegrab(bool grab) {
56
-    mMousegrab = grab;
57
-
58
-    if (mInit == true) {
59
-        if (mMousegrab)
60
-            glutSetCursor(GLUT_CURSOR_NONE);
61
-        else
62
-            glutSetCursor(GLUT_CURSOR_INHERIT);
63
-    }
64
-}
65
-
66
-int WindowGLUT::initialize() {
67
-    assert(mInit == false);
68
-
69
-    int argc = 1;
70
-    char* argv[] = { new char[11], nullptr };
71
-    strcpy(argv[0], "OpenRaider");
72
-    glutInitWindowSize(mWidth, mHeight);
73
-    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_MULTISAMPLE);
74
-    glutInitContextVersion(3, 3);
75
-    glutInitContextProfile(GLUT_CORE_PROFILE);
76
-    glutInit(&argc, argv);
77
-    glutCreateWindow(VERSION);
78
-
79
-    glutReshapeFunc(WindowGLUT::reshapeCallback);
80
-    glutKeyboardFunc(WindowGLUT::keyboardCallback);
81
-    glutKeyboardUpFunc(WindowGLUT::keyboardUpCallback);
82
-    glutSpecialFunc(WindowGLUT::specialCallback);
83
-    glutSpecialUpFunc(WindowGLUT::specialUpCallback);
84
-    glutMouseFunc(WindowGLUT::mouseCallback);
85
-    glutMotionFunc(WindowGLUT::motionCallback);
86
-    glutPassiveMotionFunc(WindowGLUT::motionCallback);
87
-    glutMouseWheelFunc(WindowGLUT::mouseWheelCallback);
88
-
89
-    delete [] argv[0];
90
-
91
-    mInit = true;
92
-    return 0;
93
-}
94
-
95
-void WindowGLUT::eventHandling() {
96
-    assert(mInit == true);
97
-
98
-    glutMainLoopEvent();
99
-
100
-    UI::eventsFinished();
101
-}
102
-
103
-void WindowGLUT::setTextInput(bool on) {
104
-    assert(mInit == true);
105
-    mTextInput = on;
106
-}
107
-
108
-void WindowGLUT::swapBuffersGL() {
109
-    assert(mInit == true);
110
-    glutSwapBuffers();
111
-}
112
-
113
-void WindowGLUT::reshapeCallback(int width, int height) {
114
-    getWindow().resizeGL();
115
-}
116
-
117
-// Note that the escape, backspace, and delete keys are generated as an ASCII character.
118
-void WindowGLUT::keyboardCallback(unsigned char key, int x, int y) {
119
-    if (getWindow().getTextInput()) {
120
-        if ((key >= ' ') && (key <= '~')) {
121
-            char s[2] = { static_cast<char>(key), '\0' };
122
-            UI::handleText(s, false);
123
-        }
124
-    }
125
-
126
-    KeyboardButton b = convertAsciiButton(key);
127
-    UI::handleKeyboard(b, true);
128
-}
129
-
130
-void WindowGLUT::keyboardUpCallback(unsigned char key, int x, int y) {
131
-    KeyboardButton b = convertAsciiButton(key);
132
-    UI::handleKeyboard(b, false);
133
-}
134
-
135
-void WindowGLUT::specialCallback(int key, int x, int y) {
136
-    KeyboardButton b = convertKeyCode(key);
137
-    UI::handleKeyboard(b, true);
138
-}
139
-
140
-void WindowGLUT::specialUpCallback(int key, int x, int y) {
141
-    KeyboardButton b = convertKeyCode(key);
142
-    UI::handleKeyboard(b, false);
143
-}
144
-
145
-void WindowGLUT::mouseCallback(int button, int state, int x, int y) {
146
-    KeyboardButton b;
147
-
148
-    switch (button) {
149
-        case GLUT_LEFT_BUTTON:
150
-            b = leftmouseKey;
151
-            break;
152
-
153
-        case GLUT_RIGHT_BUTTON:
154
-            b = rightmouseKey;
155
-            break;
156
-
157
-        case GLUT_MIDDLE_BUTTON:
158
-            b = middlemouseKey;
159
-            break;
160
-
161
-        default:
162
-            b = unknownKey;
163
-            break;
164
-    }
165
-
166
-    UI::handleMouseClick(x, y, b, (state == GLUT_UP));
167
-}
168
-
169
-// The x and y callback parameters indicate the mouse location in window relative coordinates.
170
-void WindowGLUT::motionCallback(int x, int y) {
171
-    int xrel = x - lastMouseX;
172
-    int yrel = y - lastMouseY;
173
-    UI::handleMouseMotion(xrel, yrel, x, y);
174
-    lastMouseX = x;
175
-    lastMouseY = y;
176
-
177
-    if (getWindow().getMousegrab()) {
178
-        lastMouseX = getWindow().getWidth() / 2;
179
-        lastMouseY = getWindow().getHeight() / 2;
180
-        glutWarpPointer(lastMouseX, lastMouseY);
181
-    }
182
-}
183
-
184
-void WindowGLUT::mouseWheelCallback(int wheel, int direction, int x, int y) {
185
-    int xrel = 0, yrel = 0;
186
-
187
-    if (wheel == 0)
188
-        yrel = direction;
189
-    else
190
-        xrel = direction;
191
-
192
-    UI::handleMouseScroll(xrel, yrel);
193
-}
194
-
195
-KeyboardButton WindowGLUT::convertAsciiButton(unsigned char key) {
196
-    // Convert Uppercase to Lowercase
197
-    if ((key >= 'A') && (key <= 'Z'))
198
-        key = key - 'A' + 'a';
199
-
200
-    // Alphanumerics can be returned as is
201
-    if (((key >= '0') && (key <= '9'))
202
-        || ((key >= 'a') && (key <= 'z'))) {
203
-        return static_cast<KeyboardButton>(key);
204
-    }
205
-
206
-    //! \fixme GLUT requires keyboard layout? Currently US is hard coded
207
-    switch (key) {
208
-        case ' ':
209
-            return spaceKey;
210
-
211
-        case '!':
212
-            return oneKey;
213
-
214
-        case '@':
215
-            return twoKey;
216
-
217
-        case '#':
218
-            return threeKey;
219
-
220
-        case '$':
221
-            return fourKey;
222
-
223
-        case '%':
224
-            return fiveKey;
225
-
226
-        case '^':
227
-            return sixKey;
228
-
229
-        case '&':
230
-            return sevenKey;
231
-
232
-        case '*':
233
-            return eightKey;
234
-
235
-        case '(':
236
-            return nineKey;
237
-
238
-        case ')':
239
-            return zeroKey;
240
-
241
-        case '"':
242
-        case '\'':
243
-            return quoteKey;
244
-
245
-        case '+':
246
-        case '=':
247
-            return equalsKey;
248
-
249
-        case ',':
250
-        case '<':
251
-            return commaKey;
252
-
253
-        case '-':
254
-        case '_':
255
-            return minusKey;
256
-
257
-        case '.':
258
-        case '>':
259
-            return dotKey;
260
-
261
-        case '/':
262
-        case '?':
263
-            return slashKey;
264
-
265
-        case ':':
266
-        case ';':
267
-            return semicolonKey;
268
-
269
-        case '[':
270
-        case '{':
271
-            return leftbracketKey;
272
-
273
-        case ']':
274
-        case '}':
275
-            return rightbracketKey;
276
-
277
-        case '\\':
278
-        case '|':
279
-            return backslashKey;
280
-
281
-        case '`':
282
-        case '~':
283
-            return backquoteKey;
284
-
285
-        case '\t':
286
-            return tabKey;
287
-
288
-        case 8: // Backspace
289
-            return backspaceKey;
290
-
291
-        case '\r':
292
-        case '\n':
293
-            return enterKey;
294
-
295
-        case 27: // Escape
296
-            return escapeKey;
297
-
298
-        default:
299
-            return unknownKey;
300
-    }
301
-}
302
-
303
-KeyboardButton WindowGLUT::convertKeyCode(int key) {
304
-    switch (key) {
305
-        case GLUT_KEY_F1:
306
-            return f1Key;
307
-
308
-        case GLUT_KEY_F2:
309
-            return f2Key;
310
-
311
-        case GLUT_KEY_F3:
312
-            return f3Key;
313
-
314
-        case GLUT_KEY_F4:
315
-            return f4Key;
316
-
317
-        case GLUT_KEY_F5:
318
-            return f5Key;
319
-
320
-        case GLUT_KEY_F6:
321
-            return f6Key;
322
-
323
-        case GLUT_KEY_F7:
324
-            return f7Key;
325
-
326
-        case GLUT_KEY_F8:
327
-            return f8Key;
328
-
329
-        case GLUT_KEY_F9:
330
-            return f9Key;
331
-
332
-        case GLUT_KEY_F10:
333
-            return f10Key;
334
-
335
-        case GLUT_KEY_F11:
336
-            return f11Key;
337
-
338
-        case GLUT_KEY_F12:
339
-            return f12Key;
340
-
341
-        case GLUT_KEY_LEFT:
342
-            return leftKey;
343
-
344
-        case GLUT_KEY_UP:
345
-            return upKey;
346
-
347
-        case GLUT_KEY_RIGHT:
348
-            return rightKey;
349
-
350
-        case GLUT_KEY_DOWN:
351
-            return downKey;
352
-
353
-        case GLUT_KEY_PAGE_UP:
354
-            return pageupKey;
355
-
356
-        case GLUT_KEY_PAGE_DOWN:
357
-            return pagedownKey;
358
-
359
-        case GLUT_KEY_HOME:
360
-            return homeKey;
361
-
362
-        case GLUT_KEY_END:
363
-            return endKey;
364
-
365
-        case GLUT_KEY_INSERT:
366
-            return insertKey;
367
-
368
-        default:
369
-            return unknownKey;
370
-    }
371
-}
372
-

Loading…
Cancel
Save