summaryrefslogtreecommitdiff
path: root/src/resources/image.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-03-01 00:07:47 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-03-01 00:07:47 +0000
commit17de81fb71b4f91d2e0897f802a36df5630f1eaa (patch)
treea8d6444c8f4da24918228eb7566204aa5dded4a9 /src/resources/image.cpp
parente9a413d772c608f4ceba2953fabea643a02e0266 (diff)
downloadmana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.tar.gz
mana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.tar.bz2
mana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.tar.xz
mana-17de81fb71b4f91d2e0897f802a36df5630f1eaa.zip
Changed around recent additions to Image class a bit and fixed OpenGL compile.
Diffstat (limited to 'src/resources/image.cpp')
-rw-r--r--src/resources/image.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index cefb9d88..314de573 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -44,11 +44,6 @@ Image::Image(GLuint image, int width, int height, int texWidth, int texHeight):
alpha = 1.0f;
}
-Image::Image():image(image)
-{
- alpha = 1.0f;
-}
-
Image::~Image()
{
unload();
@@ -225,6 +220,24 @@ Image* Image::load(const char* buffer, unsigned int bufferSize)
#endif
}
+Image *Image::create(int width, int height)
+{
+#ifndef USE_OPENGL
+ SDL_Surface *surf =
+ SDL_AllocSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0);
+
+ if (surf) {
+ return new Image(surf);
+ }
+ else {
+ return NULL;
+ }
+#else
+ return NULL;
+#endif
+}
+
+
void Image::unload()
{
// Free the image surface.
@@ -366,26 +379,19 @@ float Image::getAlpha()
return alpha;
}
-bool Image::create(int width, int height)
+void Image::fillWithColor(
+ unsigned char red, unsigned char green, unsigned blue)
{
- image = SDL_AllocSurface(SDL_SWSURFACE, width, height, 32, 0, 0, 0, 0);
- if ( image )
- return true;
- else
- return false;
-}
-
-void Image::fillWithColor(unsigned char red, unsigned char green, unsigned blue)
-{
- Uint32 boxColor = SDL_MapRGB(SDL_GetVideoSurface()->format, red, green, blue);
- if ( image )
- {
+#ifndef USE_OPENGL
+ if (image) {
+ Uint32 boxColor = SDL_MapRGB(image->format, red, green, blue);
SDL_Rect sourceRect;
sourceRect.x = sourceRect.y = 0;
sourceRect.w = image->w;
sourceRect.h = image->h;
SDL_FillRect(image, &sourceRect, boxColor);
}
+#endif
}
//============================================================================