Revision: 55357 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55357 Author: ton Date: 2013-03-17 17:32:45 +0000 (Sun, 17 Mar 2013) Log Message: ----------- Fix for "draw images as texture"
Zooming in on images in Image window now shows pixels again (was filtered). Now the glaDrawPixelsTex() and glaDrawPixelsAuto() have an argument to define if images should zoom in with linear filter, or draw pixels. Modified Paths: -------------- trunk/blender/source/blender/editors/include/BIF_glutil.h trunk/blender/source/blender/editors/interface/interface_draw.c trunk/blender/source/blender/editors/screen/glutil.c trunk/blender/source/blender/editors/space_file/file_draw.c trunk/blender/source/blender/editors/space_image/image_draw.c trunk/blender/source/blender/editors/space_node/drawnode.c trunk/blender/source/blender/editors/space_node/node_draw.c trunk/blender/source/blender/editors/space_view3d/drawobject.c trunk/blender/source/blender/editors/space_view3d/view3d_draw.c trunk/blender/source/blender/windowmanager/intern/wm_dragdrop.c Modified: trunk/blender/source/blender/editors/include/BIF_glutil.h =================================================================== --- trunk/blender/source/blender/editors/include/BIF_glutil.h 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/include/BIF_glutil.h 2013-03-17 17:32:45 UTC (rev 55357) @@ -141,17 +141,17 @@ * 1-to-1 mapping to screen space. */ -void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *rect); +void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect); /** * glaDrawPixelsAuto - Switches between texture or pixel drawing using UserDef. * only RGBA * needs glaDefine2DArea to be set. */ -void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, void *rect); +void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect); -void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, void *rect, float scaleX, float scaleY); +void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect, float scaleX, float scaleY); /* 2D Drawing Assistance */ Modified: trunk/blender/source/blender/editors/interface/interface_draw.c =================================================================== --- trunk/blender/source/blender/editors/interface/interface_draw.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/interface/interface_draw.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -453,8 +453,7 @@ float facy = (float)h / (float)ibuf->y; glPixelZoom(facx, facy); } - glaDrawPixelsSafe((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - //glaDrawPixelsTex((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsAuto((float)rect->xmin, (float)rect->ymin, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect); glPixelZoom(1.0f, 1.0f); Modified: trunk/blender/source/blender/editors/screen/glutil.c =================================================================== --- trunk/blender/source/blender/editors/screen/glutil.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/screen/glutil.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -482,7 +482,7 @@ return texid; } -void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, void *rect, float scaleX, float scaleY) +void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect, float scaleX, float scaleY) { unsigned char *uc_rect = (unsigned char *) rect; float *f_rect = (float *)rect; @@ -503,6 +503,7 @@ /* don't want nasty border artifacts */ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, zoomfilter); #ifdef __APPLE__ /* workaround for os x 10.5/10.6 driver bug: http://lists.apple.com/archives/Mac-opengl/2008/Jul/msg00117.html */ @@ -585,9 +586,9 @@ #endif } -void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void *rect) +void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect) { - glaDrawPixelsTexScaled(x, y, img_w, img_h, format, rect, 1.0f, 1.0f); + glaDrawPixelsTexScaled(x, y, img_w, img_h, format, zoomfilter, rect, 1.0f, 1.0f); } void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect) @@ -670,7 +671,7 @@ } /* uses either DrawPixelsSafe or DrawPixelsTex, based on user defined maximum */ -void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, void *rect) +void glaDrawPixelsAuto(float x, float y, int img_w, int img_h, int format, int zoomfilter, void *rect) { if (U.image_gpubuffer_limit) { /* Megapixels, use float math to prevent overflow */ @@ -678,7 +679,7 @@ if (U.image_gpubuffer_limit > (int)img_size) { glColor4f(1.0, 1.0, 1.0, 1.0); - glaDrawPixelsTex(x, y, img_w, img_h, format, rect); + glaDrawPixelsTex(x, y, img_w, img_h, format, zoomfilter, rect); return; } } Modified: trunk/blender/source/blender/editors/space_file/file_draw.c =================================================================== --- trunk/blender/source/blender/editors/space_file/file_draw.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/space_file/file_draw.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -376,7 +376,7 @@ /* the image */ glColor4f(1.0, 1.0, 1.0, 1.0); - glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_UNSIGNED_BYTE, imb->rect, scale, scale); + glaDrawPixelsTexScaled((float)xco, (float)yco, imb->x, imb->y, GL_UNSIGNED_BYTE, GL_NEAREST, imb->rect, scale, scale); /* border */ if (dropshadow) { Modified: trunk/blender/source/blender/editors/space_image/image_draw.c =================================================================== --- trunk/blender/source/blender/editors/space_image/image_draw.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/space_image/image_draw.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -525,7 +525,7 @@ display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); if (display_buffer) - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, display_buffer); + glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); IMB_display_buffer_release(cache_handle); Modified: trunk/blender/source/blender/editors/space_node/drawnode.c =================================================================== --- trunk/blender/source/blender/editors/space_node/drawnode.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/space_node/drawnode.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -3301,7 +3301,7 @@ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, display_buffer); + glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, display_buffer); glPixelZoom(1.0f, 1.0f); glDisable(GL_BLEND); @@ -3309,7 +3309,7 @@ else { glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, display_buffer); + glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, display_buffer); glPixelZoom(1.0f, 1.0f); } Modified: trunk/blender/source/blender/editors/space_node/node_draw.c =================================================================== --- trunk/blender/source/blender/editors/space_node/node_draw.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/space_node/node_draw.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -629,7 +629,7 @@ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */ glColor4f(1.0, 1.0, 1.0, 1.0); - glaDrawPixelsTex(prv->xmin, prv->ymin, preview->xsize, preview->ysize, GL_UNSIGNED_BYTE, preview->rect); + glaDrawPixelsTex(prv->xmin, prv->ymin, preview->xsize, preview->ysize, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect); glDisable(GL_BLEND); glPixelZoom(1.0f, 1.0f); Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c =================================================================== --- trunk/blender/source/blender/editors/space_view3d/drawobject.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/space_view3d/drawobject.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -611,7 +611,7 @@ glColor4fv(ob->col); /* Draw the Image on the screen */ - glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsTex(ofs_x, ofs_y, ima_x, ima_y, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); glDisable(GL_BLEND); Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c =================================================================== --- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -1819,7 +1819,7 @@ glPixelZoom(zoomx, zoomy); glColor4f(1.0f, 1.0f, 1.0f, 1.0f - bgpic->blend); - glaDrawPixelsAuto(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); + glaDrawPixelsAuto(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect); glPixelZoom(1.0, 1.0); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); Modified: trunk/blender/source/blender/windowmanager/intern/wm_dragdrop.c =================================================================== --- trunk/blender/source/blender/windowmanager/intern/wm_dragdrop.c 2013-03-17 16:54:06 UTC (rev 55356) +++ trunk/blender/source/blender/windowmanager/intern/wm_dragdrop.c 2013-03-17 17:32:45 UTC (rev 55357) @@ -323,7 +323,7 @@ drag_rect_minmax(rect, x, y, x + drag->sx, y + drag->sy); else { glColor4f(1.0, 1.0, 1.0, 0.65); /* this blends texture */ - glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, drag->imb->rect, drag->scale, drag->scale); + glaDrawPixelsTexScaled(x, y, drag->imb->x, drag->imb->y, GL_UNSIGNED_BYTE, GL_NEAREST, drag->imb->rect, drag->scale, drag->scale); } } else { _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs