more tweaks to depth bits

This commit is contained in:
David Rose 2008-12-13 01:29:17 +00:00
parent af435acd5c
commit 28e082c7ea
2 changed files with 28 additions and 1 deletions

View File

@ -1,4 +1,5 @@
#include "zgl.h"
#include <limits.h>
/* fill triangle profile */
/* #define PROFILE */
@ -22,7 +23,16 @@ void gl_transform_to_viewport(GLContext *c,GLVertex *v)
+ c->viewport.trans.v[1] );
v->zp.z= (int) ( v->pc.v[2] * winv * c->viewport.scale.v[2]
+ c->viewport.trans.v[2] );
v->zp.z += (c->zbias << (ZB_Z_BITS - 8));
// Add the z-bias, if any. Be careful not to overflow the int.
int z = v->zp.z + (c->zbias << (ZB_POINT_Z_FRAC_BITS + 4));
if (z < v->zp.z && c->zbias > 0) {
v->zp.z = INT_MAX;
} else if (z > v->zp.z && c->zbias < 0) {
v->zp.z = -INT_MAX;
} else {
v->zp.z = z;
}
/* color */
v->zp.r=(int)(v->color.v[0] * (ZB_POINT_RED_MAX - ZB_POINT_RED_MIN)

View File

@ -491,6 +491,23 @@ void TinyGraphicsStateGuardian::
end_frame(Thread *current_thread) {
GraphicsStateGuardian::end_frame(current_thread);
#ifndef NDEBUG
static ConfigVariableBool td_show_zbuffer
("td-show-zbuffer", false,
PRC_DESC("Set this true to draw the ZBuffer instead of the visible buffer, when rendering with tinydisplay. This is useful to aid debugging the ZBuffer"));
if (td_show_zbuffer) {
PIXEL *tp = _current_frame_buffer->pbuf;
ZPOINT *tz = _current_frame_buffer->zbuf;
for (int yi = 0; yi < _current_frame_buffer->ysize; ++yi) {
for (int xi = 0; xi < _current_frame_buffer->xsize; ++xi) {
(*tp) = (int)(*tz);
++tz;
++tp;
}
}
}
#endif // NDEBUG
#ifdef DO_PSTATS
// Flush any PCollectors specific to this kind of GSG.
_vertices_immediate_pcollector.flush_level();