summaryrefslogtreecommitdiff
path: root/texturesdl.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-06-13 16:35:25 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-06-13 16:35:25 +0200
commitd6b9953c32b9abc2a96bb2e5b82d8801a1d12cef (patch)
treeb78ebfebaa02788641ace0f58bc2a0dacd31c40a /texturesdl.cpp
parentf1c0772af07f0339bda5a9abeaf4f869de9868e1 (diff)
Added more stuff.
Diffstat (limited to 'texturesdl.cpp')
-rw-r--r--texturesdl.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/texturesdl.cpp b/texturesdl.cpp
new file mode 100644
index 0000000..bab760b
--- /dev/null
+++ b/texturesdl.cpp
@@ -0,0 +1,23 @@
+#include <stdexcept>
+#include <SDL/SDL_image.h>
+#include <SDL/SDL_opengl.h>
+#include "texturesdl.h"
+
+TextureSDL::TextureSDL(const char* filename) {
+ SDL_Surface* image = IMG_Load(filename);
+
+ width = image->w;
+ height = image->h;
+
+ if(image->format->BytesPerPixel == 4) {
+ format = image->format->Bshift ? GL_RGBA : GL_BGRA;
+ } else {
+ format = image->format->Bshift ? GL_RGB : GL_BGR;
+ }
+
+ data = (unsigned char*)image->pixels;
+
+ build();
+
+ SDL_FreeSurface(image);
+}