I am fairly certain my textures are loaded without problem, however, I cannot get them to render!
I enable GL_TEXTURE_2D in when I initialize GL. I then load the texture with this function:
GLuint loadTexture(std::string filepath)
{
SDL_Surface *image;
if ( image = SDL_LoadBMP( filepath.c_str() ) )
{
GLuint tex_id;
glGenTextures( 1, &tex_id );
glBindTexture( GL_TEXTURE_2D, tex_id );
glTexImage2D( GL_TEXTURE_2D, 0, 3, image->w,
image->h, 0, GL_RGB,
GL_UNSIGNED_BYTE, image->pixels );
SDL_FreeSurface(image);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
textures.emplace(getFilename(filepath), tex_id);
glBindTexture(GL_TEXTURE_2D, 0);
return tex_id;
}
else
{
// std::cout << "[!!] Could not open " << filepath << "! \n";
return -1;
}
}
The texture is loaded, and then the texture name is placed in a map with the file name as a key. The map is a global defined as std::map <std::string, GLuint> textures. I can iterate through the map and verify that GL is assigning texture names properly. Finally, I go on to draw my quads as such:
glBindTexture(GL_TEXTURE_2D, textures["MY_IMAGE.BMP"]);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3d(0.0, 0.0, iNode->verticies[1]);
glTexCoord2f(1.0, 0.0);
glVertex3d(1.0, 0.0, iNode->verticies[2]);
glTexCoord2f(1.0, 1.0);
glVertex3d(1.0, 1.0, iNode->verticies[3]);
glTexCoord2f(0.0, 1.0);
glVertex3d(0.0, 1.0, iNode->verticies[4]);
glEnd();
A few things worth noting:
- Colors for these quads have been defined prior to drawing. If I
comment out all of the color definitions, which are in format
glColor3ub(r, g, b), the quads render black. - If I call
glIsTexture(textures["MY_IMAGE.BMP"]), it returns false. - The texture names are still stored properly in the map.
- I am using OpenGL 2.1.
Is the texture being somehow deleted internally? Am I doing something wrong with my rendering?
I am willing to supply more code if needed.
EDIT:
I have no idea what I did...
Now my renders look like this: 
glGetError()return anything after theglGenTextures()call? - genpfaultglPixelStorei(GL_UNPACK_ALIGNMENT, 1)beforeglTexImage2D(). - genpfault