From d95f18442ea216a886bfddf75d349362d1e537bc Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 11 Jul 2014 19:37:17 +0000 Subject: Support material layer blending. --- src/render/draw.cc | 4 ++-- src/render/state.cc | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/render') diff --git a/src/render/draw.cc b/src/render/draw.cc index d932739..af9ec27 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -1104,7 +1104,7 @@ void draw_pass_model_fx(float elapsed) } // restore the default depth buffer comparison function - gl::depthfunc(GL_LESS); + gl::depthfunc(GL_LEQUAL); gl::disable(GL_TEXTURE_2D); gl::cullface(GL_BACK); @@ -1185,7 +1185,7 @@ void draw(float seconds) draw_pass_sky(); // draw the skybox gl::depthmask(GL_TRUE); // enable writing to the depth buffer - gl::depthfunc(GL_LESS); // default depth buffer comparison function + gl::depthfunc(GL_LEQUAL); // default depth buffer comparison function gl::enable(GL_DEPTH_TEST); // enable depth testing gl::enable(GL_CULL_FACE); // enable culling gl::enable(GL_COLOR_MATERIAL); // enable color tracking diff --git a/src/render/state.cc b/src/render/state.cc index 7857963..6f791b3 100644 --- a/src/render/state.cc +++ b/src/render/state.cc @@ -285,7 +285,7 @@ void State::use_material_layer(const model::Material * material, const model::La gl::specular(specular); // lighted or fullbright - if (state_power && layer->bright()) { + if (state_power && layer->fullbright()) { gl::disable(GL_LIGHTING); } else if (state_power && (layer->rgbgen() == model::Layer::RGBGenEngine)) { @@ -332,10 +332,26 @@ void State::use_material_layer(const model::Material * material, const model::La } + // alpha blending + switch(layer->blendfunc()) { + case model::Layer::BlendFuncNone: + gl::disable(GL_BLEND); + break; + case model::Layer::BlendFuncAdd: + gl::blendfunc(GL_ONE, GL_ONE); + gl::enable(GL_BLEND); + break; + case model::Layer::BlendFuncBlend: + gl::enable(GL_BLEND); + break; + } } void State::reset() { + gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl::enable(GL_BLEND); + gl::disable(GL_POLYGON_OFFSET_FILL); gl::disable(GL_ALPHA_TEST); gl::disable(GL_TEXTURE_GEN_S); -- cgit v1.2.3