From 25d2c764443723eb7a3dd5f8bf0b76586c1ff10b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 5 Apr 2008 10:52:39 +0000 Subject: Makefile.am updates, math::Axis, improved VertexArray, r_arraysize --- src/client/view.cc | 62 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'src/client/view.cc') diff --git a/src/client/view.cc b/src/client/view.cc index a19f98a..c31cc12 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -15,6 +15,7 @@ #include "client/camera.h" #include "client/chat.h" #include "client/console.h" +#include "client/input.h" #include "client/video.h" #include "render/draw.h" #include "render/render.h" @@ -25,6 +26,9 @@ namespace client { +core::Cvar *draw_stats = 0; +core::Cvar *draw_crosshaircolor = 0; + namespace view { @@ -33,6 +37,9 @@ float fps = 0; void init() { camera::init(); + + draw_stats = core::Cvar::get("draw_stats", "0", core::Cvar::Archive); + draw_crosshaircolor = core::Cvar::get("draw_crosshaircolor", "1 1 1", core::Cvar::Archive); } void shutdown() @@ -93,7 +100,6 @@ void draw_loader() { using namespace render; - gl::enable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, render::textures[0]); // bitmaps/loader.tga gl::color(1.0f, 1.0f, 1.0f, 1.0f); @@ -111,8 +117,6 @@ void draw_loader() glTexCoord2f(0.0f, 1.0f); gl::vertex(0,video::height,0); gl::end(); - - gl::disable(GL_TEXTURE_2D); } void draw_status() @@ -123,7 +127,6 @@ void draw_status() return; glBindTexture(GL_TEXTURE_2D, render::textures[1]); // bitmaps/conchars.tga - gl::enable(GL_TEXTURE_2D); // print the status in the upper left corner gl::color(1.0f, 1.0f, 1.0f, 1.0f); @@ -144,7 +147,7 @@ void draw_status() draw_text(CHARWIDTH, 4, status); // print stats if desired - if (render::r_drawstats && render::r_drawstats->value()) { + if (draw_stats && draw_stats->value()) { std::stringstream stats; stats << "fps " << std::setw(6) << fps << "\n"; if (core::application()->connected()) { @@ -184,11 +187,49 @@ void draw_status() if (core::localcontrol()) { status.str(""); status << " dir " << std::setfill('0') << std::setw(3) << roundf(core::localcontrol()->direction()) << - " speed " << std::setfill(' ') << std::setw(5) << std::fixed << std::setprecision(2) << core::localcontrol()->speed(); + " speed " << std::setfill(' ') << std::setw(5) << std::fixed << std::setprecision(2) << core::localcontrol()->speed() << " - " << input::mouse_x << "+" << input::mouse_y; + draw_text(CHARWIDTH, video::height - CHARHEIGHT -4, status); } - gl::disable(GL_TEXTURE_2D); +} + +void draw_cursor() +{ + if (!core::localcontrol() || console::visible()) + return; + + float crosshair_size = 48.0f; + float x = input::mouse_x - (crosshair_size /2); + float y = input::mouse_y - (crosshair_size /2); + + using namespace render; + + glBindTexture(GL_TEXTURE_2D, render::textures[2]); // bitmaps/crosshairs.tga + + math::Color color; + if (draw_crosshaircolor && draw_crosshaircolor->value()) { + std::stringstream colorstr(draw_crosshaircolor->str()); + colorstr >> color; + } + color.a = 0.5f; + + gl::color(color); + gl::begin(gl::Quads); + + glTexCoord2f(0,0 ); + gl::vertex(x,y,0.0f); + + glTexCoord2f(1, 0); + gl::vertex(x+crosshair_size, y, 0.0f); + + glTexCoord2f(1, 1); + gl::vertex(x+crosshair_size, y+crosshair_size, 0.0f); + + glTexCoord2f(0, 1); + gl::vertex(x, y+crosshair_size, 0.0f); + + gl::end(); } void frame(float seconds) @@ -234,6 +275,8 @@ void frame(float seconds) gl::matrixmode(GL_MODELVIEW); gl::loadidentity(); + gl::enable(GL_TEXTURE_2D); + if (!core::application()->connected()) { // draw the loader bitmap draw_loader(); @@ -245,6 +288,11 @@ void frame(float seconds) // draw the status line draw_status(); + + // draw the mouse cursor + draw_cursor(); + + gl::disable(GL_TEXTURE_2D); } } //namespace view -- cgit v1.2.3