diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 8 | ||||
-rw-r--r-- | src/render/render.cc | 39 | ||||
-rw-r--r-- | src/render/render.h | 7 |
3 files changed, 42 insertions, 12 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc index 2775f63..4305b4d 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -381,7 +381,7 @@ void draw_pass_model_fx() { void draw_pass_model_radius() { - if (!(r_drawradius && r_drawradius->value())) + if (!(r_radius && r_radius->value())) return; for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { @@ -457,9 +457,9 @@ void draw(math::Vector3f const &eye, math::Vector3f const &target, float seconds gl::disable(GL_BLEND); // disbable alpha blending for world polys gl::disable(GL_RESCALE_NORMAL); - glVertexPointer(3, GL_FLOAT, 0, core::VertexArray::vertex); - glNormalPointer(GL_FLOAT, 0, core::VertexArray::vertex_normal); - glColorPointer(3, GL_FLOAT, 0, core::VertexArray::vertex_color); + glVertexPointer(3, GL_FLOAT, 0, vertexarray->vertex()); + glNormalPointer(GL_FLOAT, 0, vertexarray->normal()); + glColorPointer(3, GL_FLOAT, 0, vertexarray->color()); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); diff --git a/src/render/render.cc b/src/render/render.cc index 76704a4..8311c16 100644 --- a/src/render/render.cc +++ b/src/render/render.cc @@ -20,9 +20,11 @@ namespace render { GLuint textures[32]; -core::Cvar *r_drawradius = 0; -core::Cvar *r_drawstats = 0; +core::Cvar *r_radius = 0; core::Cvar *r_wireframe = 0; +core::Cvar * r_arraysize = 0; + +core::VertexArray *vertexarray = 0; bool texture(const char *filename, size_t id) { @@ -30,8 +32,6 @@ bool texture(const char *filename, size_t id) if (!image) return false; - // FIXME - I don't get this part... yet - glGenTextures(1, &textures[id]); glBindTexture(GL_TEXTURE_2D, textures[id]); @@ -64,19 +64,46 @@ void init() con_error << "Essential file bitmaps/loader.tga missing" << std::endl; core::application()->shutdown(); } + if (!texture("bitmaps/conchars.tga", 1)) { con_error << "Essential file bitmaps/conchars.tga missing" << std::endl; core::application()->shutdown(); } - r_drawradius = core::Cvar::get("r_drawradius", "0", core::Cvar::Archive); - r_drawstats = core::Cvar::get("r_drawstats", "0", core::Cvar::Archive); + if (!texture("bitmaps/crosshair.tga", 2)) { + con_error << "Essential file bitmaps/crosshair.tga missing" << std::endl; + core::application()->shutdown(); + } + + r_arraysize = core::Cvar::get("r_arraysize", 4.0f * (float) sizeof(float) , core::Cvar::Archive); + size_t mb = (size_t) r_arraysize->value(); + if (mb < 8) + mb = 8; + if (mb > 256) + mb = 256; + (*r_arraysize) = (float) mb; + vertexarray = new core::VertexArray(mb); + + r_radius = core::Cvar::get("r_radius", "0", core::Cvar::Archive); r_wireframe = core::Cvar::get("r_wireframe", "0", core::Cvar::Archive); } void shutdown() { con_print << "Shutting down renderer..." << std::endl; + + glDeleteTextures(2, textures); + + // clear entity models, this will force a reload + for (std::map<unsigned int, core::Entity *>::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { + core::Entity *entity = (*it).second; + if (entity->model()) + entity->entity_model = 0; + } + + core::Model::clear(); + delete vertexarray; + vertexarray = 0; } } diff --git a/src/render/render.h b/src/render/render.h index 34ba974..00b4672 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -9,6 +9,7 @@ #include "GL/gl.h" #include "core/cvar.h" +#include "core/model.h" namespace render { @@ -23,9 +24,11 @@ namespace render { extern GLuint textures[32]; - extern core::Cvar *r_drawradius; - extern core::Cvar *r_drawstats; + extern core::Cvar *r_radius; extern core::Cvar *r_wireframe; + extern core::Cvar *r_arraysize; + + extern core::VertexArray *vertexarray; } #include "render/draw.h" |