diff options
author | Benjamin Cohen <bencoh@notk.org> | 2011-11-29 21:46:22 +0100 |
---|---|---|
committer | Benjamin Cohen <bencoh@notk.org> | 2011-11-29 21:46:22 +0100 |
commit | eec305c93536dabd30a1c38cd6270c2bdc8a5e98 (patch) | |
tree | 2bca9294de36fcbeeded9a7a3d84c05837289d40 /MainWindow.cpp | |
parent | 70955a55db7616b77fca0f2acdc3454fb08e71a2 (diff) |
- Add drawString method
- Display "PAUSE" when pausing game
Diffstat (limited to 'MainWindow.cpp')
-rw-r--r-- | MainWindow.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/MainWindow.cpp b/MainWindow.cpp index 13d96a0..f336bc4 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -1,17 +1,8 @@ #include "MainWindow.h" #include "types.h" - #include <iostream> -#ifdef APPLE_NATIVE_GLUT -#include <OpenGL/gl.h> -#include <OpenGL/glu.h> -#include <GLUT/glut.h> -#else -#include <GL/freeglut.h> -#endif - #include <string> #include <iostream> @@ -55,6 +46,26 @@ MainWindow &MainWindow::getInstance() return s_mainWindow; } +void MainWindow::drawString(GLfloat x, GLfloat y, char *text, uint color, TextAlign align) +{ + char *p; + float red, green, blue; + + hex2fColor(color, red, green, blue); + + glLineWidth(3.0); + glPushMatrix(); + glTranslatef(x, y, 0); + glScalef(0.001, 0.001, 0.00); + if (align) + glTranslatef( ((float) align / 2) * glutStrokeLength(GLUT_STROKE_MONO_ROMAN, (const unsigned char *) text), 0, 0); + glColor3f(red, green, blue); + + for (p = text; *p; p++) + glutStrokeCharacter(GLUT_STROKE_MONO_ROMAN, *p); + glPopMatrix(); +} + void MainWindow::onChangeSize(int w, int h) { if (h == 0) @@ -158,6 +169,8 @@ void MainWindow::onRenderScene() { } } } + if (! m_pGame->isRunning()) + drawString(0, -0.02, "PAUSED", 0xffffff, center); } glutSwapBuffers(); |