diff options
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 10 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 35 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.c | 3 |
3 files changed, 39 insertions, 9 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index f6bfada7fd8..cd305d5697f 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -187,13 +187,10 @@ typedef struct GPUStateValues eGPUStateMask mask; /* GL_ENABLE_BIT */ - unsigned int is_alpha_test : 1; unsigned int is_blend : 1; - bool is_clip_plane[6]; unsigned int is_cull_face : 1; unsigned int is_depth_test : 1; unsigned int is_dither : 1; - bool is_light[8]; unsigned int is_lighting : 1; unsigned int is_line_smooth : 1; unsigned int is_color_logic_op : 1; @@ -205,6 +202,13 @@ typedef struct GPUStateValues unsigned int is_scissor_test : 1; unsigned int is_stencil_test : 1; +#ifdef WITH_LEGACY_OPENGL + unsigned int is_alpha_test : 1; + bool is_light[8]; +#endif + + bool is_clip_plane[6]; + /* GL_DEPTH_BUFFER_BIT */ /* unsigned int is_depth_test : 1; */ int depth_func; diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 181cd0ad4bc..aea5cccf2e7 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -422,14 +422,18 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) { if (alphablend == GPU_BLEND_SOLID) { glDisable(GL_BLEND); +#ifdef WITH_LEGACY_OPENGL glDisable(GL_ALPHA_TEST); +#endif glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } else if (alphablend == GPU_BLEND_ADD) { glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); +#ifdef WITH_LEGACY_OPENGL glDisable(GL_ALPHA_TEST); +#endif glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); } else if (ELEM(alphablend, GPU_BLEND_ALPHA, GPU_BLEND_ALPHA_SORT)) { @@ -442,6 +446,7 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) /* if U.glalphaclip == 1.0, some cards go bonkers... * turn off alpha test in this case */ +#ifdef WITH_LEGACY_OPENGL /* added after 2.45 to clip alpha */ if (U.glalphaclip == 1.0f) { glDisable(GL_ALPHA_TEST); @@ -450,16 +455,21 @@ static void gpu_set_alpha_blend(GPUBlendMode alphablend) glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, U.glalphaclip); } +#endif } else if (alphablend == GPU_BLEND_CLIP) { glDisable(GL_BLEND); glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); +#ifdef WITH_LEGACY_OPENGL glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f); +#endif } else if (alphablend == GPU_BLEND_ALPHA_TO_COVERAGE) { +#ifdef WITH_LEGACY_OPENGL glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, U.glalphaclip); +#endif glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); } } @@ -2261,19 +2271,26 @@ void GPU_state_init(void) GPU_disable_program_point_size(); +#ifndef WITH_GL_PROFILE_CORE /* TODO: remove this when we switch to core profile */ - glEnable(GL_POINT_SPRITE); + if (!GLEW_VERSION_3_2) { + glEnable(GL_POINT_SPRITE); + } +#endif glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); glDepthFunc(GL_LEQUAL); - glDisable(GL_ALPHA_TEST); glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); glDisable(GL_COLOR_LOGIC_OP); glDisable(GL_STENCIL_TEST); + +#ifdef WITH_LEGACY_OPENGL + glDisable(GL_ALPHA_TEST); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +#endif glDepthRange(0.0, 1.0); @@ -2292,7 +2309,7 @@ void GPU_state_init(void) void GPU_enable_program_point_size(void) { -#ifdef __APPLE__ +#if defined(__APPLE__) && defined(WITH_LEGACY_OPENGL) /* TODO: remove this when we switch to core profile */ glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); #else @@ -2302,7 +2319,7 @@ void GPU_enable_program_point_size(void) void GPU_disable_program_point_size(void) { -#ifdef __APPLE__ +#if defined(__APPLE__) && defined(WITH_LEGACY_OPENGL) /* TODO: remove this when we switch to core profile */ glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); #else @@ -2502,7 +2519,6 @@ void gpuSaveState(GPUStateValues *values, eGPUStateMask mask) } if ((mask & GPU_ENABLE_BIT) != 0) { - values->is_alpha_test = glIsEnabled(GL_ALPHA_TEST); values->is_blend = glIsEnabled(GL_BLEND); for (int i = 0; i < 6; i++) { @@ -2513,9 +2529,13 @@ void gpuSaveState(GPUStateValues *values, eGPUStateMask mask) values->is_depth_test = glIsEnabled(GL_DEPTH_TEST); values->is_dither = glIsEnabled(GL_DITHER); +#ifdef WITH_LEGACY_OPENGL + values->is_alpha_test = glIsEnabled(GL_ALPHA_TEST); + for (int i = 0; i < 8; i++) { values->is_light[i] = glIsEnabled(GL_LIGHT0 + i); } +#endif values->is_line_smooth = glIsEnabled(GL_LINE_SMOOTH); values->is_color_logic_op = glIsEnabled(GL_COLOR_LOGIC_OP); @@ -2564,7 +2584,6 @@ void gpuRestoreState(GPUStateValues *values) } if ((mask & GPU_ENABLE_BIT) != 0) { - restore_mask(GL_ALPHA_TEST, values->is_alpha_test); restore_mask(GL_BLEND, values->is_blend); for (int i = 0; i < 6; i++) { @@ -2575,9 +2594,13 @@ void gpuRestoreState(GPUStateValues *values) restore_mask(GL_DEPTH_TEST, values->is_depth_test); restore_mask(GL_DITHER, values->is_dither); +#ifdef WITH_LEGACY_OPENGL + restore_mask(GL_ALPHA_TEST, values->is_alpha_test); + for (int i = 0; i < 8; i++) { restore_mask(GL_LIGHT0 + i, values->is_light[i]); } +#endif restore_mask(GL_LINE_SMOOTH, values->is_line_smooth); restore_mask(GL_COLOR_LOGIC_OP, values->is_color_logic_op); diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 31c871008bd..c330726daea 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -345,7 +345,9 @@ static GPUTexture *GPU_texture_create_nD( glTexParameteri(tex->target_base, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); glTexParameteri(tex->target_base, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); +#ifdef WITH_LEGACY_OPENGL glTexParameteri(tex->target_base, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); +#endif } else { glTexParameteri(tex->target_base, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -447,6 +449,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget /* see GPUInput::textarget: it can take two values - GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP * these values are correct for glDisable, so textarget can be safely used in * GPU_texture_bind/GPU_texture_unbind through tex->target_base */ + /* (is any of this obsolete now that we don't glEnable/Disable textures?) */ if (textarget == GL_TEXTURE_2D) gputt = TEXTARGET_TEXTURE_2D; else |