From 7784ea53bf3865c0cf6725611034da771b4535bf Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 17 Jun 2006 17:07:49 +0000 Subject: [PATCH] Also for new 'to image window' rendering, drawing of float buffers while rendering now is full 32 bits. This gives drawing issues in some cards, like ATIs. Copied the function used for renderwindow to glutil.c, and used now in the image window. --- source/blender/include/BIF_glutil.h | 6 +++++ source/blender/src/drawimage.c | 2 +- source/blender/src/glutil.c | 36 +++++++++++++++++++++++++---- source/blender/src/renderwin.c | 31 +------------------------ 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/source/blender/include/BIF_glutil.h b/source/blender/include/BIF_glutil.h index 0edc73eee2d..48d4d903d28 100644 --- a/source/blender/include/BIF_glutil.h +++ b/source/blender/include/BIF_glutil.h @@ -139,6 +139,12 @@ void glaDrawPixelsSafe (float x, float y, int img_w, int img_h, int row_w, int * modelview and projection matrices are assumed to define a * 1-to-1 mapping to screen space. */ + + /* only for float rects, converts to 32 bits and draws */ + /* uses threadsafe malloc */ +void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, float *rectf); + + void glaDrawPixelsTex (float x, float y, int img_w, int img_h, int format, void *rect); /* 2D Drawing Assistance */ diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c index f927028bfe6..2e3636685cb 100644 --- a/source/blender/src/drawimage.c +++ b/source/blender/src/drawimage.c @@ -1930,7 +1930,7 @@ static void imagewindow_progress(ScrArea *sa, RenderResult *rr, volatile rcti *r if(rect32) glaDrawPixelsSafe(x1, y1, xmax, ymax, rr->rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect32); else - glaDrawPixelsSafe(x1, y1, xmax, ymax, rr->rectx, GL_RGBA, GL_FLOAT, rectf); + glaDrawPixelsSafe_to32(x1, y1, xmax, ymax, rr->rectx, rectf); glPixelZoom(1.0, 1.0); diff --git a/source/blender/src/glutil.c b/source/blender/src/glutil.c index 4cdc65f621c..ef6728c1a0a 100644 --- a/source/blender/src/glutil.c +++ b/source/blender/src/glutil.c @@ -34,17 +34,16 @@ #include -#ifdef HAVE_CONFIG_H -#include -#endif - #include "MEM_guardedalloc.h" #include "DNA_vec_types.h" +#include "DNA_listBase.h" #include "BKE_utildefines.h" #include "BLI_arithb.h" +#include "BLI_threads.h" + #include "BIF_gl.h" #include "BIF_glutil.h" @@ -286,6 +285,35 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void * glPixelStorei(GL_UNPACK_ROW_LENGTH, lrowlength); } +#define FTOCHAR(val) val<=0.0f?0: (val>=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; + int x, y; + char *rect32, *rc; + + /* copy imgw-imgh to a temporal 32 bits rect */ + if(img_w<1 || img_h<1) return; + + /* happens during threaded render... */ + rc= rect32= MEM_mallocT(img_w*img_h*sizeof(int), "temp 32 bits"); + + for(y=0; y=1.0f?255: (char)(255.0f*val)) -static void glaDrawPixelsSafe_to32(float fx, float fy, int img_w, int img_h, int row_w, int format, int type, float *rectf) -{ - float *rf; - int x, y; - char *rect32, *rc; - - /* copy imgw-imgh to a temporal 32 bits rect */ - if(img_w<1 || img_h<1) return; - - /* happens during threaded render... */ - rc= rect32= MEM_mallocT(img_w*img_h*sizeof(int), "temp 32 bits"); - - for(y=0; yrectx, GL_RGBA, GL_UNSIGNED_BYTE, rect32); else - glaDrawPixelsSafe_to32(fullrect[0][0], fullrect[0][1], xmax, ymax, rr->rectx, GL_RGBA, GL_FLOAT, rectf); + glaDrawPixelsSafe_to32(fullrect[0][0], fullrect[0][1], xmax, ymax, rr->rectx, rectf); glPixelZoom(1.0, 1.0);