浏览代码

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,6 +14,7 @@ typedef struct {
14 14
     char *text;
15 15
     unsigned int x;
16 16
     unsigned int y;
17
+    float scale;
17 18
 } WindowString;
18 19
 
19 20
 /*!
@@ -39,13 +40,17 @@ public:
39 40
 
40 41
     virtual void eventHandling() = 0;
41 42
 
42
-    virtual void writeString(WindowString *s) = 0;
43
-
44 43
     virtual void delay(clock_t ms) = 0;
45 44
 
46 45
     virtual void swapBuffersGL() = 0;
47 46
 
48 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 56
 #endif

+ 8
- 2
include/WindowSDL.h 查看文件

@@ -40,12 +40,16 @@ public:
40 40
 
41 41
     virtual void eventHandling();
42 42
 
43
-    virtual void writeString(WindowString *s);
44
-
45 43
     virtual void delay(clock_t ms);
46 44
 
47 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 53
 private:
50 54
     bool mInit;
51 55
     char *mDriver;
@@ -53,6 +57,8 @@ private:
53 57
     unsigned int mHeight;
54 58
     bool mFullscreen;
55 59
     bool mMousegrab;
60
+    char *mFont;
61
+    bool mFontInit;
56 62
 
57 63
     SDL_Window *mWindow;      //!< This is the pointer to the SDL surface
58 64
     SDL_GLContext mGLContext; //!< The OpenGL Context

+ 5
- 0
src/OpenRaider.cpp 查看文件

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

+ 36
- 11
src/WindowSDL.cpp 查看文件

@@ -21,18 +21,26 @@ WindowSDL::WindowSDL() {
21 21
     mHeight = DEFAULT_HEIGHT;
22 22
     mFullscreen = false;
23 23
     mMousegrab = false;
24
+    mFont = NULL;
25
+    mFontInit = false;
24 26
     mWindow = NULL;
25 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 36
 WindowSDL::~WindowSDL() {
29
-    if (mDriver)
30
-        delete [] mDriver;
31
-
32 37
     if (mInit) {
33 38
         SDL_QuitSubSystem(SUBSYSTEMS_USED);
34 39
         SDL_Quit();
35 40
     }
41
+
42
+    if (mDriver)
43
+        delete [] mDriver;
36 44
 }
37 45
 
38 46
 void WindowSDL::setDriver(const char *driver) {
@@ -174,14 +182,6 @@ void WindowSDL::eventHandling() {
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 185
 void WindowSDL::delay(clock_t ms) {
186 186
     assert(mInit == true);
187 187
 
@@ -194,3 +194,28 @@ void WindowSDL::swapBuffersGL() {
194 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
+

正在加载...
取消
保存