From fb1d166768e516a8493c16064640c98b1efa6707 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 7 Jul 2009 09:32:38 +0000 Subject: Moved vertexarray from render to core --- src/core/cvar.cc | 1 + src/core/cvar.h | 1 + src/core/gameinterface.cc | 20 ++++++++++++++++++++ src/core/gameinterface.h | 5 +++++ 4 files changed, 27 insertions(+) (limited to 'src/core') 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 -- cgit v1.2.3