Drop redundant branching in GL.

Pointers are always set.
This commit is contained in:
Themaister 2012-09-14 21:35:32 +02:00
parent ca50a90c09
commit 5a4c51a5cb
2 changed files with 32 additions and 54 deletions

View File

@ -242,31 +242,19 @@ static void gl_set_coords(const struct gl_coords *coords)
{
pglClientActiveTexture(GL_TEXTURE0);
if (coords->vertex)
{
glVertexPointer(2, GL_FLOAT, 0, coords->vertex);
glEnableClientState(GL_VERTEX_ARRAY);
}
glVertexPointer(2, GL_FLOAT, 0, coords->vertex);
glEnableClientState(GL_VERTEX_ARRAY);
if (coords->color)
{
glColorPointer(4, GL_FLOAT, 0, coords->color);
glEnableClientState(GL_COLOR_ARRAY);
}
glColorPointer(4, GL_FLOAT, 0, coords->color);
glEnableClientState(GL_COLOR_ARRAY);
if (coords->tex_coord)
{
glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
glTexCoordPointer(2, GL_FLOAT, 0, coords->tex_coord);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
if (coords->lut_tex_coord)
{
pglClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
pglClientActiveTexture(GL_TEXTURE0);
}
pglClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(2, GL_FLOAT, 0, coords->lut_tex_coord);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
pglClientActiveTexture(GL_TEXTURE0);
}
#endif

View File

@ -1299,48 +1299,38 @@ bool gl_glsl_set_coords(const struct gl_coords *coords)
if (!glsl_enable || !glsl_modern)
return false;
if (coords->tex_coord)
int loc;
loc = pglGetAttribLocation(gl_program[active_index], "rubyTexCoord");
if (loc >= 0)
{
int loc = pglGetAttribLocation(gl_program[active_index], "rubyTexCoord");
if (loc >= 0)
{
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, 0, coords->tex_coord);
gl_attribs[gl_attrib_index++] = loc;
}
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, 0, coords->tex_coord);
gl_attribs[gl_attrib_index++] = loc;
}
if (coords->vertex)
loc = pglGetAttribLocation(gl_program[active_index], "rubyVertexCoord");
if (loc >= 0)
{
int loc = pglGetAttribLocation(gl_program[active_index], "rubyVertexCoord");
if (loc >= 0)
{
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, 0, coords->vertex);
gl_attribs[gl_attrib_index++] = loc;
}
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, 0, coords->vertex);
gl_attribs[gl_attrib_index++] = loc;
}
if (coords->color)
loc = pglGetAttribLocation(gl_program[active_index], "rubyColor");
if (loc >= 0)
{
int loc = pglGetAttribLocation(gl_program[active_index], "rubyColor");
if (loc >= 0)
{
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, 0, coords->color);
gl_attribs[gl_attrib_index++] = loc;
}
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, 0, coords->color);
gl_attribs[gl_attrib_index++] = loc;
}
if (coords->lut_tex_coord)
loc = pglGetAttribLocation(gl_program[active_index], "rubyLUTTexCoord");
if (loc >= 0)
{
int loc = pglGetAttribLocation(gl_program[active_index], "rubyLUTTexCoord");
if (loc >= 0)
{
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, 0, coords->lut_tex_coord);
gl_attribs[gl_attrib_index++] = loc;
}
pglEnableVertexAttribArray(loc);
pglVertexAttribPointer(loc, 2, GL_FLOAT, GL_FALSE, 0, coords->lut_tex_coord);
gl_attribs[gl_attrib_index++] = loc;
}
return true;