From d6e4c4e7c2b1e28961f1dfe2f25ef96ced60b21b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 17 Oct 2010 17:19:03 +0000 Subject: core bullet physics support, initial vstrafe support --- src/render/draw.cc | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/render/draw.cc') diff --git a/src/render/draw.cc b/src/render/draw.cc index d54387a..656653b 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -15,6 +15,7 @@ #include "model/model.h" #include "render/render.h" #include "render/textures.h" +#include "render/debugdrawer.h" #include "render/draw.h" #include "render/dust.h" #include "render/gl.h" @@ -1206,12 +1207,17 @@ void draw(float seconds) glPolygonMode(GL_FRONT, GL_FILL); draw_pass_sky(); // draw the skybox + + gl::depthmask(GL_TRUE); // enable writing to the depth buffer + gl::enable(GL_DEPTH_TEST); + gl::enable(GL_CULL_FACE); // enable culling + gl::enable(GL_COLOR_MATERIAL); // enable color tracking // enable wireframe mode if requested if (r_wireframe && r_wireframe->value()) { glPolygonMode(GL_FRONT, GL_LINE); } - + // set vertex array pointers glInterleavedArrays(GL_T2F_N3F_V3F, 0, core::game()->vertexarray()->ptr()); @@ -1220,12 +1226,6 @@ void draw(float seconds) glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); - gl::depthmask(GL_TRUE); // enable writing to the depth buffer - gl::enable(GL_DEPTH_TEST); - - gl::enable(GL_CULL_FACE); // enable culling - gl::enable(GL_COLOR_MATERIAL); // enable color tracking - if (r_normalize && r_normalize->value()) { // enable full normalization gl::enable(GL_NORMALIZE); @@ -1248,7 +1248,7 @@ void draw(float seconds) // disable full normalization gl::disable(GL_NORMALIZE); } else { - // disable resaling of normals + // disable rescaling of normals gl::disable(GL_RESCALE_NORMAL); } @@ -1294,12 +1294,27 @@ void draw(float seconds) glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - + gl::depthmask(GL_TRUE); // enable depth buffer writing + gl::disable(GL_DEPTH_TEST); // disable depth buffer testing + + // draw physics + if (r_physics && r_physics->value()) { + if (zone->physics()) { + if (!zone->physics()->getDebugDrawer()) + zone->physics()->setDebugDrawer(&bullet_debugdrawer); + + // draw physics bodies in red + gl::color(1.0f, 0.0f, 0.0f, 1.0f); + gl::begin(gl::Lines); + zone->physics()->debugDrawWorld(); + gl::end(); + } + } + gl::disable(GL_COLOR_MATERIAL); // disable color tracking gl::disable(GL_CULL_FACE); // disable culling - gl::depthmask(GL_TRUE); // enable depth buffer writing - gl::disable(GL_DEPTH_TEST); // disable depth buffer testing + // GL_BLEND must be enabled for the GUI } -- cgit v1.2.3