Merge pull request #191 from cxd4/so_i_herd_u_liek_vertex_arrays
a couple minor improvements to Glitch64 geometry, vector processing
This commit is contained in:
commit
a347b829d1
|
@ -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);
|
||||||
|
|
|
@ -1786,26 +1786,41 @@ static void render_rectangle(int texture_number,
|
||||||
int src_width, int src_height,
|
int src_width, int src_height,
|
||||||
int tex_width, int tex_height, int invert)
|
int tex_width, int tex_height, int invert)
|
||||||
{
|
{
|
||||||
|
GLfloat planar_vertices[5][2];
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
|
planar_vertices[0][0] = ((int)dst_x - widtho) / (float)(width / 2);
|
||||||
|
planar_vertices[0][1] = -((int)dst_y - heighto) / (float)(height / 2) * invert;
|
||||||
|
planar_vertices[1][0] = ((int)dst_x - widtho) / (float)(width / 2);
|
||||||
|
planar_vertices[1][1] = -((int)dst_y + (int)src_height - heighto) / (float)(height / 2) * invert;
|
||||||
|
planar_vertices[2][0] = ((int)dst_x + (int)src_width - widtho) / (float)(width / 2);
|
||||||
|
planar_vertices[2][1] = -((int)dst_y + (int)src_height - heighto) / (float)(height / 2) * invert;
|
||||||
|
planar_vertices[3][0] = ((int)dst_x + (int)src_width - widtho) / (float)(width / 2);
|
||||||
|
planar_vertices[3][1] = -((int)dst_y - heighto) / (float)(height / 2) * invert;
|
||||||
|
planar_vertices[4][0] = ((int)dst_x - widtho) / (float)(width / 2);
|
||||||
|
planar_vertices[4][1] = -((int)dst_y - heighto) / (float)(height / 2) * invert;
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glMultiTexCoord2fARB(texture_number, 0.0f, 0.0f);
|
glMultiTexCoord2fARB(texture_number, 0.0f, 0.0f);
|
||||||
glVertex2f(((int)dst_x - widtho) / (float)(width/2),
|
glVertex2fv(planar_vertices[0]);
|
||||||
invert*-((int)dst_y - heighto) / (float)(height/2));
|
|
||||||
glMultiTexCoord2fARB(texture_number, 0.0f, (float)src_height / (float)tex_height);
|
glMultiTexCoord2fARB(texture_number, 0.0f, (float)src_height / (float)tex_height);
|
||||||
glVertex2f(((int)dst_x - widtho) / (float)(width/2),
|
glVertex2fv(planar_vertices[1]);
|
||||||
invert*-((int)dst_y + (int)src_height - heighto) / (float)(height/2));
|
|
||||||
glMultiTexCoord2fARB(texture_number, (float)src_width / (float)tex_width, (float)src_height / (float)tex_height);
|
glMultiTexCoord2fARB(texture_number, (float)src_width / (float)tex_width, (float)src_height / (float)tex_height);
|
||||||
glVertex2f(((int)dst_x + (int)src_width - widtho) / (float)(width/2),
|
glVertex2fv(planar_vertices[2]);
|
||||||
invert*-((int)dst_y + (int)src_height - heighto) / (float)(height/2));
|
|
||||||
glMultiTexCoord2fARB(texture_number, (float)src_width / (float)tex_width, 0.0f);
|
glMultiTexCoord2fARB(texture_number, (float)src_width / (float)tex_width, 0.0f);
|
||||||
glVertex2f(((int)dst_x + (int)src_width - widtho) / (float)(width/2),
|
glVertex2fv(planar_vertices[3]);
|
||||||
invert*-((int)dst_y - heighto) / (float)(height/2));
|
|
||||||
glMultiTexCoord2fARB(texture_number, 0.0f, 0.0f);
|
glMultiTexCoord2fARB(texture_number, 0.0f, 0.0f);
|
||||||
glVertex2f(((int)dst_x - widtho) / (float)(width/2),
|
glVertex2fv(planar_vertices[4]);
|
||||||
invert*-((int)dst_y - heighto) / (float)(height/2));
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
compile_shader();
|
compile_shader();
|
||||||
|
|
Loading…
Reference in New Issue