ソースを参照

Started font support

Thomas Buck 11年前
コミット
3b6f0730c6
4個のファイルの変更56行の追加15行の削除
  1. 7
    2
      include/Window.h
  2. 8
    2
      include/WindowSDL.h
  3. 5
    0
      src/OpenRaider.cpp
  4. 36
    11
      src/WindowSDL.cpp

+ 7
- 2
include/Window.h ファイルの表示

14
     char *text;
14
     char *text;
15
     unsigned int x;
15
     unsigned int x;
16
     unsigned int y;
16
     unsigned int y;
17
+    float scale;
17
 } WindowString;
18
 } WindowString;
18
 
19
 
19
 /*!
20
 /*!
39
 
40
 
40
     virtual void eventHandling() = 0;
41
     virtual void eventHandling() = 0;
41
 
42
 
42
-    virtual void writeString(WindowString *s) = 0;
43
-
44
     virtual void delay(clock_t ms) = 0;
43
     virtual void delay(clock_t ms) = 0;
45
 
44
 
46
     virtual void swapBuffersGL() = 0;
45
     virtual void swapBuffersGL() = 0;
47
 
46
 
48
     virtual void resizeGL(unsigned int w, unsigned int h);
47
     virtual void resizeGL(unsigned int w, unsigned int h);
48
+
49
+    virtual void setFont(const char *font) = 0;
50
+
51
+    virtual int initializeFont() = 0;
52
+
53
+    virtual void writeString(WindowString *s) = 0;
49
 };
54
 };
50
 
55
 
51
 #endif
56
 #endif

+ 8
- 2
include/WindowSDL.h ファイルの表示

40
 
40
 
41
     virtual void eventHandling();
41
     virtual void eventHandling();
42
 
42
 
43
-    virtual void writeString(WindowString *s);
44
-
45
     virtual void delay(clock_t ms);
43
     virtual void delay(clock_t ms);
46
 
44
 
47
     virtual void swapBuffersGL();
45
     virtual void swapBuffersGL();
48
 
46
 
47
+    virtual void setFont(const char *font);
48
+
49
+    virtual int initializeFont();
50
+
51
+    virtual void writeString(WindowString *s);
52
+
49
 private:
53
 private:
50
     bool mInit;
54
     bool mInit;
51
     char *mDriver;
55
     char *mDriver;
53
     unsigned int mHeight;
57
     unsigned int mHeight;
54
     bool mFullscreen;
58
     bool mFullscreen;
55
     bool mMousegrab;
59
     bool mMousegrab;
60
+    char *mFont;
61
+    bool mFontInit;
56
 
62
 
57
     SDL_Window *mWindow;      //!< This is the pointer to the SDL surface
63
     SDL_Window *mWindow;      //!< This is the pointer to the SDL surface
58
     SDL_GLContext mGLContext; //!< The OpenGL Context
64
     SDL_GLContext mGLContext; //!< The OpenGL Context

+ 5
- 0
src/OpenRaider.cpp ファイルの表示

42
     assert(mInit == false);
42
     assert(mInit == false);
43
     assert(mRunning == false);
43
     assert(mRunning == false);
44
 
44
 
45
+    // Initialize Windowing
45
     mWindow = new WindowSDL();
46
     mWindow = new WindowSDL();
46
     if (mWindow->initialize() != 0)
47
     if (mWindow->initialize() != 0)
47
         return -1;
48
         return -1;
48
 
49
 
50
+    // Initialize windows font
51
+    if (mWindow->initializeFont() != 0)
52
+        return -2;
53
+
49
     mInit = true;
54
     mInit = true;
50
 
55
 
51
     return 0;
56
     return 0;

+ 36
- 11
src/WindowSDL.cpp ファイルの表示

21
     mHeight = DEFAULT_HEIGHT;
21
     mHeight = DEFAULT_HEIGHT;
22
     mFullscreen = false;
22
     mFullscreen = false;
23
     mMousegrab = false;
23
     mMousegrab = false;
24
+    mFont = NULL;
25
+    mFontInit = false;
24
     mWindow = NULL;
26
     mWindow = NULL;
25
     mGLContext = NULL;
27
     mGLContext = NULL;
28
+
29
+#ifdef WIN32
30
+    setDriver("libGL32.dll");
31
+#elif !defined(__APPLE__)
32
+    setDriver("/usr/lib/libGL.so.1");
33
+#endif
26
 }
34
 }
27
 
35
 
28
 WindowSDL::~WindowSDL() {
36
 WindowSDL::~WindowSDL() {
29
-    if (mDriver)
30
-        delete [] mDriver;
31
-
32
     if (mInit) {
37
     if (mInit) {
33
         SDL_QuitSubSystem(SUBSYSTEMS_USED);
38
         SDL_QuitSubSystem(SUBSYSTEMS_USED);
34
         SDL_Quit();
39
         SDL_Quit();
35
     }
40
     }
41
+
42
+    if (mDriver)
43
+        delete [] mDriver;
36
 }
44
 }
37
 
45
 
38
 void WindowSDL::setDriver(const char *driver) {
46
 void WindowSDL::setDriver(const char *driver) {
174
     }
182
     }
175
 }
183
 }
176
 
184
 
177
-void WindowSDL::writeString(WindowString *s) {
178
-    assert(s != NULL);
179
-    assert(s->text != NULL);
180
-    assert(mInit == true);
181
-
182
-
183
-}
184
-
185
 void WindowSDL::delay(clock_t ms) {
185
 void WindowSDL::delay(clock_t ms) {
186
     assert(mInit == true);
186
     assert(mInit == true);
187
 
187
 
194
     SDL_GL_SwapWindow(mWindow);
194
     SDL_GL_SwapWindow(mWindow);
195
 }
195
 }
196
 
196
 
197
+void WindowSDL::setFont(const char *font) {
198
+    assert(font != NULL);
199
+    assert(font[0] != '\0');
200
+    assert(mFontInit == false);
201
+
202
+    mFont = fullPath(font, 0);
203
+}
204
+
205
+int WindowSDL::initializeFont() {
206
+    assert(mFontInit == false);
207
+    assert(mFont != NULL);
208
+    assert(mFont[0] != '\0');
209
+
210
+    mFontInit = true;
211
+    return 0;
212
+}
213
+
214
+void WindowSDL::writeString(WindowString *s) {
215
+    assert(s != NULL);
216
+    assert(s->text != NULL);
217
+    assert(mInit == true);
218
+
219
+
220
+}
221
+

読み込み中…
キャンセル
保存