瀏覽代碼

Window resizing working

Thomas Buck 10 年之前
父節點
當前提交
1e125794e2
共有 5 個文件被更改,包括 18 次插入5 次删除
  1. 3
    0
      ChangeLog
  2. 7
    0
      include/OpenRaider.h
  3. 1
    1
      include/SDLSystem.h
  4. 4
    3
      src/OpenRaider.cpp
  5. 3
    1
      src/SDLSystem.cpp

+ 3
- 0
ChangeLog 查看文件

@@ -5,6 +5,9 @@
5 5
 
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140312 ]
9
+	* Resizing the window works properly (except for fixed string positions)
10
+
8 11
 	[ 20140311 ]
9 12
 	* Removed empty Camera, Matrix, Particle, Quaternion,
10 13
 	  Vector3d and ViewVolume destructors

+ 7
- 0
include/OpenRaider.h 查看文件

@@ -74,6 +74,13 @@ public:
74 74
     void start();
75 75
 
76 76
     /*!
77
+     * \brief Resizes game window and updated renderer
78
+     * \param width new width
79
+     * \param height new height
80
+     */
81
+    virtual void resize(unsigned int width, unsigned int height);
82
+
83
+    /*!
77 84
      * \brief Mouse motion input
78 85
      * \param x relative x motion
79 86
      * \param y relative y motion

+ 1
- 1
include/SDLSystem.h 查看文件

@@ -86,7 +86,7 @@ public:
86 86
      * \param width new width
87 87
      * \param height new height
88 88
      */
89
-    void resize(unsigned int width, unsigned int height);
89
+    virtual void resize(unsigned int width, unsigned int height);
90 90
 
91 91
     /*!
92 92
      * \brief Start game loop

+ 4
- 3
src/OpenRaider.cpp 查看文件

@@ -3061,17 +3061,14 @@ void OpenRaider::consoleCommand(char *cmd)
3061 3061
         if (rc_command("xga", cmd))
3062 3062
         {
3063 3063
             resize(1024, 768);
3064
-            m_render.Update(1024, 768);
3065 3064
         }
3066 3065
         else if (rc_command("svga", cmd))
3067 3066
         {
3068 3067
             resize(800, 600);
3069
-            m_render.Update(800, 600);
3070 3068
         }
3071 3069
         else if (rc_command("vga", cmd))
3072 3070
         {
3073 3071
             resize(640, 460);
3074
-            m_render.Update(640, 460);
3075 3072
         }
3076 3073
     }
3077 3074
     else if (rc_command("sshot", cmd))
@@ -3172,6 +3169,10 @@ void OpenRaider::consoleCommand(char *cmd)
3172 3169
     }
3173 3170
 }
3174 3171
 
3172
+void OpenRaider::resize(unsigned int width, unsigned int height) {
3173
+    SDLSystem::resize(width, height);
3174
+    m_render.Update(width, height);
3175
+}
3175 3176
 
3176 3177
 void OpenRaider::loadPakFolderRecursive(const char *dir) {
3177 3178
     struct dirent *ep;

+ 3
- 1
src/SDLSystem.cpp 查看文件

@@ -106,6 +106,8 @@ void SDLSystem::resize(unsigned int width, unsigned int height) {
106 106
     m_width = width;
107 107
     m_height = height;
108 108
 
109
+    SDL_SetWindowSize(mWindow, width, height);
110
+
109 111
     // Resize context
110 112
     resizeGL(width, height);
111 113
 }
@@ -316,7 +318,7 @@ void SDLSystem::runGame() {
316 318
                 case SDL_WINDOWEVENT:
317 319
                     switch(event.window.event) {
318 320
                         case SDL_WINDOWEVENT_RESIZED:
319
-                            resizeGL(event.window.data1, event.window.data2);
321
+                            resize(event.window.data1, event.window.data2);
320 322
                             break;
321 323
                     }
322 324
                     break;

Loading…
取消
儲存