Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/particles.h2
-rw-r--r--src/render/textures.cc25
-rw-r--r--src/render/textures.h5
3 files changed, 30 insertions, 2 deletions
diff --git a/src/render/particles.h b/src/render/particles.h
index a36b142..cf0f5eb 100644
--- a/src/render/particles.h
+++ b/src/render/particles.h
@@ -13,7 +13,7 @@
#include "math/color.h"
#include "math/vector3f.h"
#include "core/entity.h"
-#include "model/classes.h"
+#include "model/parts.h"
namespace render {
diff --git a/src/render/textures.cc b/src/render/textures.cc
index 5845bb6..fe85c8d 100644
--- a/src/render/textures.cc
+++ b/src/render/textures.cc
@@ -23,6 +23,12 @@ namespace render
std::map<std::string, size_t> Textures::registry;
GLuint Textures::textures[MAXTEXTURES];
+math::Vector2f Textures::texture_size[MAXTEXTURES];
+
+void material_loader_func(model::Material *material)
+{
+ Textures::material_loader(material);
+}
void Textures::init()
{
@@ -49,10 +55,13 @@ void Textures::init()
load("bitmaps/pointers/center");
load("bitmaps/pointers/control");
load("bitmaps/pointers/target");
+
+ model::Material::set_loader_func(Textures::material_loader);
}
void Textures::shutdown()
{
+ model::Material::set_loader_func(0);
clear();
}
@@ -159,7 +168,7 @@ size_t Textures::load(const std::string &name, const bool filter)
if (!image) {
// add to the registry with id 0 (texture not found)
- con_warn << "Could not open " << filename << std::endl;
+ con_warn << "Could not open texture " << name << std::endl;
registry[name] = 0;
return 0;
}
@@ -181,6 +190,10 @@ size_t Textures::load(const std::string &name, const bool filter)
// hardware generated mipmaps (requires OpenGL 1.4)
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
}
+
+ // enable texture wrapping
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
} else {
// scaling functions
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
@@ -210,6 +223,7 @@ size_t Textures::load(const std::string &name, const bool filter)
// add to the registry
registry[name] = id;
+ texture_size[id].assign((float) image->width(), (float) image->height());
// delete image data
delete image;
@@ -258,4 +272,13 @@ size_t Textures::bind(const size_t texture, const bool filter)
return id;
}
+void Textures::material_loader(model::Material *material)
+{
+ if ((material->flags() & model::Material::Texture) & (material->texture().size())) {
+ size_t id = load(material->texture());
+ material->set_texture_id(id);
+ material->set_size(texture_size[id]);
+ }
+}
+
}
diff --git a/src/render/textures.h b/src/render/textures.h
index 84d5c9a..c1ccabe 100644
--- a/src/render/textures.h
+++ b/src/render/textures.h
@@ -10,6 +10,7 @@
#include <string>
#include <map>
+#include "model/material.h"
#include "render/gl.h"
namespace render
@@ -56,11 +57,15 @@ public:
/// list loaded textures
static void list();
+ /// material loader func
+ static void material_loader(model::Material *material);
+
private:
static void clear();
typedef std::map<std::string, size_t>::iterator iterator;
+ static math::Vector2f texture_size[MAXTEXTURES];
static std::map<std::string, size_t> registry;
static GLuint textures[MAXTEXTURES];
};