Cycles: viewport rendered draw mode now shows background images, also changed the

image editor checkerboard pattern to be the same as cycles viewport.
This commit is contained in:
Brecht Van Lommel 2012-03-28 09:07:10 +00:00
parent 30d128c7a7
commit 33740c5eb5
6 changed files with 39 additions and 51 deletions

@ -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()

@ -119,7 +119,6 @@ public:
bool draw_ready();
protected:
void draw_transparency_grid();
void device_free();
Device *device;

@ -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];

@ -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];

@ -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);

@ -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);