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-07-07 09:32:38 +0000
committerStijn Buys <ingar@osirion.org>2009-07-07 09:32:38 +0000
commitfb1d166768e516a8493c16064640c98b1efa6707 (patch)
treee5d1827028fc6a5fa527c9293f6ae2fde42b3991 /src
parente66f56ea71f466cc2b261e04d7348e36baff71e1 (diff)
Moved vertexarray from render to core
Diffstat (limited to 'src')
-rw-r--r--src/core/cvar.cc1
-rw-r--r--src/core/cvar.h1
-rw-r--r--src/core/gameinterface.cc20
-rw-r--r--src/core/gameinterface.h5
-rw-r--r--src/render/draw.cc8
-rw-r--r--src/render/render.cc33
-rw-r--r--src/render/render.h6
7 files changed, 38 insertions, 36 deletions
diff --git a/src/core/cvar.cc b/src/core/cvar.cc
index 2e5de5a..2a9fd67 100644
--- a/src/core/cvar.cc
+++ b/src/core/cvar.cc
@@ -24,6 +24,7 @@ Cvar *Cvar::sv_framerate = 0;
Cvar *Cvar::sv_name = 0;
Cvar *Cvar::sv_description = 0;
Cvar *Cvar::sv_password = 0;
+Cvar *Cvar::sv_arraysize = 0;
Cvar *Cvar::cl_prediction = 0;
diff --git a/src/core/cvar.h b/src/core/cvar.h
index 5683d94..8861f2a 100644
--- a/src/core/cvar.h
+++ b/src/core/cvar.h
@@ -115,6 +115,7 @@ public:
static Cvar *sv_name; // server name
static Cvar *sv_description; // server description
static Cvar *sv_password; // server rcon password
+ static Cvar *sv_arraysize; // vertex array size in MegaBytes
static Cvar *con_ansi; // console ANSI colors
diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc
index 5f3c91a..1ed0a67 100644
--- a/src/core/gameinterface.cc
+++ b/src/core/gameinterface.cc
@@ -70,6 +70,19 @@ GameInterface::GameInterface()
Func *func = Func::add("list_players", func_list_players);
func->set_info("get the local list of connected players");
+
+ // size of the vertex array in megabytes
+ Cvar::sv_arraysize = core::Cvar::get("sv_arraysize", 128.0f , core::Cvar::Archive);
+ Cvar::sv_arraysize->set_info("[int] size of the vertex array in MegabBytes");
+
+ size_t mb = (size_t) Cvar::sv_arraysize->value();
+ if (mb < 4 * sizeof(float))
+ mb = 4 * sizeof(float);
+ if (mb > 512)
+ mb = 512;
+ (*Cvar::sv_arraysize) = (float) mb;
+ game_vertexarray = new model::VertexArray(mb);
+
}
GameInterface::~GameInterface()
@@ -79,6 +92,12 @@ GameInterface::~GameInterface()
game_localplayer.clear();
clear();
+
+ // delete vertex array
+ if (game_vertexarray) {
+ delete game_vertexarray;
+ game_vertexarray = 0;
+ }
}
// clear all game related objects
@@ -122,6 +141,7 @@ void GameInterface::clear()
// remove all models
model::Model::clear();
+
// remove infos
Info::clear();
diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h
index 8dc401b..7d3e086 100644
--- a/src/core/gameinterface.h
+++ b/src/core/gameinterface.h
@@ -9,6 +9,7 @@
#include "core/player.h"
#include "core/info.h"
+#include "model/vertexarray.h"
namespace core
{
@@ -32,6 +33,8 @@ public:
inline Player *localplayer() { return &game_localplayer; }
inline Players & players() { return game_players; }
+
+ inline model::VertexArray *vertexarray() { return game_vertexarray; }
/// find the first player who's id or name matches the search string
Player *find_player(const std::string &search);
@@ -74,6 +77,8 @@ protected:
/// all the players
Players game_players;
+
+ model::VertexArray *game_vertexarray;
};
/// global local player instance
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 5784347..f128019 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -1025,10 +1025,10 @@ void draw(float seconds)
}
// set vertex array pointers
- glVertexPointer(3, GL_FLOAT, 0, vertexarray->vertex());
- glNormalPointer(GL_FLOAT, 0, vertexarray->normal());
- glColorPointer(3, GL_FLOAT, 0, vertexarray->color());
- glTexCoordPointer(3, GL_FLOAT, 0, vertexarray->texture());
+ glVertexPointer(3, GL_FLOAT, 0, core::game()->vertexarray()->vertex());
+ glNormalPointer(GL_FLOAT, 0, core::game()->vertexarray()->normal());
+ glColorPointer(3, GL_FLOAT, 0, core::game()->vertexarray()->color());
+ glTexCoordPointer(3, GL_FLOAT, 0, core::game()->vertexarray()->texture());
// enable vertex arrays
glEnableClientState(GL_VERTEX_ARRAY);
diff --git a/src/render/render.cc b/src/render/render.cc
index 60d64a7..ce23645 100644
--- a/src/render/render.cc
+++ b/src/render/render.cc
@@ -26,9 +26,6 @@
namespace render {
-model::VertexArray *vertexarray = 0;
-
-core::Cvar *r_arraysize = 0;
core::Cvar *r_bbox = 0;
core::Cvar *r_grid = 0;
core::Cvar *r_particles = 0;
@@ -36,6 +33,7 @@ core::Cvar *r_radius = 0;
core::Cvar *r_sky = 0;
core::Cvar *r_wireframe = 0;
core::Cvar *r_mipmap = 0;
+core::Cvar *r_collision = 0;
void func_list_textures(std::string const &args)
{
@@ -63,18 +61,6 @@ void init(int width, int height)
// initialize render state
State::init(width, height);
- // 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");
-
- size_t mb = (size_t) r_arraysize->value();
- if (mb < 4 * sizeof(float))
- mb = 4 * sizeof(float);
- if (mb > 256)
- mb = 256;
- (*r_arraysize) = (float) mb;
- vertexarray = new model::VertexArray(mb);
-
// engine variables
r_radius = core::Cvar::get("r_radius", "0", core::Cvar::Archive);
r_radius->set_info("[bool] render entity radius");
@@ -93,7 +79,10 @@ void init(int width, int height)
r_particles = core::Cvar::get("r_particles", "1", core::Cvar::Archive);
r_particles->set_info("[bool] render particles");
-
+ /*
+ r_collision = core::Cvar::get("r_collision", "1", core::Cvar::Archive);
+ r_collision->set_info("[bool] render collision (server side only)");
+ */
Screenshot::screenshotformat = core::Cvar::get("screenshotformat", "jpg", core::Cvar::Archive);
Screenshot::screenshotformat->set_info("[string] screenshot format: jpg png tga");
@@ -196,10 +185,6 @@ void clear()
// clear particle system scripts
ParticleScript::clear();
-
- // clear vertex array
- delete vertexarray;
- vertexarray = 0;
}
// reset render subsystem (module disconnect)
@@ -213,14 +198,6 @@ void reset()
Textures::init();
- size_t mb = (size_t) r_arraysize->value();
- if (mb < 4 * sizeof(float))
- mb = 4 * sizeof(float);
- if (mb > 256)
- mb = 256;
- (*r_arraysize) = (float) mb;
- vertexarray = new model::VertexArray(mb);
-
Dust::reset();
model::Material::init();
diff --git a/src/render/render.h b/src/render/render.h
index a7b1950..54205bc 100644
--- a/src/render/render.h
+++ b/src/render/render.h
@@ -36,8 +36,6 @@ namespace render {
/// resize viewport
void resize(int width, int height);
- /// size of the vertex array, in megabytes
- extern core::Cvar *r_arraysize;
/// render model bounding boxes
extern core::Cvar *r_bbox;
/// render the spacegrid
@@ -50,10 +48,10 @@ namespace render {
extern core::Cvar *r_sky;
/// render wireframe models
extern core::Cvar *r_wireframe;
+ /// render collision
+ extern core::Cvar *r_collision;
/// 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)); }