diff options
Diffstat (limited to 'src/ui')
-rwxr-xr-x | src/ui/modelview.cc | 45 | ||||
-rwxr-xr-x | src/ui/modelview.h | 7 |
2 files changed, 47 insertions, 5 deletions
diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index a07922a..11dd318 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -11,6 +11,7 @@ #include "render/camera.h" #include "render/draw.h" #include "render/render.h" + namespace ui { @@ -55,18 +56,56 @@ void ModelView::draw() if (!modelview_modelname.size()) return; + model::Model *model = model::Model::find(modelview_modelname); + if (!model) + return; + math ::Vector2f center(global_location()); center.x += width() * 0.5f; center.y += height() * 0.5f; - - //model::Model *model = model::Model::find(modelview_modelname); + + gl::clear(GL_DEPTH_BUFFER_BIT); // gl 3d mode + render::Camera::frustum_default(model->radius(), center.x, center.y); + + gl::disable(GL_BLEND); + 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 + gl::enable(GL_LIGHTING); + + // enable vertex arrays + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + + render::draw_model_fragments(model, core::localplayer()->color(), core::localplayer()->color_second(), true, true, 0); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + gl::disable(GL_LIGHTING); + 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::enable(GL_BLEND); // gl 2d mode - //render::Camera::ortho(); + render::Camera::ortho(); +} + +void ModelView::draw_border() +{ + paint::color(palette()->foreground()); + paint::border(global_location(), size()); } } diff --git a/src/ui/modelview.h b/src/ui/modelview.h index 2abeb01..1fbb4d9 100755 --- a/src/ui/modelview.h +++ b/src/ui/modelview.h @@ -35,9 +35,12 @@ public: virtual void print(const size_t indent) const; protected: - /// draw the model + /// draw the widget virtual void draw(); - + + /// draw border + void draw_border(); + private: std::string modelview_modelname; math::Color modelview_color; |