(Glitch64) vectorized depth bias triangle strip vertices
This commit is contained in:
parent
c904115353
commit
a82947b5bd
|
@ -228,9 +228,13 @@ grDepthMask( FxBool mask )
|
||||||
float biasFactor = 0;
|
float biasFactor = 0;
|
||||||
void FindBestDepthBias()
|
void FindBestDepthBias()
|
||||||
{
|
{
|
||||||
|
GLfloat vertices[4][3];
|
||||||
float f, bestz = 0.25f;
|
float f, bestz = 0.25f;
|
||||||
int x;
|
int x;
|
||||||
if (biasFactor) return;
|
|
||||||
|
if (biasFactor)
|
||||||
|
return;
|
||||||
|
|
||||||
biasFactor = 64.0f; // default value
|
biasFactor = 64.0f; // default value
|
||||||
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
glPushAttrib(GL_ALL_ATTRIB_BITS);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
@ -242,14 +246,28 @@ void FindBestDepthBias()
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glColor4ub(255,255,255,255);
|
glColor4ub(255,255,255,255);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
for (x=0, f=1.0f; f<=65536.0f; x+=4, f*=2.0f) {
|
|
||||||
|
for (x = 0; x < 4; x++)
|
||||||
|
vertices[x][2] = 0.5;
|
||||||
|
|
||||||
|
for (x = 0, f = 1.0f; f <= 65536.0f; x += 4, f *= 2.0f) {
|
||||||
float z;
|
float z;
|
||||||
|
|
||||||
|
vertices[0][0] = float(x + 4 - widtho) / (width / 2);
|
||||||
|
vertices[0][1] = float(0 + 0 - heighto) / (height / 2);
|
||||||
|
vertices[1][0] = float(x + 0 - widtho) / (width / 2);
|
||||||
|
vertices[1][1] = float(0 + 0 - heighto) / (height / 2);
|
||||||
|
vertices[2][0] = float(x + 4 - widtho) / (width / 2);
|
||||||
|
vertices[2][1] = float(0 + 4 - heighto) / (height / 2);
|
||||||
|
vertices[3][0] = float(x + 0 - widtho) / (width / 2);
|
||||||
|
vertices[3][1] = float(0 + 4 - heighto) / (height / 2);
|
||||||
glPolygonOffset(0, f);
|
glPolygonOffset(0, f);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
glBegin(GL_TRIANGLE_STRIP);
|
||||||
glVertex3f(float(x+4 - widtho)/(width/2), float(0 - heighto)/(height/2), 0.5);
|
glVertex3fv(vertices[0]);
|
||||||
glVertex3f(float(x - widtho)/(width/2), float(0 - heighto)/(height/2), 0.5);
|
glVertex3fv(vertices[1]);
|
||||||
glVertex3f(float(x+4 - widtho)/(width/2), float(4 - heighto)/(height/2), 0.5);
|
glVertex3fv(vertices[2]);
|
||||||
glVertex3f(float(x - widtho)/(width/2), float(4 - heighto)/(height/2), 0.5);
|
glVertex3fv(vertices[3]);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
glReadPixels(x+2, 2+viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
|
glReadPixels(x+2, 2+viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
|
||||||
|
|
Loading…
Reference in New Issue