summaryrefslogtreecommitdiff
path: root/texturestbi.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-10-02 03:43:27 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-10-02 03:43:27 +0200
commit8e0a72184085aa6e3e741ad5d79f5db2e63d63a6 (patch)
treef7924997c55e98ced990fc24e19b48ec0fedb535 /texturestbi.cpp
parentbf4827f46f22b4df0fa2ddd6716fd59247f9e1bb (diff)
Replaced TextureSDL with TextureSTBI.
Diffstat (limited to 'texturestbi.cpp')
-rw-r--r--texturestbi.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/texturestbi.cpp b/texturestbi.cpp
new file mode 100644
index 0000000..abd802e
--- /dev/null
+++ b/texturestbi.cpp
@@ -0,0 +1,20 @@
+#include <stdexcept>
+#include <SFML/Window/OpenGL.hpp>
+#include "texturestbi.h"
+#include "stb_image.h"
+
+TextureSTBI::TextureSTBI(const char* filename) {
+ int w, h, ch;
+ uint8_t* data = stbi_load(filename, &w, &h, &ch, 4);
+
+ unsigned int format;
+ if(ch == 4) {
+ format = GL_RGBA;
+ } else {
+ format = GL_RGB;
+ }
+
+ build(data, format, w, h);
+
+ stbi_image_free(data);
+}