diff options
Diffstat (limited to 'source/blender/gpu/intern/gpu_basic_shader.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_basic_shader.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/gpu/intern/gpu_basic_shader.c b/source/blender/gpu/intern/gpu_basic_shader.c index 4be50a078b7..a2b89239344 100644 --- a/source/blender/gpu/intern/gpu_basic_shader.c +++ b/source/blender/gpu/intern/gpu_basic_shader.c @@ -376,6 +376,8 @@ static GPUShader *gpu_basic_shader(int options) strcat(defines, "#define DRAW_LINE\n"); geom_glsl = datatoc_gpu_shader_basic_geom_glsl; } + if (options & GPU_SHADER_FLAT_NORMAL) + strcat(defines, "#define USE_FLAT_NORMAL\n"); if (options & GPU_SHADER_SOLID_LIGHTING) strcat(defines, "#define USE_SOLID_LIGHTING\n"); else if (options & GPU_SHADER_LIGHTING) @@ -500,18 +502,35 @@ void GPU_basic_shader_bind(int options) else if ((bound_options & GPU_SHADER_LINE) && (bound_options & GPU_SHADER_STIPPLE)) { glDisable(GL_LINE_STIPPLE); } - else { - if (options & GPU_SHADER_STIPPLE) - glEnable(GL_POLYGON_STIPPLE); - else if (bound_options & GPU_SHADER_STIPPLE) - glDisable(GL_POLYGON_STIPPLE); + + if (((options & GPU_SHADER_LINE) == 0) && (options & GPU_SHADER_STIPPLE)) { + glEnable(GL_POLYGON_STIPPLE); + } + else if (((bound_options & GPU_SHADER_LINE) == 0) && (bound_options & GPU_SHADER_STIPPLE)) { + glDisable(GL_POLYGON_STIPPLE); } + if (options & GPU_SHADER_FLAT_NORMAL) { + glShadeModel(GL_FLAT); + } + else if (bound_options & GPU_SHADER_FLAT_NORMAL) { + glShadeModel(GL_SMOOTH); + } } GPU_MATERIAL_STATE.bound_options = options; } +void GPU_basic_shader_bind_enable(int options) +{ + GPU_basic_shader_bind(GPU_MATERIAL_STATE.bound_options | options); +} + +void GPU_basic_shader_bind_disable(int options) +{ + GPU_basic_shader_bind(GPU_MATERIAL_STATE.bound_options & ~options); +} + int GPU_basic_shader_bound_options(void) { /* ideally this should disappear, anything that uses this is making fragile |