diff options
author | Stijn Buys <ingar@osirion.org> | 2014-07-11 19:37:17 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2014-07-11 19:37:17 +0000 |
commit | d95f18442ea216a886bfddf75d349362d1e537bc (patch) | |
tree | a86352393b9f51181594ea4e167e8beba57f2f3a /src/render | |
parent | 1d518a54914531d7a4fab3a6835b75de85bd7bc7 (diff) |
Support material layer blending.
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 4 | ||||
-rw-r--r-- | src/render/state.cc | 18 |
2 files changed, 19 insertions, 3 deletions
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); |