summaryrefslogtreecommitdiff
path: root/texture.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-02-09 11:38:58 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-02-09 11:38:58 +0100
commit19b6628549c8b80f23976d9b42f2cd853989422c (patch)
tree3d8ad793b39c0e96b3bb6d6ca7e0a2555a17a803 /texture.cpp
Initial commit.
Diffstat (limited to 'texture.cpp')
-rwxr-xr-xtexture.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/texture.cpp b/texture.cpp
new file mode 100755
index 0000000..5a4a7ab
--- /dev/null
+++ b/texture.cpp
@@ -0,0 +1,25 @@
+#ifndef __APPLE__
+#include <GL/gl.h>
+#include <GL/glut.h>
+#else
+#include <OpenGL/gl.h>
+#include <GLUT/glut.h>
+#endif
+#include <stdexcept>
+#include "texture.h"
+
+unsigned int Texture::tex() {
+ return texture;
+}
+
+void Texture::build() {
+ if(!data) {
+ throw(std::runtime_error("No texture data"));
+ }
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+ //glTexImage2D(GL_TEXTURE_2D, 0, 4, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
+ gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
+}