From 33740c5eb56884929b70a394e5b3dc7ceb0cfc91 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 28 Mar 2012 09:07:10 +0000 Subject: [PATCH] Cycles: viewport rendered draw mode now shows background images, also changed the image editor checkerboard pattern to be the same as cycles viewport. --- intern/cycles/render/buffers.cpp | 28 +------------------ intern/cycles/render/buffers.h | 1 - source/blender/editors/include/BIF_glutil.h | 2 ++ source/blender/editors/screen/glutil.c | 25 +++++++++++++++++ .../blender/editors/space_image/image_draw.c | 25 ++--------------- .../editors/space_view3d/view3d_draw.c | 9 ++++++ 6 files changed, 39 insertions(+), 51 deletions(-) diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index dd0ebf7195c..c8d5dd2da8d 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -250,36 +250,10 @@ void DisplayBuffer::draw_set(int width, int height) draw_height = height; } -void DisplayBuffer::draw_transparency_grid() -{ - GLubyte checker_stipple_sml[32*32/8] = { - 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \ - 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \ - 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \ - 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \ - 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \ - 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, \ - 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \ - 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, \ - }; - - glColor4ub(50, 50, 50, 255); - glRectf(0, 0, params.width, params.height); - glEnable(GL_POLYGON_STIPPLE); - glColor4ub(55, 55, 55, 255); - glPolygonStipple(checker_stipple_sml); - glRectf(0, 0, params.width, params.height); - glDisable(GL_POLYGON_STIPPLE); -} - void DisplayBuffer::draw(Device *device) { - if(draw_width != 0 && draw_height != 0) { - if(transparent) - draw_transparency_grid(); - + if(draw_width != 0 && draw_height != 0) device->draw_pixels(rgba, 0, draw_width, draw_height, 0, params.width, params.height, transparent); - } } bool DisplayBuffer::draw_ready() diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index 3062e5ae3e4..77ad4a5a4b0 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -119,7 +119,6 @@ public: bool draw_ready(); protected: - void draw_transparency_grid(); void device_free(); Device *device; diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h index d75fac18c8c..ade34c43eec 100644 --- a/source/blender/editors/include/BIF_glutil.h +++ b/source/blender/editors/include/BIF_glutil.h @@ -47,6 +47,8 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1); void fdrawXORellipse(float xofs, float yofs, float hw, float hh); void fdrawXORcirc(float xofs, float yofs, float rad); +void fdrawcheckerboard(float x1, float y1, float x2, float y2); + /* glStipple defines */ extern unsigned char stipple_halftone[128]; extern unsigned char stipple_quarttone[128]; diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 28fe8caf34b..66abbaecbe7 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -191,6 +191,31 @@ void fdrawbox(float x1, float y1, float x2, float y2) glEnd(); } +void fdrawcheckerboard(float x1, float y1, float x2, float y2) +{ + unsigned char col1[4]= {40, 40, 40}, col2[4]= {50, 50, 50}; + + GLubyte checker_stipple[32*32/8] = { + 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, + 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, + 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, + 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, + 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, + 255,0,255,0,255,0,255,0,255,0,255,0,255,0,255,0, + 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, + 0,255,0,255,0,255,0,255,0,255,0,255,0,255,0,255, + }; + + glColor3ubv(col1); + glRectf(x1, y1, x2, y2); + glColor3ubv(col2); + + glEnable(GL_POLYGON_STIPPLE); + glPolygonStipple(checker_stipple); + glRectf(x1, y1, x2, y2); + glDisable(GL_POLYGON_STIPPLE); +} + void sdrawline(short x1, short y1, short x2, short y2) { short v[2]; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 59ca1925abf..684e541043a 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -393,28 +393,8 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) glEnd(); } -static void sima_draw_alpha_backdrop(float x1, float y1, float xsize, float ysize, float zoomx, float zoomy, unsigned char col1[3], unsigned char col2[3]) +static void sima_draw_alpha_backdrop(float x1, float y1, float xsize, float ysize, float zoomx, float zoomy) { - GLubyte checker_stipple[32*32/8] = - { - 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, - 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, - 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, - 255,255,0,0,255,255,0,0,255,255,0,0,255,255,0,0, - 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, - 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, - 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, - 0,0,255,255,0,0,255,255,0,0,255,255,0,0,255,255, - }; - - glColor3ubv(col1); - glRectf(x1, y1, x1 + zoomx*xsize, y1 + zoomy*ysize); - glColor3ubv(col2); - - glEnable(GL_POLYGON_STIPPLE); - glPolygonStipple(checker_stipple); - glRectf(x1, y1, x1 + zoomx*xsize, y1 + zoomy*ysize); - glDisable(GL_POLYGON_STIPPLE); } static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti) @@ -528,8 +508,7 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image } else { if (sima->flag & SI_USE_ALPHA) { - unsigned char col1[3]= {100, 100, 100}, col2[3]= {160, 160, 160}; - sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy, col1, col2); + fdrawcheckerboard(x, y, x + ibuf->x*zoomx, y + ibuf->y*zoomy); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b6ed8f65c68..59a19782f1d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2728,6 +2728,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) RegionView3D *rv3d = CTX_wm_region_view3d(C); RenderEngineType *type; + /* create render engine */ if (!rv3d->render_engine) { type = RE_engines_find(scene->r.engine); @@ -2738,13 +2739,21 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) type->view_update(rv3d->render_engine, C); } + /* setup view matrices */ view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL); + /* background draw */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ED_region_pixelspace(ar); + /* render result draw */ + if (v3d->flag & V3D_DISPBGPICS) + draw_bgpic(scene, ar, v3d); + else + fdrawcheckerboard(0, 0, ar->winx, ar->winy); + type = rv3d->render_engine->type; type->view_draw(rv3d->render_engine, C);