summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/being.cpp3
-rw-r--r--src/engine.cpp2
-rw-r--r--src/graphics.cpp174
-rw-r--r--src/graphics.h13
5 files changed, 97 insertions, 101 deletions
diff --git a/ChangeLog b/ChangeLog
index 90b71087..dd98dd60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-14 Björn Steinbrink <B.Steinbrink@gmx.de>
+
+ * src/being.cpp, src/engine.cpp, src/graphics.cpp, src/graphics.h: Made
+ the wrapper functions in the Graphics class conditional on whether we
+ compile with OpenGL support.
+
2005-08-13 Björn Steinbrink <B.Steinbrink@gmx.de>
* src/Makefile.am, src/being.cpp, src/being.h, src/configlistener.cpp,
diff --git a/src/being.cpp b/src/being.cpp
index 04a07152..a0b9a88c 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -23,9 +23,10 @@
#include "being.h"
-#include <iostream>
#include <sstream>
+#include <guichan/imagefont.hpp>
+
#include "game.h"
#include "graphics.h"
#include "log.h"
diff --git a/src/engine.cpp b/src/engine.cpp
index a14b04f6..1f255456 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -25,6 +25,8 @@
#include <sstream>
+#include <guichan/imagefont.hpp>
+
#include <guichan/widgets/label.hpp>
#include "being.h"
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 5c7e01b3..cd80fd3e 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -23,7 +23,9 @@
#include "graphics.h"
+#ifdef USE_OPENGL
#include <guichan/imagefont.hpp>
+#endif
#include "log.h"
#include "main.h"
@@ -137,103 +139,6 @@ bool Graphics::setFullscreen(bool fs)
mScreen->format->BitsPerPixel, fs, mHWAccel);
}
-void Graphics::_beginDraw()
-{
-#ifdef USE_OPENGL
- if (useOpenGL) {
- gcn::OpenGLGraphics::_beginDraw();
- } else
-#endif
- {
- gcn::SDLGraphics::_beginDraw();
- }
-}
-
-void Graphics::_endDraw()
-{
-#ifdef USE_OPENGL
- if (useOpenGL) {
- gcn::OpenGLGraphics::_endDraw();
- } else
-#endif
- {
- gcn::SDLGraphics::_endDraw();
- }
-}
-
-void Graphics::setFont(gcn::ImageFont *font)
-{
- if (!useOpenGL) {
- gcn::SDLGraphics::setFont(font);
- }
-#ifdef USE_OPENGL
- else {
- gcn::OpenGLGraphics::setFont(font);
- }
-#endif
-}
-
-void Graphics::drawText(const std::string &text,
- int x, int y, unsigned int alignment)
-{
- if (!useOpenGL) {
- gcn::SDLGraphics::drawText(text, x, y, alignment);
- }
-#ifdef USE_OPENGL
- else {
- gcn::OpenGLGraphics::drawText(text, x, y, alignment);
- }
-#endif
-}
-
-void Graphics::setColor(gcn::Color color)
-{
- if (!useOpenGL) {
- gcn::SDLGraphics::setColor(color);
- }
-#ifdef USE_OPENGL
- else {
- gcn::OpenGLGraphics::setColor(color);
- }
-#endif
-}
-
-void Graphics::popClipArea()
-{
- if (!useOpenGL) {
- gcn::SDLGraphics::popClipArea();
- }
-#ifdef USE_OPENGL
- else {
- gcn::OpenGLGraphics::popClipArea();
- }
-#endif
-}
-
-bool Graphics::pushClipArea(gcn::Rectangle area)
-{
- if (!useOpenGL) {
- return gcn::SDLGraphics::pushClipArea(area);
- }
-#ifdef USE_OPENGL
- else {
- return gcn::OpenGLGraphics::pushClipArea(area);
- }
-#endif
-}
-
-void Graphics::fillRectangle(const gcn::Rectangle &rectangle)
-{
- if (!useOpenGL) {
- gcn::SDLGraphics::fillRectangle(rectangle);
- }
-#ifdef USE_OPENGL
- else {
- gcn::OpenGLGraphics::fillRectangle(rectangle);
- }
-#endif
-}
-
int Graphics::getWidth()
{
return mScreen->w;
@@ -343,3 +248,78 @@ void Graphics::updateScreen()
SDL_Delay(10);
}
}
+
+#ifdef USE_OPENGL
+void Graphics::_beginDraw()
+{
+ if (useOpenGL) {
+ gcn::OpenGLGraphics::_beginDraw();
+ } else {
+ gcn::SDLGraphics::_beginDraw();
+ }
+}
+
+void Graphics::_endDraw()
+{
+ if (useOpenGL) {
+ gcn::OpenGLGraphics::_endDraw();
+ } else {
+ gcn::SDLGraphics::_endDraw();
+ }
+}
+
+void Graphics::setFont(gcn::ImageFont *font)
+{
+ if (!useOpenGL) {
+ gcn::SDLGraphics::setFont(font);
+ } else {
+ gcn::OpenGLGraphics::setFont(font);
+ }
+}
+
+void Graphics::drawText(const std::string &text,
+ int x, int y, unsigned int alignment)
+{
+ if (!useOpenGL) {
+ gcn::SDLGraphics::drawText(text, x, y, alignment);
+ } else {
+ gcn::OpenGLGraphics::drawText(text, x, y, alignment);
+ }
+}
+
+void Graphics::setColor(gcn::Color color)
+{
+ if (!useOpenGL) {
+ gcn::SDLGraphics::setColor(color);
+ } else {
+ gcn::OpenGLGraphics::setColor(color);
+ }
+}
+
+void Graphics::popClipArea()
+{
+ if (!useOpenGL) {
+ gcn::SDLGraphics::popClipArea();
+ } else {
+ gcn::OpenGLGraphics::popClipArea();
+ }
+}
+
+bool Graphics::pushClipArea(gcn::Rectangle area)
+{
+ if (!useOpenGL) {
+ return gcn::SDLGraphics::pushClipArea(area);
+ } else {
+ return gcn::OpenGLGraphics::pushClipArea(area);
+ }
+}
+
+void Graphics::fillRectangle(const gcn::Rectangle &rectangle)
+{
+ if (!useOpenGL) {
+ gcn::SDLGraphics::fillRectangle(rectangle);
+ } else {
+ gcn::OpenGLGraphics::fillRectangle(rectangle);
+ }
+}
+#endif
diff --git a/src/graphics.h b/src/graphics.h
index 46dfef89..ce4a281f 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -65,9 +65,6 @@ public gcn::SDLGraphics {
*/
bool setFullscreen(bool fs);
- void _beginDraw();
- void _endDraw();
-
void drawImage(Image *image, int x, int y);
void drawImagePattern(Image *image, int x, int y, int w, int h);
@@ -107,6 +104,15 @@ public gcn::SDLGraphics {
*/
int getHeight();
+ /*
+ * Wrapper functions to delegate calls to the right base-class when we
+ * compile with OpenGL support and thus have two gcn::Graphics
+ * base-classes.
+ */
+#ifdef USE_OPENGL
+ void _beginDraw();
+ void _endDraw();
+
void setFont(gcn::ImageFont *font);
void drawText(const std::string &text,
@@ -120,6 +126,7 @@ public gcn::SDLGraphics {
bool pushClipArea(gcn::Rectangle area);
void fillRectangle(const gcn::Rectangle &rectangle);
+#endif
private:
SDL_Surface *mScreen;