summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog43
-rw-r--r--src/engine.cpp2
-rw-r--r--src/graphics.cpp40
-rw-r--r--src/graphics.h10
-rw-r--r--src/gui/browserbox.cpp4
-rw-r--r--src/gui/gui.cpp6
-rw-r--r--src/gui/listbox.cpp2
-rw-r--r--src/gui/minimap.cpp2
-rw-r--r--src/gui/progressbar.cpp2
-rw-r--r--src/gui/scrollarea.cpp16
-rw-r--r--src/resources/image.cpp23
-rw-r--r--src/resources/image.h18
12 files changed, 116 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index f118329b..26a7d93a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-07-27 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * src/engine.cpp, src/game.cpp, src/graphics.cpp, src/graphics.h,
+ src/main.cpp, src/gui/browserbox.cpp, src/gui/button.cpp,
+ src/gui/gui.cpp, src/gui/listbox.cpp, src/gui/minimap.cpp,
+ src/gui/playerbox.cpp, src/gui/progressbar.cpp,
+ src/gui/scrollarea.cpp, src/gui/textfield.cpp, src/gui/window.cpp,
+ src/resources/image.cpp, src/resources/image.h,
+ src/resources/mapreader.h: Merged OpenGL/SDL merge patch by Andrej
+ Sinicyn, and his followup patch for fixing SDL-only build.
+
2005-07-27 Björn Steinbrink <B.Steinbrink@gmx.de>
* src/gui/gui.cpp, src/gui/gui.h: Removed continous mouse
@@ -21,38 +32,32 @@
* src/being.cpp, src/engine.cpp: Fixed text and smilies position.
* src/game.cpp: Cleanups.
* src/gui/skill.cpp: Added new skill names.
- * src/main.cpp: Moved sound playback to update screen and changed song.
+ * src/main.cpp: Moved sound playback to update screen and changed song.
2005-07-24 Björn Steinbrink <B.Steinbrink@gmx.de>
* src/game.cpp: Made the key-event handler use switches instead of
if-else.
- * src/gui/gui.cpp:
- * src/gui/gui.h:
- Allow continous movement when holding down the left mouse button.
+ * src/gui/gui.cpp, src/gui/gui.h: Allow continous movement when holding
+ down the left mouse button.
2005-07-23 Björn Steinbrink <B.Steinbrink@gmx.de>
- * src/being.h:
- * src/being.cpp:
- Added a member to keep the current map, restored setDestination.
-
- * src/game.cpp:
- * src/gui/gui.cpp:
- Change calls to Being::setPath() to Being::setDestination().
-
- * src/map.h:
- Add a forward declaration for struct PATH_NODE.
+ * src/being.h, src/being.cpp: Added a member to keep the current map,
+ restored setDestination.
+ * src/game.cpp, src/gui/gui.cpp: Change calls to Being::setPath() to
+ Being::setDestination().
+ * src/map.h: Add a forward declaration for struct PATH_NODE.
2005-07-23 Bjørn Lindeijer <bjorn@lindeijer.nl>
* NEWS: Moved project news here.
* ChangeLog: Started standard ChangeLog file here.
* docs/HACKING.txt: Added info about member naming and ChangeLog
- format.
+ format.
* src/gui/updatewindow.h, src/gui/updatewindow.cpp: Changed member
- names, set a 15 second timeout for connecting to update server and
- restore some doxygen comments, improved size adaption and made the
- window a shorter.
+ names, set a 15 second timeout for connecting to update server and
+ restore some doxygen comments, improved size adaption and made the
+ window a shorter.
* data/graphics/images/login_wallpaper.png: New login wallpaper by
- Momotaro.
+ Momotaro.
diff --git a/src/engine.cpp b/src/engine.cpp
index 1d511e6a..8be62168 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -538,7 +538,9 @@ void Engine::draw()
int squareY = (node.y - camera_y) * 32 - offset_y + 12;
guiGraphics->setColor(gcn::Color(255, 0, 0));
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 8fc60abb..93448c7c 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -50,35 +50,41 @@ Graphics::Graphics(SDL_Surface *screen):
}
// Initialize for drawing
- if (useOpenGL) {
- gcn::OpenGLGraphics::_beginDraw() ;
+ if (!useOpenGL) {
+ gcn::SDLGraphics::_beginDraw();
}
+#ifdef USE_OPENGL
else {
- gcn::SDLGraphics::_beginDraw();
+ gcn::OpenGLGraphics::_beginDraw();
}
+#endif
//_beginDraw();
}
Graphics::~Graphics()
{
// Deinitialize for drawing
- if (useOpenGL) {
- gcn::OpenGLGraphics::_endDraw() ;
+ if (!useOpenGL) {
+ gcn::SDLGraphics::_endDraw();
}
+#ifdef USE_OPENGL
else {
- gcn::SDLGraphics::_endDraw();
+ gcn::OpenGLGraphics::_endDraw();
}
+#endif
//_endDraw();
}
void Graphics::setFont(gcn::ImageFont *font)
{
- if (useOpenGL) {
- gcn::OpenGLGraphics::setFont(font);
+ if (!useOpenGL) {
+ gcn::SDLGraphics::setFont(font);
}
+#ifdef USE_OPENGL
else {
- gcn::SDLGraphics::setFont(font);
+ gcn::OpenGLGraphics::setFont(font);
}
+#endif
}
void Graphics::drawText(const std::string &text,
@@ -86,22 +92,26 @@ void Graphics::drawText(const std::string &text,
int y,
unsigned int alignment)
{
- if (useOpenGL) {
- gcn::OpenGLGraphics::drawText(text, x, y, alignment);
+ if (!useOpenGL) {
+ gcn::SDLGraphics::drawText(text, x, y, alignment);
}
+#ifdef USE_OPENGL
else {
- gcn::SDLGraphics::drawText(text, x, y, alignment);
+ gcn::OpenGLGraphics::drawText(text, x, y, alignment);
}
+#endif
}
void Graphics::setColor(gcn::Color color)
{
- if (useOpenGL) {
- gcn::OpenGLGraphics::setColor(color);
+ if (!useOpenGL) {
+ gcn::SDLGraphics::setColor(color);
}
+#ifdef USE_OPENGL
else {
- gcn::SDLGraphics::setColor(color);
+ gcn::OpenGLGraphics::setColor(color);
}
+#endif
}
int Graphics::getWidth()
diff --git a/src/graphics.h b/src/graphics.h
index a66bb2da..461bb45c 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -26,8 +26,10 @@
#include <guichan/sdl.hpp>
#include <SDL.h>
+#ifdef USE_OPENGL
#include <guichan/opengl.hpp>
#include <SDL_opengl.h>
+#endif
#include <guichan/imagefont.hpp>
#include <guichan/rectangle.hpp>
#include "resources/image.h"
@@ -56,7 +58,11 @@ struct ImageRect {
/**
* A central point of control for graphics.
*/
-class Graphics : public gcn::SDLGraphics, public gcn::OpenGLGraphics {
+class Graphics :
+#ifdef USE_OPENGL
+public gcn::OpenGLGraphics,
+#endif
+public gcn::SDLGraphics {
public:
/**
* Constructor.
@@ -100,7 +106,7 @@ class Graphics : public gcn::SDLGraphics, public gcn::OpenGLGraphics {
/**
* Returns the width of the screen.
*/
- virtual int getWidth();
+ int getWidth();
/**
* Returns the height of the screen.
diff --git a/src/gui/browserbox.cpp b/src/gui/browserbox.cpp
index 56539455..58877b6e 100644
--- a/src/gui/browserbox.cpp
+++ b/src/gui/browserbox.cpp
@@ -210,7 +210,9 @@ void BrowserBox::draw(gcn::Graphics* graphics)
{
graphics->setColor(gcn::Color(BGCOLOR));
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
@@ -223,6 +225,7 @@ void BrowserBox::draw(gcn::Graphics* graphics)
{
graphics->setColor(gcn::Color(HIGHLIGHT));
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(
gcn::Rectangle(
mLinks[mSelectedLink].x1,
@@ -230,6 +233,7 @@ void BrowserBox::draw(gcn::Graphics* graphics)
mLinks[mSelectedLink].x2 - mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y2 - mLinks[mSelectedLink].y1
));
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 1e101c5b..737b880c 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -56,7 +56,9 @@ Gui::Gui(Graphics *graphics):
guiGraphics = graphics;
//setGraphics(graphics);
if (useOpenGL) {
+#ifdef USE_OPENGL
setGraphics((gcn::OpenGLGraphics*)graphics);
+#endif
}
else {
setGraphics((gcn::SDLGraphics*)graphics);
@@ -212,8 +214,10 @@ void Gui::logic()
void Gui::draw()
{
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(guiGraphics)->pushClipArea(guiTop->getDimension());
guiTop->draw((gcn::OpenGLGraphics*)guiGraphics);
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(guiGraphics)->pushClipArea(guiTop->getDimension());
@@ -230,7 +234,9 @@ void Gui::draw()
}
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(guiGraphics)->popClipArea();
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(guiGraphics)->popClipArea();
diff --git a/src/gui/listbox.cpp b/src/gui/listbox.cpp
index bf80589a..3f82fe1b 100644
--- a/src/gui/listbox.cpp
+++ b/src/gui/listbox.cpp
@@ -52,8 +52,10 @@ void ListBox::draw(gcn::Graphics *graphics)
{
if (i == mSelected) {
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(
gcn::Rectangle(0, y, getWidth(), fontHeight));
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 59447fd7..c6069821 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -89,9 +89,11 @@ void Minimap::draw(gcn::Graphics *graphics)
// Player dot
graphics->setColor(gcn::Color(209, 52, 61));
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(
being->x / 2 + getPadding() - 1,
being->y / 2 + getTitleBarHeight() - 1, 3, 3));
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(
diff --git a/src/gui/progressbar.cpp b/src/gui/progressbar.cpp
index a1083db3..fb03d90b 100644
--- a/src/gui/progressbar.cpp
+++ b/src/gui/progressbar.cpp
@@ -105,8 +105,10 @@ void ProgressBar::draw(gcn::Graphics *graphics)
{
graphics->setColor(gcn::Color(red, green, blue, 200));
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(4, 4,
(int)(progress * (getWidth() - 8)), getHeight() - 8));
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(4, 4,
diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp
index c8524657..3350a252 100644
--- a/src/gui/scrollarea.cpp
+++ b/src/gui/scrollarea.cpp
@@ -180,10 +180,12 @@ void ScrollArea::draw(gcn::Graphics *graphics)
{
graphics->setColor(getBaseColor());
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(getWidth() - mScrollbarWidth,
getHeight() - mScrollbarWidth,
mScrollbarWidth,
mScrollbarWidth));
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(gcn::Rectangle(getWidth() - mScrollbarWidth,
@@ -197,7 +199,9 @@ void ScrollArea::draw(gcn::Graphics *graphics)
{
gcn::Rectangle contdim = mContent->getDimension();
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->pushClipArea(getContentDimension());
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->pushClipArea(getContentDimension());
@@ -211,14 +215,18 @@ void ScrollArea::draw(gcn::Graphics *graphics)
rec.width += 2 * mContent->getBorderSize();
rec.height += 2 * mContent->getBorderSize();
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->pushClipArea(rec);
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->pushClipArea(rec);
}
mContent->drawBorder(graphics);
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->popClipArea();
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->popClipArea();
@@ -226,15 +234,19 @@ void ScrollArea::draw(gcn::Graphics *graphics)
}
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->pushClipArea(contdim);
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->pushClipArea(contdim);
}
mContent->draw(graphics);
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->popClipArea();
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->popClipArea();
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->popClipArea();
@@ -330,7 +342,9 @@ void ScrollArea::drawVBar(gcn::Graphics *graphics)
gcn::Rectangle dim = getVerticalBarDimension();
graphics->setColor(gcn::Color(0, 0, 0, 32));
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(dim);
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(dim);
@@ -343,7 +357,9 @@ void ScrollArea::drawHBar(gcn::Graphics *graphics)
gcn::Rectangle dim = getHorizontalBarDimension();
graphics->setColor(gcn::Color(0, 0, 0, 32));
if (useOpenGL) {
+#ifdef USE_OPENGL
dynamic_cast<gcn::OpenGLGraphics*>(graphics)->fillRectangle(dim);
+#endif
}
else {
dynamic_cast<gcn::SDLGraphics*>(graphics)->fillRectangle(dim);
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index eb550a3a..2bf4721f 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -34,6 +34,7 @@ Image::Image(SDL_Surface *image):
alpha = 1.0f;
}
+#ifdef USE_OPENGL
Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight):
glimage(glimage),
width(width),
@@ -44,6 +45,7 @@ Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight)
// Default to opaque
alpha = 1.0f;
}
+#endif
Image::~Image()
{
@@ -240,9 +242,9 @@ Image* Image::load(void* buffer, unsigned int bufferSize)
return new Image(texture, width, height, realWidth, realHeight);
}
-#endif
-
+#else
return NULL;
+#endif
}
void Image::unload()
@@ -265,9 +267,11 @@ int Image::getWidth() const
return image->w;
}
}
+#ifdef USE_OPENGL
else {
return width;
}
+#endif
return 0;
}
@@ -278,21 +282,27 @@ int Image::getHeight() const
return image->h;
}
}
+#ifdef USE_OPENGL
else {
return height;
}
+#endif
return 0;
}
Image *Image::getSubImage(int x, int y, int width, int height)
{
// Create a new clipped sub-image
- if (useOpenGL) {
- return new SubImage(this, glimage, x, y, width, height, texWidth, texHeight);
+ if (!useOpenGL) {
+ return new SubImage(this, image, x, y, width, height);
}
+#ifdef USE_OPENGL
else {
- return new SubImage(this, image, x, y, width, height);
+ return new SubImage(this, glimage, x, y, width, height, texWidth, texHeight);
}
+#else
+ return NULL;
+#endif
}
bool Image::draw_deprecated(SDL_Surface *screen, int srcX, int srcY, int dstX, int dstY,
@@ -386,7 +396,7 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
rect.h = height;
}
-//SubImage::SubImage((GLuint*)Image *parent, GLuint glimage,
+#ifdef USE_OPENGL
SubImage::SubImage(Image *parent, GLuint image,
int x, int y, int width, int height, int texWidth, int texHeight):
Image(image, width, height, texWidth, texHeight), parent(parent)
@@ -399,6 +409,7 @@ SubImage::SubImage(Image *parent, GLuint image,
rect.w = width;
rect.h = height;
}
+#endif
SubImage::~SubImage()
{
diff --git a/src/resources/image.h b/src/resources/image.h
index cfa42330..a12572bb 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -26,8 +26,9 @@
#include "resource.h"
#include <SDL.h>
+#ifdef USE_OPENGL
#include <SDL_opengl.h>
-
+#endif
/**
* Defines a class for loading and storing images.
@@ -118,21 +119,19 @@ class Image : public Resource
/**
* Constructor.
*/
-//#ifdef USE_OPENGL
+#ifdef USE_OPENGL
Image(GLuint glimage, int width, int height, int texWidth, int texHeight);
-//#else
+#endif
Image(SDL_Surface *image);
-//#endif
bool loaded;
-//#ifdef USE_OPENGL
+#ifdef USE_OPENGL
GLuint glimage;
int width, height;
int texWidth, texHeight;
-//#else
+#endif
SDL_Surface *image;
-//#endif
float alpha;
};
@@ -145,13 +144,12 @@ class SubImage : public Image
/**
* Constructor.
*/
-//#ifndef USE_OPENGL
SubImage(Image *parent, SDL_Surface *image,
int x, int y, int width, int height);
-//#else
+#ifdef USE_OPENGL
SubImage(Image *parent, GLuint image, int x, int y,
int width, int height, int texWidth, int textHeight);
-//#endif
+#endif
/**
* Destructor.