Thomas Buck 9 anni fa
parent
commit
2c547828ae
11 ha cambiato i file con 36 aggiunte e 65 eliminazioni
  1. 4
    0
      ChangeLog.md
  2. 1
    0
      TODO.md
  3. 1
    0
      include/UI.h
  4. 5
    5
      include/Window.h
  5. 0
    4
      include/WindowGLUT.h
  6. 0
    4
      include/WindowSDL.h
  7. 1
    1
      src/Render.cpp
  8. 7
    2
      src/UI.cpp
  9. 0
    8
      src/Window.cpp
  10. 7
    16
      src/WindowGLUT.cpp
  11. 10
    25
      src/WindowSDL.cpp

+ 4
- 0
ChangeLog.md Vedi File

4
 
4
 
5
     [ 20141008 ]
5
     [ 20141008 ]
6
     * Added freeGLUT windowing system to use if SDL2 is not available. Not yet working 100%.
6
     * Added freeGLUT windowing system to use if SDL2 is not available. Not yet working 100%.
7
+    * Moved unnecessarily duplicated code to Window base class
8
+    * Fixed Bug in new GLUT implementation: Console now working properly
9
+    * Fixed Bug where the debug overlay was flashing for a frame if it’s key is used in
10
+      combination with a modifier (in this case CMD + Q to quit)
7
 
11
 
8
     [ 20141007 ]
12
     [ 20141007 ]
9
     * Set all RunTime vars to sensible defaults, so OpenRaider can try to start
13
     * Set all RunTime vars to sensible defaults, so OpenRaider can try to start

+ 1
- 0
TODO.md Vedi File

16
 
16
 
17
 * Screenshots are sometimes not written, sometimes distorted?
17
 * Screenshots are sometimes not written, sometimes distorted?
18
     * Seems to happen if OpenRaider.ini sets a resolution larger than the window can be
18
     * Seems to happen if OpenRaider.ini sets a resolution larger than the window can be
19
+* When the freeGLUT windowing interface is used, the first pressed button seems to be repeated
19
 
20
 
20
 ## Cmake
21
 ## Cmake
21
 
22
 

+ 1
- 0
include/UI.h Vedi File

38
     static unsigned int fontTex;
38
     static unsigned int fontTex;
39
     static std::string iniFilename;
39
     static std::string iniFilename;
40
     static std::string logFilename;
40
     static std::string logFilename;
41
+    static bool metaKeyIsActive;
41
 
42
 
42
     static std::list<std::tuple<KeyboardButton, bool>> keyboardEvents;
43
     static std::list<std::tuple<KeyboardButton, bool>> keyboardEvents;
43
     static std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> clickEvents;
44
     static std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> clickEvents;

+ 5
- 5
include/Window.h Vedi File

22
 
22
 
23
     virtual void setMousegrab(bool grab) = 0;
23
     virtual void setMousegrab(bool grab) = 0;
24
 
24
 
25
-    virtual bool getMousegrab() = 0;
25
+    virtual bool getMousegrab() { return mMousegrab; }
26
 
26
 
27
     virtual int initialize() = 0;
27
     virtual int initialize() = 0;
28
 
28
 
30
 
30
 
31
     virtual void setTextInput(bool on) = 0;
31
     virtual void setTextInput(bool on) = 0;
32
 
32
 
33
-    virtual bool getTextInput() = 0;
33
+    virtual bool getTextInput() { return mTextInput; }
34
 
34
 
35
     virtual void swapBuffersGL() = 0;
35
     virtual void swapBuffersGL() = 0;
36
 
36
 
37
-    virtual unsigned int getWidth();
37
+    virtual unsigned int getWidth() { return mWidth; }
38
 
38
 
39
-    virtual unsigned int getHeight();
39
+    virtual unsigned int getHeight() { return mHeight; }
40
 
40
 
41
     virtual int initializeGL();
41
     virtual int initializeGL();
42
 
42
 
46
 
46
 
47
     virtual void glExit2D();
47
     virtual void glExit2D();
48
 
48
 
