diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-06-13 16:35:25 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-06-13 16:35:25 +0200 |
commit | d6b9953c32b9abc2a96bb2e5b82d8801a1d12cef (patch) | |
tree | b78ebfebaa02788641ace0f58bc2a0dacd31c40a /texture.cpp | |
parent | f1c0772af07f0339bda5a9abeaf4f869de9868e1 (diff) |
Added more stuff.
Diffstat (limited to 'texture.cpp')
-rw-r--r-- | texture.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/texture.cpp b/texture.cpp new file mode 100644 index 0000000..c3575f2 --- /dev/null +++ b/texture.cpp @@ -0,0 +1,19 @@ +#include <SDL/SDL_opengl.h> +#include <stdexcept> +#include "texture.h" +#include <stdio.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_NEAREST); + gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, format, GL_UNSIGNED_BYTE, data); +} |