diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-07-04 16:24:19 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-07-04 16:24:19 +0400 |
commit | 90162cb0cb4ad432a7453c7d5ec7de832a058f16 (patch) | |
tree | a83e17623392d53b40604e64fb779975aa3d5107 /source/blender | |
parent | ace570cb1024f0b3affd48b2f2104af3048d1707 (diff) |
Fix #21894: backface selection wasn't working correct with < 24 bits colors,
e.g. thousands of colors on OS X, due to use of uninitialized value. Problem
tracked down and patch provided by Shane Ambler, thanks!
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 16 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_draw.c | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_subwindow.c | 30 |
4 files changed, 16 insertions, 34 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 6b98ffdede7..5275f8988a8 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -61,7 +61,7 @@ int GPU_print_error(char *str); int GPU_glsl_support(void); int GPU_non_power_of_two_support(void); -int GPU_24bit_color_support(void); +int GPU_color_depth(void); /* GPU Types */ diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 4eaf969ee8a..0b7ea605ec8 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -71,7 +71,7 @@ static struct GPUGlobal { GLuint currentfb; int glslsupport; int extdisabled; - int color24bit; + int colordepth; GPUDeviceType device; GPUOSType os; GPUDriverType driver; @@ -93,7 +93,7 @@ void GPU_extensions_disable() void GPU_extensions_init() { - GLint bits; + GLint r, g, b; const char *vendor, *renderer; glewInit(); @@ -108,9 +108,11 @@ void GPU_extensions_init() if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0; if (!GLEW_ARB_fragment_shader) GG.glslsupport = 0; - glGetIntegerv(GL_RED_BITS, &bits); - GG.color24bit = (bits >= 8); - + glGetIntegerv(GL_RED_BITS, &r); + glGetIntegerv(GL_GREEN_BITS, &g); + glGetIntegerv(GL_BLUE_BITS, &b); + GG.colordepth = r+g+b; /* assumes same depth for RGB */ + vendor = (const char*)glGetString(GL_VENDOR); renderer = (const char*)glGetString(GL_RENDERER); @@ -178,9 +180,9 @@ int GPU_non_power_of_two_support() return GLEW_ARB_texture_non_power_of_two; } -int GPU_24bit_color_support() +int GPU_color_depth() { - return GG.color24bit; + return GG.colordepth; } int GPU_print_error(char *str) diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index d2afef3b117..5dbbf35796f 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -682,7 +682,7 @@ static int wm_automatic_draw_method(wmWindow *win) /* Windows software driver darkens color on each redraw */ else if(GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_WIN, GPU_DRIVER_SOFTWARE)) return USER_DRAW_OVERLAP_FLIP; - else if(!GPU_24bit_color_support()) + else if(GPU_color_depth() < 24) return USER_DRAW_OVERLAP; else return USER_DRAW_TRIPLE; diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index f512434a141..207b6cebfe6 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -45,6 +45,8 @@ #include "BIF_gl.h" +#include "GPU_extensions.h" + #include "WM_api.h" #include "wm_subwindow.h" #include "wm_window.h" @@ -301,28 +303,6 @@ void wmOrtho2(float x1, float x2, float y1, float y2) /* *************************** Framebuffer color depth, for selection codes ********************** */ -static int wm_get_colordepth(void) -{ - static int mainwin_color_depth= 0; - - if(mainwin_color_depth==0) { - GLint r, g, b; - - glGetIntegerv(GL_RED_BITS, &r); - glGetIntegerv(GL_GREEN_BITS, &g); - glGetIntegerv(GL_BLUE_BITS, &b); - - mainwin_color_depth= r + g + b; - if(G.f & G_DEBUG) { - printf("Color depth r %d g %d b %d\n", (int)r, (int)g, (int)b); - glGetIntegerv(GL_AUX_BUFFERS, &r); - printf("Aux buffers: %d\n", (int)r); - } - } - return mainwin_color_depth; -} - - #ifdef __APPLE__ /* apple seems to round colors to below and up on some configs */ @@ -331,7 +311,7 @@ unsigned int index_to_framebuffer(int index) { unsigned int i= index; - switch(wm_get_colordepth()) { + switch(GPU_color_depth()) { case 12: i= ((i & 0xF00)<<12) + ((i & 0xF0)<<8) + ((i & 0xF)<<4); /* sometimes dithering subtracts! */ @@ -361,7 +341,7 @@ unsigned int index_to_framebuffer(int index) { unsigned int i= index; - switch(wm_get_colordepth()) { + switch(GPU_color_depth()) { case 8: i= ((i & 48)<<18) + ((i & 12)<<12) + ((i & 3)<<6); i |= 0x3F3F3F; @@ -398,7 +378,7 @@ int WM_framebuffer_to_index(unsigned int col) { if (col==0) return 0; - switch(wm_get_colordepth()) { + switch(GPU_color_depth()) { case 8: return ((col & 0xC00000)>>18) + ((col & 0xC000)>>12) + ((col & 0xC0)>>6); case 12: |