From eb075660e7cb61b138c2da337115c59857f89e17 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 16 Jul 2008 22:55:07 +0000 Subject: network protocol cleanup, radar test (doesn't work) --- src/client/view.cc | 131 ++++++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 62 deletions(-) (limited to 'src/client/view.cc') diff --git a/src/client/view.cc b/src/client/view.cc index 2bbae15..63718e1 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -63,69 +63,12 @@ void shutdown() { } -void reset() -{ - using namespace render; - - // set clear color - gl::clearcolor(0.0f, 0.0f, 0.0f, 1.0f); - - // shading model: Gouraud (smooth, the default) - gl::shademodel(GL_SMOOTH); - //gl::shademodel(GL_FLAT); - - // load identity matrices - gl::matrixmode(GL_MODELVIEW); - gl::loadidentity(); - - gl::matrixmode(GL_MODELVIEW); - gl::loadidentity(); - - // lighting - GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 }; - GLfloat ambient_light[] = { 0.01f, 0.01f, 0.01f, 1.0f }; - GLfloat diffuse_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; - GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; - - glLightfv(GL_LIGHT0, GL_POSITION, light_position); - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light); - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light); - glLightfv(GL_LIGHT0, GL_SPECULAR, specular_light); - - // color tracking - glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); - - GLfloat specular_reflectance[] = { 0.2f, 0.2f, 0.2f, 1.0f }; - glMaterialfv(GL_FRONT, GL_SPECULAR, specular_reflectance); - glMateriali(GL_FRONT, GL_SHININESS, 128); // shininess 1-128 - - gl::disable(GL_LIGHTING); - gl::enable(GL_LIGHT0); - gl::disable(GL_COLOR_MATERIAL); - - // culling - gl::cullface(GL_BACK); - gl::frontface(GL_CCW); - gl::disable(GL_CULL_FACE); - - // depth - gl::depthmask(GL_TRUE); - gl::disable(GL_DEPTH_TEST); - - // alpha-blending - gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - gl::enable(GL_BLEND); - - // client state -} - void draw_loader() { using namespace render; render::Textures::bind("bitmaps/loader"); - gl::color(1.0f, 1.0f, 1.0f, 1.0f); - + gl::begin(gl::Quads); glTexCoord2f(0.0f, 0.0f); @@ -139,6 +82,7 @@ void draw_loader() glTexCoord2f(0.0f, 1.0f); gl::vertex(0,video::height,0); + gl::end(); } @@ -282,6 +226,62 @@ void draw_cursor() gl::end(); } +void reset() +{ + using namespace render; + + // set clear color + gl::clearcolor(0.0f, 0.0f, 0.0f, 1.0f); + + // load identity matrices + gl::matrixmode(GL_MODELVIEW); + gl::loadidentity(); + + gl::matrixmode(GL_MODELVIEW); + gl::loadidentity(); + + // shading model: Gouraud (smooth, the default) + gl::shademodel(GL_SMOOTH); + //gl::shademodel(GL_FLAT); + + // lighting settings for the default light GL_LIGHT0 + GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 }; + GLfloat ambient_light[] = { 0.01f, 0.01f, 0.01f, 1.0f }; + GLfloat diffuse_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; + GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f }; + + glLightfv(GL_LIGHT0, GL_POSITION, light_position); + glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light); + glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light); + glLightfv(GL_LIGHT0, GL_SPECULAR, specular_light); + + // GL_LIGHT0 is always enabled + gl::enable(GL_LIGHT0); + + // color tracking + glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); + + // material settings + GLfloat specular_reflectance[] = { 0.2f, 0.2f, 0.2f, 1.0f }; + glMaterialfv(GL_FRONT, GL_SPECULAR, specular_reflectance); + glMateriali(GL_FRONT, GL_SHININESS, 128); // shininess 1-128 + + // alpha blending function + gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + gl::disable(GL_LIGHTING); + gl::disable(GL_COLOR_MATERIAL); + + gl::cullface(GL_BACK); + gl::frontface(GL_CCW); + gl::disable(GL_CULL_FACE); + gl::disable(GL_DEPTH_TEST); + gl::disable(GL_BLEND); + + gl::disable(GL_TEXTURE_2D); + +} + void frame(float seconds) { using namespace render; @@ -300,21 +300,20 @@ void frame(float seconds) if (core::application()->connected() && core::game()->serverframetime()) { render::draw(seconds); // draw the world - if (draw_radar->value()) { - Radar::draw(); - } } // switch to ortographic projection to draw the GUI gl::matrixmode(GL_PROJECTION); gl::loadidentity(); - glOrtho(0, video::width, video::height, 0, -1000.0f, 1000.0f); + glOrtho(0, video::width, video::height, 0, -1024.0f, 1024.0f); gl::matrixmode(GL_MODELVIEW); gl::loadidentity(); gl::enable(GL_TEXTURE_2D); + gl::color(1.0f, 1.0f, 1.0f, 1.0f); + if (!core::application()->connected()) { // draw the loader bitmap draw_loader(); @@ -322,9 +321,15 @@ void frame(float seconds) // draw text elements if (draw_ui->value()) { + Text::setfont("bitmaps/fonts/gui", 16, 24); + draw_status(); + if (draw_radar->value()) { + Radar::draw(); + } + // draw the mouse cursor draw_cursor(); } @@ -334,6 +339,8 @@ void frame(float seconds) console()->draw(); gl::disable(GL_TEXTURE_2D); + + gl::disable(GL_BLEND); } } //namespace view -- cgit v1.2.3