diff --git a/modules/gfx/src/gfx_object.cc b/modules/gfx/src/gfx_object.cc index c6eec4a3a1ff878ac66821a27c6d0395d043a453..c5f7fd2ac076d139f59a064f3946d81fd27d280c 100644 --- a/modules/gfx/src/gfx_object.cc +++ b/modules/gfx/src/gfx_object.cc @@ -148,17 +148,22 @@ void GfxObj::RenderGL(RenderPass pass) render_depth_only(); } else if(pass==TRANSPARENT_RENDER_PASS) { if(GetOpacity()<1.0) { - render_depth_only(); - CustomRenderGL(STANDARD_RENDER_PASS); + render_depth_only(); + CustomRenderGL(STANDARD_RENDER_PASS); + if(outline_flag_) { + va_.SetOutlineMode(outline_mode_); + CustomRenderGL(pass); + va_.SetOutlineMode(0); + } } } else if(pass==STANDARD_RENDER_PASS) { if(GetOpacity()>=1.0) { - CustomRenderGL(STANDARD_RENDER_PASS); - } - if(outline_flag_) { - va_.SetOutlineMode(outline_mode_); - CustomRenderGL(pass); - va_.SetOutlineMode(0); + CustomRenderGL(STANDARD_RENDER_PASS); + if(outline_flag_) { + va_.SetOutlineMode(outline_mode_); + CustomRenderGL(pass); + va_.SetOutlineMode(0); + } } } else if(pass==GLOW_RENDER_PASS) { CustomRenderGL(GLOW_RENDER_PASS); diff --git a/modules/gfx/src/vertex_array.cc b/modules/gfx/src/vertex_array.cc index ce0f4b73139f380ecb3b9b5fdb097d1990e25409..da22a32727df37eb87cd2311263efdf486f504ca 100644 --- a/modules/gfx/src/vertex_array.cc +++ b/modules/gfx/src/vertex_array.cc @@ -382,6 +382,7 @@ void IndexedVertexArray::SetOpacity(float o) for(EntryList::iterator it=entry_list_.begin();it!=entry_list_.end();++it) { it->c[3]=o; } + opacity_=o; FlagRefresh(); } @@ -436,7 +437,7 @@ void IndexedVertexArray::RenderGL() glCullFace(GL_FRONT); glEnable(GL_CULL_FACE); glShadeModel(GL_FLAT); - if(outline_mode_==1) { + if(outline_mode_==2) { glCallList(outline_mat_dlist_); glEnable(GL_POLYGON_OFFSET_LINE); glEnable(GL_POLYGON_OFFSET_POINT); @@ -446,7 +447,7 @@ void IndexedVertexArray::RenderGL() glEnable(GL_LINE_SMOOTH); glDisable(GL_POINT_SMOOTH); // kills selfx fragment shader if enabled glDisable(GL_POLYGON_SMOOTH); - } else if(outline_mode_==2) { + } else if(outline_mode_==1) { glCallList(outline_mat_dlist_); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(10.0,1.0); @@ -459,7 +460,12 @@ void IndexedVertexArray::RenderGL() glDisable(GL_POLYGON_OFFSET_LINE); glDisable(GL_POLYGON_OFFSET_POINT); glDisable(GL_LINE_SMOOTH); - glDisable(GL_BLEND); + if(opacity_<1.0) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + } else { + glDisable(GL_BLEND); + } } } else { // not in outline mode @@ -473,17 +479,17 @@ void IndexedVertexArray::RenderGL() } else { glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); } - if(color_mat_) { - glEnable(GL_COLOR_MATERIAL); - } else { - glDisable(GL_COLOR_MATERIAL); - } if(cull_face_) { glEnable(GL_CULL_FACE); } else { glDisable(GL_CULL_FACE); } } + if(color_mat_) { + glEnable(GL_COLOR_MATERIAL); + } else { + glDisable(GL_COLOR_MATERIAL); + } if(mode_&0x1) { if(outline_mode_>0) { @@ -516,7 +522,7 @@ void IndexedVertexArray::RenderGL() glUniform1f(glGetUniformLocation(Shader::Instance().GetCurrentProgram(),"scalef"),outline_exp_factor_); glUniform4f(glGetUniformLocation(Shader::Instance().GetCurrentProgram(),"color"), outline_exp_color_[0],outline_exp_color_[1], - outline_exp_color_[2],outline_exp_color_[3]); + outline_exp_color_[2],opacity_); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); draw_ltq(use_buff); @@ -663,6 +669,7 @@ void IndexedVertexArray::Reset() aalines_flag_=false; point_size_=2.0; line_halo_=0.0; + opacity_=1.0; outline_mode_=0; outline_width_=4.0; outline_mat_=Material(0.3,1.0,0.0,0.0,0.0); diff --git a/modules/gfx/src/vertex_array.hh b/modules/gfx/src/vertex_array.hh index 3883c2abe9e298be14c9f64a7d091d51b52e4bda..24025194806abd80e7cc4e7b4362678299ed2fe2 100644 --- a/modules/gfx/src/vertex_array.hh +++ b/modules/gfx/src/vertex_array.hh @@ -211,6 +211,7 @@ class DLLEXPORT_OST_GFX IndexedVertexArray { bool aalines_flag_; float point_size_; float line_halo_; + float opacity_; int outline_mode_; float outline_width_;