49
-    virtual void lookAt(float eyeX, float eyeY, float eyeZ,
49
+    static void lookAt(float eyeX, float eyeY, float eyeZ,
50
                         float lookAtX, float lookAtY, float lookAtZ,
50
                         float lookAtX, float lookAtY, float lookAtZ,
51
                         float upX, float upY, float upZ);
51
                         float upX, float upY, float upZ);
52
 
52
 

+ 0
- 4
include/WindowGLUT.h Vedi File

24
 
24
 
25
     virtual void setMousegrab(bool grab);
25
     virtual void setMousegrab(bool grab);
26
 
26
 
27
-    virtual bool getMousegrab();
28
-
29
     virtual int initialize();
27
     virtual int initialize();
30
 
28
 
31
     virtual void eventHandling();
29
     virtual void eventHandling();
32
 
30
 
33
     virtual void setTextInput(bool on);
31
     virtual void setTextInput(bool on);
34
 
32
 
35
-    virtual bool getTextInput();
36
-
37
     virtual void swapBuffersGL();
33
     virtual void swapBuffersGL();
38
 
34
 
39
 private:
35
 private:

+ 0
- 4
include/WindowSDL.h Vedi File

34
 
34
 
35
     virtual void setMousegrab(bool grab);
35
     virtual void setMousegrab(bool grab);
36
 
36
 
37
-    virtual bool getMousegrab();
38
-
39
     virtual int initialize();
37
     virtual int initialize();
40
 
38
 
41
     virtual void eventHandling();
39
     virtual void eventHandling();
42
 
40
 
43
     virtual void setTextInput(bool on);
41
     virtual void setTextInput(bool on);
44
 
42
 
45
-    virtual bool getTextInput();
46
-
47
     virtual void swapBuffersGL();
43
     virtual void swapBuffersGL();
48
 
44
 
49
 private:
45
 private:

+ 1
- 1
src/Render.cpp Vedi File

267
     getCamera().update();
267
     getCamera().update();
268
     getCamera().getTarget(atPos);
268
     getCamera().getTarget(atPos);
269
     // Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
269
     // Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
270
-    getWindow().lookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0f, -1.0f, 0.0f);
270
+    Window::lookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0f, -1.0f, 0.0f);
271
 
271
 
272
     // Update view volume for vising
272
     // Update view volume for vising
273
     updateViewVolume();
273
     updateViewVolume();

+ 7
- 2
src/UI.cpp Vedi File

26
 unsigned int UI::fontTex;
26
 unsigned int UI::fontTex;
27
 std::string UI::iniFilename;
27
 std::string UI::iniFilename;
28
 std::string UI::logFilename;
28
 std::string UI::logFilename;
29
+bool UI::metaKeyIsActive = false;
29
 
30
 
30
 std::list<std::tuple<KeyboardButton, bool>> UI::keyboardEvents;
31
 std::list<std::tuple<KeyboardButton, bool>> UI::keyboardEvents;
31
 std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> UI::clickEvents;
32
 std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> UI::clickEvents;
72
     void* tex_data = stbi_load_from_memory((const unsigned char*)png_data,
73
     void* tex_data = stbi_load_from_memory((const unsigned char*)png_data,
73
             (int)png_size, &tex_x, &tex_y, &tex_comp, 0);
74
             (int)png_size, &tex_x, &tex_y, &tex_comp, 0);
74
 
75
 
75
-     //! \fixme TODO use proper slot
76
+     //! \fixme TODO use proper texture slot
76
     fontTex = getTextureManager().loadBufferSlot((unsigned char *)tex_data,
77
     fontTex = getTextureManager().loadBufferSlot((unsigned char *)tex_data,
77
             tex_x, tex_y, RGBA, 32, 0, false);
78
             tex_x, tex_y, RGBA, 32, 0, false);
78
 
79
 
141
                     getMenu().setVisible(!getMenu().isVisible());
142
                     getMenu().setVisible(!getMenu().isVisible());
142
                     visible = false;
143
                     visible = false;
