summaryrefslogtreecommitdiff
path: root/texturestbi.cpp
diff options
context:
space:
mode:
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);
+}