diff --git a/source/blender/include/BIF_glutil.h b/source/blender/include/BIF_glutil.h index f530e7ba8d0..ed9096549ca 100644 --- a/source/blender/include/BIF_glutil.h +++ b/source/blender/include/BIF_glutil.h @@ -204,6 +204,7 @@ void bglVertex2fv(float *vec); /* intel gfx cards frontbuffer problem */ void bglFlush(void); int is_a_really_crappy_intel_card(void); +int is_a_really_crappy_nvidia_card(void); void set_inverted_drawing(int enable); diff --git a/source/blender/src/glutil.c b/source/blender/src/glutil.c index c4a7b32bf8c..69e3d4c7aac 100644 --- a/source/blender/src/glutil.c +++ b/source/blender/src/glutil.c @@ -290,17 +290,66 @@ static int get_cached_work_texture(int *w_r, int *h_r) return texid; } +#define FTOCHAR(val) val<=0.0f?0: (val>=1.0f?255: (char)(255.0f*val)) void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *rect) { - unsigned char *uc_rect= (unsigned char*) rect; - float *f_rect= (float *)rect; - float xzoom= glaGetOneFloat(GL_ZOOM_X), yzoom= glaGetOneFloat(GL_ZOOM_Y); - int ltexid= glaGetOneInteger(GL_TEXTURE_2D); - int lrowlength= glaGetOneInteger(GL_UNPACK_ROW_LENGTH); - int subpart_x, subpart_y, tex_w, tex_h; - int texid= get_cached_work_texture(&tex_w, &tex_h); - int nsubparts_x= (img_w+(tex_w-1))/tex_w; - int nsubparts_y= (img_h+(tex_h-1))/tex_h; + float *f_rect; + float xzoom, yzoom; + unsigned char *uc_rect; + int ltexid, lrowlength, texid, tex_w, tex_h; + int subpart_x, subpart_y, nsubparts_x, nsubparts_y; + + uc_rect= (unsigned char*) rect; + f_rect= (float *)rect; + +#ifdef __APPLE__ + /* On Nvidia, Mac OS X 10.5 this function doesn't work correct and + * can crash even, use glDrawPixels instead of textures then */ + if(is_a_really_crappy_nvidia_card()) { + float col[4], modcol[4]; + unsigned char *srect = rect; + int a; + + /* modulate with current color */ + glGetFloatv(GL_CURRENT_COLOR, col); + if(col[0]!=1.0f || col[1]!=1.0f ||col[2]!=1.0f ||col[3]!=1.0f) { + srect = MEM_callocN(4*img_w*img_h, "glDrawPixelsTexSafe"); + for(a=0; a=1.0f?255: (char)(255.0f*val)) void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf) { float *rf; @@ -717,6 +765,17 @@ int is_a_really_crappy_intel_card(void) return well_is_it; } +int is_a_really_crappy_nvidia_card(void) +{ + static int well_is_it= -1; + + /* Do you understand the implication? Do you? */ + if (well_is_it==-1) + well_is_it= (strcmp((char*) glGetString(GL_VENDOR), "NVIDIA Corporation") == 0); + + return well_is_it; +} + void bglFlush(void) { glFlush(); diff --git a/source/blender/src/mywindow.c b/source/blender/src/mywindow.c index cb8d233c341..6166ab18766 100644 --- a/source/blender/src/mywindow.c +++ b/source/blender/src/mywindow.c @@ -604,18 +604,6 @@ int framebuffer_to_index(unsigned int col) /* ********** END MY WINDOW ************** */ -#ifdef WIN32 -static int is_a_really_crappy_nvidia_card(void) { - static int well_is_it= -1; - - /* Do you understand the implication? Do you? */ - if (well_is_it==-1) - well_is_it= (strcmp((char*) glGetString(GL_VENDOR), "NVIDIA Corporation") == 0); - - return well_is_it; -} -#endif - void myswapbuffers(void) { ScrArea *sa;