143
                 } else if (getRunTime().getKeyBinding(debugAction) == std::get<0>(i)) {
144
                 } else if (getRunTime().getKeyBinding(debugAction) == std::get<0>(i)) {
144
-                    visible = !visible;
145
+                    if (!metaKeyIsActive)
146
+                        visible = !visible;
145
                 }
147
                 }
146
             }
148
             }
147
 
149
 
201
     io.KeyShift = io.KeysDown[leftshiftKey] | io.KeysDown[rightshiftKey];
203
     io.KeyShift = io.KeysDown[leftshiftKey] | io.KeysDown[rightshiftKey];
202
 
204
 
203
     keyboardEvents.push_back(std::make_tuple(key, pressed));
205
     keyboardEvents.push_back(std::make_tuple(key, pressed));
206
+
207
+    if ((key == leftguiKey) || (key == rightguiKey))
208
+        metaKeyIsActive = pressed;
204
 }
209
 }
205
 
210
 
206
 void UI::handleText(char *text, bool notFinished) {
211
 void UI::handleText(char *text, bool notFinished) {

+ 0
- 8
src/Window.cpp Vedi File

15
 #include "utils/strings.h"
15
 #include "utils/strings.h"
16
 #include "Window.h"
16
 #include "Window.h"
17
 
17
 
18
-unsigned int Window::getWidth() {
19
-    return mWidth;
20
-}
21
-
22
-unsigned int Window::getHeight() {
23
-    return mHeight;
24
-}
25
-
26
 int Window::initializeGL() {
18
 int Window::initializeGL() {
27
     // Print driver support information
19
     // Print driver support information
28
     //printf("GL Vendor  : %s\n", glGetString(GL_VENDOR));
20
     //printf("GL Vendor  : %s\n", glGetString(GL_VENDOR));

+ 7
- 16
src/WindowGLUT.cpp Vedi File

15
 #include "utils/strings.h"
15
 #include "utils/strings.h"
16
 #include "WindowGLUT.h"
16
 #include "WindowGLUT.h"
17
 
17
 
18
+//! \todo Modifier keys currently don't create keyboard events...
19
+
18
 static int lastMouseX = 0;
20
 static int lastMouseX = 0;
19
 static int lastMouseY = 0;
21
 static int lastMouseY = 0;
20
 
22
 
61
     }
63
     }
62
 }
64
 }
63
 
65
 
64
-bool WindowGLUT::getMousegrab() {
65
-    return mMousegrab;
66
-}
67
-
68
 int WindowGLUT::initialize() {
66
 int WindowGLUT::initialize() {
69
     assert(mInit == false);
67
     assert(mInit == false);
70
 
68
 
105
     mTextInput = on;
103
     mTextInput = on;
106
 }
104
 }
107
 
105
 
108
-bool WindowGLUT::getTextInput() {
109
-    assert(mInit == true);
110
-    return mTextInput;
111
-}
112
-
113
 void WindowGLUT::swapBuffersGL() {
106
 void WindowGLUT::swapBuffersGL() {
114
     assert(mInit == true);
107
     assert(mInit == true);
115
     glutSwapBuffers();
108
     glutSwapBuffers();
126
             char s[2] = { static_cast<char>(key), '\0' };
119
             char s[2] = { static_cast<char>(key), '\0' };
127
             UI::handleText(s, false);
120
             UI::handleText(s, false);
128
         }
121
         }
129
-    } else {
130
-        KeyboardButton b = convertAsciiButton(key);
131
-        UI::handleKeyboard(b, true);
132
     }
122
     }
123
+
124
+    KeyboardButton b = convertAsciiButton(key);
125
+    UI::handleKeyboard(b, true);
133
 }
126
 }
134
 
127
 
135
 void WindowGLUT::keyboardUpCallback(unsigned char key, int x, int y) {
128
 void WindowGLUT::keyboardUpCallback(unsigned char key, int x, int y) {
136
-    if (!getWindow().getTextInput()) {
137
-        KeyboardButton b = convertAsciiButton(key);
138
-        UI::handleKeyboard(b, false);
139
-    }
129
+    KeyboardButton b = convertAsciiButton(key);
130
+    UI::handleKeyboard(b, false);
140
 }
131
 }
141
 
132
 
