Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-05-06 19:01:42 +0000
committerStijn Buys <ingar@osirion.org>2009-05-06 19:01:42 +0000
commit3dde787b2546958072e8a98350335b2bab6d1c17 (patch)
tree788ab92dcc575d83291baa33cd4698bf2be5a768 /src
parentada263d9924c9014b445d0b855f52f1ef75d39dd (diff)
added r_mipmap variable to enable hardware generated mimaps
Diffstat (limited to 'src')
-rw-r--r--src/render/render.cc34
-rw-r--r--src/render/render.h13
-rw-r--r--src/render/textures.cc6
3 files changed, 33 insertions, 20 deletions
diff --git a/src/render/render.cc b/src/render/render.cc
index 9f364cb..60d64a7 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -35,6 +35,7 @@ core::Cvar *r_particles = 0;
core::Cvar *r_radius = 0;
core::Cvar *r_sky = 0;
core::Cvar *r_wireframe = 0;
+core::Cvar *r_mipmap = 0;
void func_list_textures(std::string const &args)
{
@@ -62,21 +63,6 @@ void init(int width, int height)
// initialize render state
State::init(width, height);
- if (!State::has_generate_mipmaps()) {
- con_print << " no hardware generated mipmap support" << std::endl;
- }
-
- Camera::init();
-
- Textures::init();
-
- Text::init();
-
- Dust::init();
-
- // read materials
- model::Material::init();
-
// size of the vertex array in megabytes
r_arraysize = core::Cvar::get("r_arraysize", 64.0f , core::Cvar::Archive);
r_arraysize->set_info("[int] size of the vertex array in Mb");
@@ -114,6 +100,24 @@ void init(int width, int height)
Screenshot::screenshotquality = core::Cvar::get("screenshotquality", "85", core::Cvar::Archive);
Screenshot::screenshotquality->set_info("[int] screenshot jpg quality");
+ // hardware generate mipmaps
+ r_mipmap = core::Cvar::get("r_mipmap", "0", core::Cvar::Archive);
+ r_mipmap->set_info("[bool] use hardware generated mipmaps");
+ if (!State::has_generate_mipmaps()) {
+ con_print << " no hardware generated mipmap support" << std::endl;
+ }
+
+ Camera::init();
+
+ Textures::init();
+
+ Text::init();
+
+ Dust::init();
+
+ // read materials
+ model::Material::init();
+
// engine functions
core::Func *func = core::Func::add("list_textures", func_list_textures);
func->set_info("list registered textures");
diff --git a/src/render/render.h b/src/render/render.h
index de881ff..a7b1950 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -36,14 +36,23 @@ namespace render {
/// resize viewport
void resize(int width, int height);
- extern core::Cvar *r_arraysize;
+ /// size of the vertex array, in megabytes
+ extern core::Cvar *r_arraysize;
+ /// render model bounding boxes
extern core::Cvar *r_bbox;
+ /// render the spacegrid
extern core::Cvar *r_grid;
+ /// render particle systems
extern core::Cvar *r_particles;
+ /// render entity radius
extern core::Cvar *r_radius;
+ /// render sky
extern core::Cvar *r_sky;
+ /// render wireframe models
extern core::Cvar *r_wireframe;
-
+ /// use hardware generated mipmaps (requires OpenGL 1.4, does not work on all cards)
+ extern core::Cvar *r_mipmap;
+ /// global vertex arrat
extern model::VertexArray *vertexarray;
inline RenderExt *ext_render(core::Entity *entity) { return static_cast<RenderExt *>(entity->extension((size_t)core::Extension::Render)); }
diff --git a/src/render/textures.cc b/src/render/textures.cc
index f5a5c62..5845bb6 100644
--- a/src/render/textures.cc
+++ b/src/render/textures.cc
@@ -6,6 +6,7 @@
#include <string.h>
+#include "render/render.h"
#include "render/gl.h"
#include "render/image.h"
#include "render/textures.h"
@@ -176,7 +177,7 @@ size_t Textures::load(const std::string &name, const bool filter)
// 4 levels of mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4);
- if (State::has_generate_mipmaps()) {
+ if (r_mipmap->value()) {
// hardware generated mipmaps (requires OpenGL 1.4)
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
}
@@ -197,12 +198,11 @@ size_t Textures::load(const std::string &name, const bool filter)
texture_internalformat = GL_RGB8;
}
- if (filter && !State::has_generate_mipmaps()) {
+ if (filter && (r_mipmap->value() <= 0)) {
gluBuild2DMipmaps(GL_TEXTURE_2D,
texture_internalformat, image->width(), image->height(),
texture_format, GL_UNSIGNED_BYTE, image->data());
} else {
-
glTexImage2D(GL_TEXTURE_2D, 0,
texture_internalformat, image->width(), image->height(), 0,
texture_format, GL_UNSIGNED_BYTE, image->data());