From d702c133c06cd9626430263292df69b092954c5f Mon Sep 17 00:00:00 2001 From: Evan Goers Date: Sat, 21 Jan 2012 03:19:55 +0000 Subject: Add a 'decal' macro material flag. Material flag 'Decal' enables polygon offsetting and alpha testing on the surface. --- src/render/state.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/render') diff --git a/src/render/state.cc b/src/render/state.cc index 09e1a59..ffff7e3 100644 --- a/src/render/state.cc +++ b/src/render/state.cc @@ -219,6 +219,14 @@ void State::use_material(const model::Material * material) { gl::color(color); return; } + + // Decal macro + if (material->flags() & model::Material::Decal) { + gl::enable(GL_POLYGON_OFFSET_FILL); + gl::enable(GL_ALPHA_TEST); + glPolygonOffset(-1,-1); + glAlphaFunc(GL_GEQUAL, 0.5f); + } // assign the opengl drawing color according to material flags if (material->flags() & model::Material::Engine) { @@ -312,6 +320,8 @@ void State::use_material(const model::Material * material) { } void State::reset() { + gl::disable(GL_POLYGON_OFFSET_FILL); + gl::disable(GL_ALPHA_TEST); gl::disable(GL_TEXTURE_GEN_S); gl::disable(GL_TEXTURE_GEN_T); gl::disable(GL_TEXTURE_GEN_R); -- cgit v1.2.3