diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/engines/select/select_engine.c | 3 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 7 | ||||
-rw-r--r-- | source/blender/gpu/GPU_state.h | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 63 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state.c | 40 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_window.c | 2 |
8 files changed, 48 insertions, 79 deletions
diff --git a/source/blender/draw/engines/select/select_engine.c b/source/blender/draw/engines/select/select_engine.c index 08ec0038755..bb7c947a0b9 100644 --- a/source/blender/draw/engines/select/select_engine.c +++ b/source/blender/draw/engines/select/select_engine.c @@ -307,9 +307,6 @@ static void select_draw_scene(void *vedata) return; } - /* dithering and AA break color coding, so disable */ - glDisable(GL_DITHER); - DRW_view_set_active(stl->g_data->view_faces); if (!DRW_pass_is_empty(psl->depth_only_pass)) { diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 639c62e5e44..970578c7438 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -63,11 +63,11 @@ #include "ED_space_api.h" #include "ED_view3d.h" -#include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_state.h" #include "GPU_uniformbuffer.h" #include "GPU_viewport.h" diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index e5a6a8ffde8..3fb48292000 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -39,13 +39,6 @@ struct Main; /* OpenGL drawing functions related to shading. */ -/* Initialize - * - sets the default Blender opengl state, if in doubt, check - * the contents of this function - * - this is called when starting Blender, for opengl rendering. */ - -void GPU_state_init(void); - /* Mipmap settings * - these will free textures on changes */ diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index 9ce91d31d69..4daf3f8dba5 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -40,6 +40,12 @@ typedef enum eGPUFilterFunction { GPU_LINEAR, } eGPUFilterFunction; +/* Initialize + * - sets the default Blender opengl state, if in doubt, check + * the contents of this function + * - this is called when starting Blender, for opengl rendering. */ +void GPU_state_init(void); + void GPU_blend(bool enable); void GPU_blend_set_func(eGPUBlendFunction sfactor, eGPUBlendFunction dfactor); void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb, diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 5f3822c794e..7871907a7d4 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -1481,66 +1481,3 @@ void GPU_free_images_old(Main *bmain) ima = ima->id.next; } } - -static void gpu_disable_multisample(void) -{ -#ifdef __linux__ - /* changing multisample from the default (enabled) causes problems on some - * systems (NVIDIA/Linux) when the pixel format doesn't have a multisample buffer */ - bool toggle_ok = true; - - if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_UNIX, GPU_DRIVER_ANY)) { - int samples = 0; - glGetIntegerv(GL_SAMPLES, &samples); - - if (samples == 0) { - toggle_ok = false; - } - } - - if (toggle_ok) { - glDisable(GL_MULTISAMPLE); - } -#else - glDisable(GL_MULTISAMPLE); -#endif -} - -/* Default OpenGL State - * - * This is called on startup, for opengl offscreen render. - * Generally we should always return to this state when - * temporarily modifying the state for drawing, though that are (undocumented) - * exceptions that we should try to get rid of. */ - -void GPU_state_init(void) -{ - GPU_program_point_size(false); - - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - - glDepthFunc(GL_LEQUAL); - - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDisable(GL_COLOR_LOGIC_OP); - glDisable(GL_STENCIL_TEST); - - glDepthRange(0.0, 1.0); - - glFrontFace(GL_CCW); - glCullFace(GL_BACK); - glDisable(GL_CULL_FACE); - - gpu_disable_multisample(); - - /* This is a bit dangerous since addons could change this. */ - glEnable(GL_PRIMITIVE_RESTART); - glPrimitiveRestartIndex((GLuint)0xFFFFFFFF); - - /* TODO: Should become default. But needs at least GL 4.3 */ - if (GLEW_ARB_ES3_compatibility) { - /* Takes predecence over GL_PRIMITIVE_RESTART */ - glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); - } -} diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index e6092b55fc4..5af9364b92c 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -541,10 +541,6 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb) } #endif - if (fb->multisample) { - glEnable(GL_MULTISAMPLE); - } - glViewport(0, 0, fb->width, fb->height); } diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c index d6f044a79e3..908f5fa5771 100644 --- a/source/blender/gpu/intern/gpu_state.c +++ b/source/blender/gpu/intern/gpu_state.c @@ -370,4 +370,44 @@ void gpuPopAttr(void) #undef Attr #undef AttrStack +/* Default OpenGL State + * + * This is called on startup, for opengl offscreen render. + * Generally we should always return to this state when + * temporarily modifying the state for drawing, though that are (undocumented) + * exceptions that we should try to get rid of. */ + +void GPU_state_init(void) +{ + GPU_program_point_size(false); + + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDisable(GL_COLOR_LOGIC_OP); + glDisable(GL_STENCIL_TEST); + glDisable(GL_DITHER); + + glDepthFunc(GL_LEQUAL); + glDepthRange(0.0, 1.0); + + glFrontFace(GL_CCW); + glCullFace(GL_BACK); + glDisable(GL_CULL_FACE); + + /* Is default but better be explicit. */ + glEnable(GL_MULTISAMPLE); + + /* This is a bit dangerous since addons could change this. */ + glEnable(GL_PRIMITIVE_RESTART); + glPrimitiveRestartIndex((GLuint)0xFFFFFFFF); + + /* TODO: Should become default. But needs at least GL 4.3 */ + if (GLEW_ARB_ES3_compatibility) { + /* Takes predecence over GL_PRIMITIVE_RESTART */ + glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX); + } +} + /** \} */ diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index b1eee7509b7..70601ae5e42 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -84,11 +84,11 @@ #include "GPU_batch.h" #include "GPU_batch_presets.h" #include "GPU_context.h" -#include "GPU_draw.h" #include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_init_exit.h" #include "GPU_platform.h" +#include "GPU_state.h" #include "UI_resources.h" |