summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-07-27 21:55:20 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-07-27 21:55:20 +0000
commitd15d76976b6e57a9f421ab034c6f841051b962f3 (patch)
treeab0c37c90af9f76158b96f195c05be9b221e9f42 /src/resources
parentaa362286c725e17ec88aa46f8f6af9ca90d744b3 (diff)
downloadmana-d15d76976b6e57a9f421ab034c6f841051b962f3.tar.gz
mana-d15d76976b6e57a9f421ab034c6f841051b962f3.tar.bz2
mana-d15d76976b6e57a9f421ab034c6f841051b962f3.tar.xz
mana-d15d76976b6e57a9f421ab034c6f841051b962f3.zip
Committing merging opengl and sdl part 3 by Andrej
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/image.cpp23
-rw-r--r--src/resources/image.h18
2 files changed, 25 insertions, 16 deletions
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.