Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-03-26 23:24:26 +0000
committerStijn Buys <ingar@osirion.org>2008-03-26 23:24:26 +0000
commit3d993058e5078fbdfd92d479281ad93bb40a4bc6 (patch)
treefd578d5a44246a90fc08cdf6b9a18f02313ce431 /src/render/render.cc
parent2b9f068e7ee4c0d249c715f9eb5a3c2c8a11e6f8 (diff)
improved TGA handling
Diffstat (limited to 'src/render/render.cc')
-rw-r--r--src/render/render.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/render/render.cc b/src/render/render.cc
index 15a6d5c..3a9ebd3 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -10,6 +10,8 @@
#include <iomanip>
#include "render/render.h"
+#include "render/tga.h"
+#include "render/gl.h"
#include "core/core.h"
#include "filesystem/filesystem.h"
#include "sys/sys.h"
@@ -22,6 +24,32 @@ core::Cvar *r_drawradius = 0;
core::Cvar *r_drawstats = 0;
core::Cvar *r_wireframe = 0;
+bool texture(char * const filename, size_t id)
+{
+ Image *image = TGA::load(filename);
+ if (!image)
+ return false;
+
+ // FIXME - I don't get this part... yet
+
+ glGenTextures(1, &textures[id]);
+ glBindTexture(GL_TEXTURE_2D, textures[id]);
+
+ int texture_type;
+ if (image->channels() == 4)
+ texture_type = GL_RGBA;
+ else
+ texture_type = GL_RGB;
+
+ gluBuild2DMipmaps(GL_TEXTURE_2D, image->channels(),
+ image->width(), image->height(), texture_type, GL_UNSIGNED_BYTE, image->data());
+
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
+
+ return true;
+}
+
void init()
{
con_print << "Initializing renderer..." << std::endl;
@@ -32,11 +60,11 @@ void init()
con_print << "Loading textures..." << std::endl;
- if (!TGA::texture(textures, "bitmaps/loader.tga", 0)) {
+ if (!texture( "bitmaps/loader.tga", 0)) {
con_error << "Essential file bitmaps/loader.tga missing" << std::endl;
core::application()->shutdown();
}
- if (!TGA::texture(textures, "bitmaps/conchars.tga", 1)) {
+ if (!texture("bitmaps/conchars.tga", 1)) {
con_error << "Essential file bitmaps/conchars.tga missing" << std::endl;
core::application()->shutdown();
}