Selaa lähdekoodia

Minor bugfixes

Thomas Buck 10 vuotta sitten
vanhempi
commit
2c547828ae
11 muutettua tiedostoa jossa 36 lisäystä ja 65 poistoa
  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 Näytä tiedosto

@@ -4,6 +4,10 @@
4 4
 
5 5
     [ 20141008 ]
6 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 12
     [ 20141007 ]
9 13
     * Set all RunTime vars to sensible defaults, so OpenRaider can try to start

+ 1
- 0
TODO.md Näytä tiedosto

@@ -16,6 +16,7 @@
16 16
 
17 17
 * Screenshots are sometimes not written, sometimes distorted?
18 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 21
 ## Cmake
21 22
 

+ 1
- 0
include/UI.h Näytä tiedosto

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

+ 5
- 5
include/Window.h Näytä tiedosto

@@ -22,7 +22,7 @@ public:
22 22
 
23 23
     virtual void setMousegrab(bool grab) = 0;
24 24
 
25
-    virtual bool getMousegrab() = 0;
25
+    virtual bool getMousegrab() { return mMousegrab; }
26 26
 
27 27
     virtual int initialize() = 0;
28 28
 
@@ -30,13 +30,13 @@ public:
30 30
 
31 31
     virtual void setTextInput(bool on) = 0;
32 32
 
33
-    virtual bool getTextInput() = 0;
33
+    virtual bool getTextInput() { return mTextInput; }
34 34
 
35 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 41
     virtual int initializeGL();
42 42
 
@@ -46,7 +46,7 @@ public:
46 46
 
47 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 50
                         float lookAtX, float lookAtY, float lookAtZ,
51 51
                         float upX, float upY, float upZ);
52 52
 

+ 0
- 4
include/WindowGLUT.h Näytä tiedosto

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

+ 0
- 4
include/WindowSDL.h Näytä tiedosto

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

+ 1
- 1
src/Render.cpp Näytä tiedosto

@@ -267,7 +267,7 @@ void Render::display()
267 267
     getCamera().update();
268 268
     getCamera().getTarget(atPos);
269 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 272
     // Update view volume for vising
273 273
     updateViewVolume();

+ 7
- 2
src/UI.cpp Näytä tiedosto

@@ -26,6 +26,7 @@ bool UI::visible = false;
26 26
 unsigned int UI::fontTex;
27 27
 std::string UI::iniFilename;
28 28
 std::string UI::logFilename;
29
+bool UI::metaKeyIsActive = false;
29 30
 
30 31
 std::list<std::tuple<KeyboardButton, bool>> UI::keyboardEvents;
31 32
 std::list<std::tuple<unsigned int, unsigned int, KeyboardButton, bool>> UI::clickEvents;
