mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
clear viewport
This commit is contained in:
parent
9787429186
commit
c72cf3f452
@ -25,6 +25,6 @@ void glopClear(GLContext *c,GLParam *p)
|
||||
/* TODO : correct value of Z */
|
||||
|
||||
ZB_clear(c->zb,mask & GL_DEPTH_BUFFER_BIT,z,
|
||||
mask & GL_COLOR_BUFFER_BIT,r,g,b);
|
||||
mask & GL_COLOR_BUFFER_BIT,r,g,b,0);
|
||||
}
|
||||
|
||||
|
@ -677,20 +677,30 @@ clear(DrawableRegion *clearable) {
|
||||
|
||||
set_state_and_transform(RenderState::make_empty(), _internal_transform);
|
||||
|
||||
int mask = 0;
|
||||
|
||||
bool clear_color = false;
|
||||
int r, g, b, a;
|
||||
if (clearable->get_clear_color_active()) {
|
||||
Colorf v = clearable->get_clear_color();
|
||||
glClearColor(v[0],v[1],v[2],v[3]);
|
||||
mask |= GL_COLOR_BUFFER_BIT;
|
||||
r = (int)(v[0] * 0xffff);
|
||||
g = (int)(v[1] * 0xffff);
|
||||
b = (int)(v[2] * 0xffff);
|
||||
a = (int)(v[3] * 0xffff);
|
||||
clear_color = true;
|
||||
}
|
||||
|
||||
bool clear_z = false;
|
||||
int z;
|
||||
if (clearable->get_clear_depth_active()) {
|
||||
glClearDepth(clearable->get_clear_depth());
|
||||
mask |= GL_DEPTH_BUFFER_BIT;
|
||||
// We ignore the specified depth clear value, since we don't
|
||||
// support alternate depth compare functions anyway.
|
||||
z = 0;
|
||||
clear_z = true;
|
||||
}
|
||||
|
||||
glClear(mask);
|
||||
|
||||
ZB_clear_viewport(_c->zb, clear_z, z,
|
||||
clear_color, r, g, b, a,
|
||||
_c->viewport.xmin, _c->viewport.ymin,
|
||||
_c->viewport.xsize, _c->viewport.ysize);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -712,24 +722,24 @@ prepare_display_region(DisplayRegionPipelineReader *dr,
|
||||
int xsize = GLsizei(w);
|
||||
int ysize = GLsizei(h);
|
||||
|
||||
int xsize_req=xmin+xsize;
|
||||
int ysize_req=ymin+ysize;
|
||||
int xsize_req = xmin + xsize;
|
||||
int ysize_req = ymin + ysize;
|
||||
|
||||
if (_c->gl_resize_viewport &&
|
||||
_c->gl_resize_viewport(_c,&xsize_req,&ysize_req) != 0) {
|
||||
_c->gl_resize_viewport(_c, &xsize_req, &ysize_req) != 0) {
|
||||
gl_fatal_error("glViewport: error while resizing display");
|
||||
}
|
||||
|
||||
xsize=xsize_req-xmin;
|
||||
ysize=ysize_req-ymin;
|
||||
xsize = xsize_req - xmin;
|
||||
ysize = ysize_req - ymin;
|
||||
if (xsize <= 0 || ysize <= 0) {
|
||||
gl_fatal_error("glViewport: size too small");
|
||||
}
|
||||
|
||||
_c->viewport.xmin=xmin;
|
||||
_c->viewport.ymin=ymin;
|
||||
_c->viewport.xsize=xsize;
|
||||
_c->viewport.ysize=ysize;
|
||||
_c->viewport.xmin = xmin;
|
||||
_c->viewport.ymin = ymin;
|
||||
_c->viewport.xsize = xsize;
|
||||
_c->viewport.ysize = ysize;
|
||||
|
||||
gl_eval_viewport(_c);
|
||||
}
|
||||
|
@ -293,21 +293,47 @@ void memset_RGB24(void *adr,int r, int v, int b,long count)
|
||||
}
|
||||
|
||||
void ZB_clear(ZBuffer * zb, int clear_z, int z,
|
||||
int clear_color, int r, int g, int b)
|
||||
int clear_color, int r, int g, int b, int a)
|
||||
{
|
||||
int color;
|
||||
int y;
|
||||
PIXEL *pp;
|
||||
|
||||
if (clear_z) {
|
||||
memset_s(zb->zbuf, z, zb->xsize * zb->ysize);
|
||||
}
|
||||
if (clear_color) {
|
||||
pp = zb->pbuf;
|
||||
for (y = 0; y < zb->ysize; y++) {
|
||||
color = RGB_TO_PIXEL(r, g, b);
|
||||
memset_l(pp, color, zb->xsize);
|
||||
pp = (PIXEL *) ((char *) pp + zb->linesize);
|
||||
}
|
||||
int color;
|
||||
int y;
|
||||
PIXEL *pp;
|
||||
|
||||
if (clear_z) {
|
||||
memset_s(zb->zbuf, z, zb->xsize * zb->ysize);
|
||||
}
|
||||
if (clear_color) {
|
||||
color = RGBA_TO_PIXEL(r, g, b, a);
|
||||
pp = zb->pbuf;
|
||||
for (y = 0; y < zb->ysize; y++) {
|
||||
memset_l(pp, color, zb->xsize);
|
||||
pp = (PIXEL *) ((char *) pp + zb->linesize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZB_clear_viewport(ZBuffer * zb, int clear_z, int z,
|
||||
int clear_color, int r, int g, int b, int a,
|
||||
int xmin, int ymin, int xsize, int ysize)
|
||||
{
|
||||
int color;
|
||||
int y;
|
||||
PIXEL *pp;
|
||||
unsigned short *zz;
|
||||
|
||||
if (clear_z) {
|
||||
zz = zb->zbuf + xmin;
|
||||
for (y = ymin; y < ymin + ysize; ++y) {
|
||||
memset_s(zz, z, xsize);
|
||||
zz += zb->xsize;
|
||||
}
|
||||
}
|
||||
if (clear_color) {
|
||||
color = RGBA_TO_PIXEL(r, g, b, a);
|
||||
pp = zb->pbuf + xmin;
|
||||
for (y = ymin; y < ymin + ysize; ++y) {
|
||||
memset_l(pp, color, xsize);
|
||||
pp = (PIXEL *) ((char *) pp + zb->linesize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,11 @@ void ZB_close(ZBuffer *zb);
|
||||
|
||||
void ZB_resize(ZBuffer *zb,void *frame_buffer,int xsize,int ysize);
|
||||
void ZB_clear(ZBuffer *zb,int clear_z,int z,
|
||||
int clear_color,int r,int g,int b);
|
||||
int clear_color,int r,int g,int b,int a);
|
||||
void ZB_clear_viewport(ZBuffer * zb, int clear_z, int z,
|
||||
int clear_color, int r, int g, int b, int a,
|
||||
int xmin, int ymin, int xsize, int ysize);
|
||||
|
||||
/* linesize is in BYTES */
|
||||
void ZB_copyFrameBuffer(ZBuffer *zb,void *buf,int linesize);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user