diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/gameserver.cc | 8 | ||||
-rw-r--r-- | src/model/vertexarray.cc | 42 | ||||
-rw-r--r-- | src/render/draw.cc | 58 | ||||
-rw-r--r-- | src/render/render.cc | 12 | ||||
-rw-r--r-- | src/render/render.h | 5 |
5 files changed, 94 insertions, 31 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index cd656ed..2027098 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -141,7 +141,7 @@ void GameServer::showtime() con_print << "Uptime " << minutes << ":" << setfill('0') << setw(2) << seconds << - " Server localtime " << setfill(' ') << setw(2) << syshours << ":" << setfill('0') << setw(2) << sysminutes << ":" << setw(2) << sysseconds << std::endl; + " Server localtime " << setfill(' ') << setw(2) << syshours << ":" << setfill('0') << setw(2) << sysminutes << ":" << setw(2) << sysseconds << setfill(' ') << std::endl; } Player *GameServer::find_player(std::string const search) @@ -301,17 +301,17 @@ void GameServer::exec(Player *player, std::string const & cmdline) } else if ((function->flags() & Func::Shared) == Func::Shared) { // enable rcon buffering - sys::ConsoleInterface::instance()->buffer_rcon(true); + console()->buffer_rcon(true); function->exec(args); char line[MAXCMDSIZE]; - while(sys::ConsoleInterface::instance()->buffer().getline(line, MAXCMDSIZE-1)) { + while(console()->buffer().getline(line, MAXCMDSIZE-1)) { send_rcon(player, std::string(line)); } // disable rcon buffering - sys::ConsoleInterface::instance()->buffer_rcon(false); + console()->buffer_rcon(false); return; } } diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc index da9c3d2..b0da6ab 100644 --- a/src/model/vertexarray.cc +++ b/src/model/vertexarray.cc @@ -75,34 +75,18 @@ void VertexArray::add_sphere() math::Vector3f v; math::Vector3f n; math::Vector3f tex; - int count; - //float h = (float) (SPHERESEGMENTS-1) / 2 -1; + // add sphere for (int j=0; j < (SPHERESEGMENTS-1) / 2; j++) { float r = sintable[j]; float r1 = sintable[j+1]; -/* v.assign(r, 0, costable[j]); - n = v; - n.normalize(); - tex.assign(1, (float)(SPHERESEGMENTS-1-j) / (float)(SPHERESEGMENTS-1), 0); - add_vertex(v, n, white, tex); - - v = math::Vector3f(r1, 0, costable[j+1]); - n = v; - n.normalize(); - tex.assign(1, (float) (SPHERESEGMENTS-2-j) / (float)(SPHERESEGMENTS-1), 0 ); - add_vertex(v, n, white, tex); - - count =2; -*/ for (int i = 0; i < SPHERESEGMENTS; i++) { v = math::Vector3f(r*costable[i], r*sintable[i], costable[j]); n = v; n.normalize(); - //tex.assign((float)i/(float)(SPHERESEGMENTS), (float) (j) / h, 0); tex.assign((float)i/(float)(SPHERESEGMENTS-1), -costable[j]/2 + 0.5f , 0); add_vertex(v, n, white, tex); @@ -116,6 +100,30 @@ void VertexArray::add_sphere() } + // add inside-out sphere + for (int j=0; j < (SPHERESEGMENTS-1) / 2; j++) { + + float r = sintable[j]; + float r1 = sintable[j+1]; + + + for (int i = SPHERESEGMENTS -1 ; i >= 0; i--) { + v = math::Vector3f(r*costable[i], r*sintable[i], costable[j]); + n = v; + n.normalize(); + tex.assign(1-(float)i/(float)(SPHERESEGMENTS-1), -costable[j]/2 + 0.5f , 0); + add_vertex(v, n, white, tex); + + v = math::Vector3f(r1*costable[i], r1*sintable[i], costable[j+1]); + n = v; + n.normalize(); + tex.assign(1-(float)i/(float)(SPHERESEGMENTS-1), -costable[j+1]/2 + 0.5f, 0); + add_vertex(v, n, white, tex); + count +=2; + } + + } + delete[] sintable; delete[] costable; } diff --git a/src/render/draw.cc b/src/render/draw.cc index 1091d8c..6aafcca 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -66,6 +66,25 @@ void draw_sphere(math::Color const & color, float radius) //gl::pop(); } +void draw_sphere_inside(math::Color const & color, float radius) +{ + //gl::push(); + gl::scale(radius, radius, radius); + gl::color(color); + + size_t index = (model::SPHERESEGMENTS) * (model::SPHERESEGMENTS-1); + size_t count = (model::SPHERESEGMENTS)*2; + + // draw body + for (int j=0; j < (model::SPHERESEGMENTS-1)/2; j++) { + glDrawArrays(gl::QuadStrip, index, count); + index += count; + Stats::quads += count/2-1; + } + + //gl::pop(); +} + void draw_entity_sphere(core::Entity *entity) { if ((entity->type() == core::Entity::Globe) && !flag_is_set(entity->flags(), core::Entity::Bright)) { @@ -393,6 +412,25 @@ void pass_prepare(float seconds) } } +/* Draw skybox */ +void draw_pass_skybox() +{ + + if (!(r_sky && r_sky->value())) + return; + + size_t flare_texture = Textures::load("textures/env/sky"); + Textures::bind(flare_texture); + + gl::enable(GL_TEXTURE_2D); + gl::push(); + + draw_sphere_inside(math::Color(), 512); + + gl::pop(); + gl::disable(GL_TEXTURE_2D); +} + /* Draw entities without model */ void draw_pass_default() { @@ -692,6 +730,9 @@ void draw_pass_model_corona() void draw_pass_spacegrid() { + if (!(r_grid && r_grid->value())) + return; + int gridsize = 32; float s = 1.0f / gridsize; float z = -4.0f; @@ -741,14 +782,8 @@ void draw(float seconds) Camera::draw(seconds); // draw the current camera transformation pass_prepare(seconds); - - gl::enable(GL_DEPTH_TEST); // enable depth buffer writing - gl::enable(GL_CULL_FACE); // enable culling - gl::enable(GL_COLOR_MATERIAL); // enable color tracking - gl::enable(GL_LIGHTING); - gl::disable(GL_BLEND); // disbable alpha blending for world polys - gl::disable(GL_RESCALE_NORMAL); + // enable vertex arrays glVertexPointer(3, GL_FLOAT, 0, vertexarray->vertex()); glNormalPointer(GL_FLOAT, 0, vertexarray->normal()); glColorPointer(3, GL_FLOAT, 0, vertexarray->color()); @@ -759,6 +794,15 @@ void draw(float seconds) glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); + draw_pass_skybox(); // draw the skybox + + gl::enable(GL_DEPTH_TEST); // enable depth buffer writing + gl::enable(GL_CULL_FACE); // enable culling + gl::enable(GL_COLOR_MATERIAL); // enable color tracking + gl::enable(GL_LIGHTING); + gl::disable(GL_BLEND); // disbable alpha blending for world polys + gl::disable(GL_RESCALE_NORMAL); + if (r_wireframe && r_wireframe->value()) { glPolygonMode(GL_FRONT, GL_LINE); } else { diff --git a/src/render/render.cc b/src/render/render.cc index dac0972..ea70dbf 100644 --- a/src/render/render.cc +++ b/src/render/render.cc @@ -23,10 +23,12 @@ namespace render { GLuint textures[32]; -core::Cvar *r_radius = 0; -core::Cvar *r_wireframe = 0; core::Cvar *r_arraysize = 0; core::Cvar *r_bbox = 0; +core::Cvar *r_grid = 0; +core::Cvar *r_radius = 0; +core::Cvar *r_sky = 0; +core::Cvar *r_wireframe = 0; using model::VertexArray; @@ -82,9 +84,15 @@ void init() r_wireframe = core::Cvar::get("r_wireframe", "0", core::Cvar::Archive); r_wireframe->set_info("[bool] render wireframe"); + r_grid = core::Cvar::get("r_grid", "1", core::Cvar::Archive); + r_grid->set_info("[bool] render the space grid"); + r_bbox = core::Cvar::get("r_bbox", "0", core::Cvar::Archive); r_bbox->set_info("[bool] render model bounding box"); + r_sky = core::Cvar::get("r_sky", "1", core::Cvar::Archive); + r_sky->set_info("[bool] render the sky globe"); + Camera::init(); Textures::init(); diff --git a/src/render/render.h b/src/render/render.h index ebecf7f..2a8952e 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -24,10 +24,13 @@ namespace render { /// shutdown the render subsystem void shutdown(); + extern core::Cvar *r_arraysize; extern core::Cvar *r_bbox; + extern core::Cvar *r_grid; extern core::Cvar *r_radius; + extern core::Cvar *r_sky; extern core::Cvar *r_wireframe; - extern core::Cvar *r_arraysize; + extern model::VertexArray *vertexarray; } |