@@ -72,7 +73,7 @@ int UI::initialize() {
72 73
     void* tex_data = stbi_load_from_memory((const unsigned char*)png_data,
73 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 77
     fontTex = getTextureManager().loadBufferSlot((unsigned char *)tex_data,
77 78
             tex_x, tex_y, RGBA, 32, 0, false);
78 79
 
@@ -141,7 +142,8 @@ void UI::eventsFinished() {
141 142
                     getMenu().setVisible(!getMenu().isVisible());
142 143
                     visible = false;
143 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,6 +203,9 @@ void UI::handleKeyboard(KeyboardButton key, bool pressed) {
201 203
     io.KeyShift = io.KeysDown[leftshiftKey] | io.KeysDown[rightshiftKey];
202 204
 
203 205
     keyboardEvents.push_back(std::make_tuple(key, pressed));
206
+
207
+    if ((key == leftguiKey) || (key == rightguiKey))
208
+        metaKeyIsActive = pressed;
204 209
 }
205 210
 
206 211
 void UI::handleText(char *text, bool notFinished) {

+ 0
- 8
src/Window.cpp Näytä tiedosto

@@ -15,14 +15,6 @@
15 15
 #include "utils/strings.h"
16 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 18
 int Window::initializeGL() {
27 19
     // Print driver support information
28 20
     //printf("GL Vendor  : %s\n", glGetString(GL_VENDOR));

+ 7
- 16
src/WindowGLUT.cpp Näytä tiedosto

@@ -15,6 +15,8 @@
15 15
 #include "utils/strings.h"
16 16
 #include "WindowGLUT.h"
17 17
 
18
+//! \todo Modifier keys currently don't create keyboard events...
19
+
18 20
 static int lastMouseX = 0;
19 21
 static int lastMouseY = 0;
20 22
 
@@ -61,10 +63,6 @@ void WindowGLUT::setMousegrab(bool grab) {
61 63
     }
62 64
 }
63 65
 
64
-bool WindowGLUT::getMousegrab() {
65
-    return mMousegrab;
66
-}
67
-
68 66
 int WindowGLUT::initialize() {
69 67
     assert(mInit == false);
70 68
 
@@ -105,11 +103,6 @@ void WindowGLUT::setTextInput(bool on) {
105 103
     mTextInput = on;
106 104
 }
107 105
 
108
-bool WindowGLUT::getTextInput() {
109
-    assert(mInit == true);
110
-    return mTextInput;
111
-}
112
-
113 106
 void WindowGLUT::swapBuffersGL() {
114 107
     assert(mInit == true);
115 108
     glutSwapBuffers();
@@ -126,17 +119,15 @@ void WindowGLUT::keyboardCallback(unsigned char key, int x, int y) {
126 119
             char s[2] = { static_cast<char>(key), '\0' };
127 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 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 133
 void WindowGLUT::specialCallback(int key, int x, int y) {

+ 10
- 25
src/WindowSDL.cpp Näytä tiedosto

@@ -5,8 +5,7 @@
5 5
  * \author xythobuz
6 6
  */
7 7
 
8
-#include <cstdio>
9
-#include <ctime>
8
+#include <iostream>
10 9
 
11 10
 #include "global.h"
12 11
 #include "RunTime.h"
@@ -71,15 +70,11 @@ void WindowSDL::setMousegrab(bool grab) {
71 70
     }
72 71
 }
73 72
 
74
-bool WindowSDL::getMousegrab() {
75
-    return mMousegrab;
76
-}
77
-
78 73
 int WindowSDL::initialize() {
79 74
     assert(mInit == false);
80 75
 
81 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 78
         return -1;
84 79
     }
85 80
 
@@ -87,35 +82,31 @@ int WindowSDL::initialize() {
87 82
     if (mFullscreen)
88 83
         flags |= SDL_WINDOW_FULLSCREEN;
89 84
 
90
-    mInit = true;
91
-    setMousegrab(mMousegrab);
92
-
93 85
     if ((SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5) != 0)
94 86
         || (SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5) != 0)
95 87
         || (SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5) != 0)
96 88
         || (SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16) != 0)
97 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 94
     mWindow = SDL_CreateWindow(VERSION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
104 95
                 mWidth, mHeight, flags);
105 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 101
     mGLContext = SDL_GL_CreateContext(mWindow);
112 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 108
     setSize(mWidth, mHeight);
109
+    setMousegrab(mMousegrab);
119 110
 
120 111
     return 0;
121 112
 }
@@ -455,14 +446,8 @@ void WindowSDL::setTextInput(bool on) {
455 446
         SDL_StopTextInput();
456 447
 }
457 448
 
458
-bool WindowSDL::getTextInput() {
459
-    assert(mInit == true);
460
-    return mTextInput;
461
-}
462
-
463 449
 void WindowSDL::swapBuffersGL() {
464 450
     assert(mInit == true);
465
-
466 451
     SDL_GL_SwapWindow(mWindow);
467 452
 }
468 453
 

Loading…
Peruuta
Tallenna