142
 void WindowGLUT::specialCallback(int key, int x, int y) {
133
 void WindowGLUT::specialCallback(int key, int x, int y) {

+ 10
- 25
src/WindowSDL.cpp Vedi File

5
  * \author xythobuz
5
  * \author xythobuz
6
  */
6
  */
7
 
7
 
8
-#include <cstdio>
9
-#include <ctime>
8
+#include <iostream>
10
 
9
 
11
 #include "global.h"
10
 #include "global.h"
12
 #include "RunTime.h"
11
 #include "RunTime.h"
71
     }
70
     }
72
 }
71
 }
73
 
72
 
74
-bool WindowSDL::getMousegrab() {
75
-    return mMousegrab;
76
-}
77
-
78
 int WindowSDL::initialize() {
73
 int WindowSDL::initialize() {
79
     assert(mInit == false);
74
     assert(mInit == false);
80
 
75
 
81
     if (SDL_Init(SUBSYSTEMS_USED) != 0) {
76
     if (SDL_Init(SUBSYSTEMS_USED) != 0) {
82
-        printf("SDL_Init Error: %s\n", SDL_GetError());
77
+        std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
83
         return -1;
78
         return -1;
84
     }
79
     }
85
 
80
 
87
     if (mFullscreen)
82
     if (mFullscreen)
88
         flags |= SDL_WINDOW_FULLSCREEN;
83
         flags |= SDL_WINDOW_FULLSCREEN;
89
 
84
 
90
-    mInit = true;
91
-    setMousegrab(mMousegrab);
92
-
93
     if ((SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5) != 0)
85
     if ((SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5) != 0)
94
         || (SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5) != 0)
86
         || (SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5) != 0)
95
         || (SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5) != 0)
87
         || (SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5) != 0)
96
         || (SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16) != 0)
88
         || (SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16) != 0)
97
         || (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) != 0)) {
89
         || (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) != 0)) {
98
-        printf("SDL_GL_SetAttribute Error: %s\n", SDL_GetError());
99
-        mInit = false;
100
-        return -3;
90
+        std::cout << "SDL_GL_SetAttribute Error: " << SDL_GetError() << std::endl;
91
+        return -2;
101
     }
92
     }
102
 
93
 
103
     mWindow = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
94
     mWindow = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
104
                 mWidth, mHeight, flags);
95
                 mWidth, mHeight, flags);
105
     if (mWindow == NULL) {
96
     if (mWindow == NULL) {
106
-        printf("SDL_CreateWindow Error: %s\n", SDL_GetError());
107
-        mInit = false;
108
-        return -4;
97
+        std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
98
+        return -3;
109
     }
99
     }
110
 
100
 
111
     mGLContext = SDL_GL_CreateContext(mWindow);
101
     mGLContext = SDL_GL_CreateContext(mWindow);
112
     if (mGLContext == NULL) {
102
     if (mGLContext == NULL) {
113
-        printf("SDL_GL_CreateContext Error: %s\n", SDL_GetError());
114
-        mInit = false;
115
-        return -5;
103
+        std::cout << "SDL_GL_CreateContext Error: " << SDL_GetError() << std::endl;
104
+        return -4;
116
     }
105
     }
117
 
106
 
107
+    mInit = true;
118
     setSize(mWidth, mHeight);
108
     setSize(mWidth, mHeight);
109
+    setMousegrab(mMousegrab);
119
 
110
 
120
     return 0;
111
     return 0;
121
 }
112
 }
455
         SDL_StopTextInput();
446
         SDL_StopTextInput();
456
 }
447
 }
457
 
448
 
458
-bool WindowSDL::getTextInput() {
459
-    assert(mInit == true);
460
-    return mTextInput;
461
-}
462
-
463
 void WindowSDL::swapBuffersGL() {
449
 void WindowSDL::swapBuffersGL() {
464
     assert(mInit == true);
450
     assert(mInit == true);
465
-
466
     SDL_GL_SwapWindow(mWindow);
451
     SDL_GL_SwapWindow(mWindow);
467
 }
452
 }
468
 
453
 

Loading…
Annulla
Salva