I'm having a problem where my textures are being rendered far darker than they actually are, and with a black outline, similar to this question: OpenGL Textures form SDLSurface goes too dark, However that solution isn't working for me, my rendering code is thus:
void BackgroundImage::render(int tile, Point2I offset)
{
//textures are being loaded in another thread.
texture_mutex.lock();
glEnable(GL_TEXTURE_2D);
if(!textures[tile].bind())
{
glDisable(GL_TEXTURE_2D);
texture_mutex.unlock();
return;
}
static GLint vertices[] =
{
0, -Tile::size.y, 0,
Tile::size.x, -Tile::size.y, 0,
Tile::size.x, 0, 0,
0, 0, 0
};
static GLfloat texCoord[] =
{
0, 1,
1, 1,
1, 0,
0, 0
};
static GLubyte indices[] =
{
0, 1, 2,
0, 2, 3
};
glPushMatrix();
glTranslatef(offset.x, -offset.y, 0);
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
glDisable (GL_COLOR_MATERIAL);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glColor3f(1.0f, 1.0f, 1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer (3, GL_INT, 0, vertices);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texCoord);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices);
glPopMatrix();
glDisable(GL_TEXTURE_2D);
texture_mutex.unlock();
}
Furthermore, the images get darker with every frame rendered until they go completely black (rendered using white as the clear color).