Down below in the code snippet you will see that I load a texture, then bind the ID.
I will complete this operation multiple times before finally using the actual id to texture map my cube.
Currently I'm completing these operations in the global scope like so:
Code:
typedef ResourceManager<ResourceTexture> TexManager;
TexManager Manager;
TexManager::Handle hTex0 = Manager.LoadResource( "axe.bmp" );
TexManager::Handle hTex1 = Manager.LoadResource( "grass.bmp" );
TexManager::Handle hTex0Again = Manager.LoadResource( "axe.bmp" );
const ResourceTexture &Tex0 = Manager.GetResource( hTex0 );
const ResourceTexture &Tex1 = Manager.GetResource( hTex1 );
const ResourceTexture &Tex0Again = Manager.GetResource( hTex0Again );
I have stepped through the process multiple times, I can confirm that each handle has a unique texture ID created by the function below, with glBindTexture.
Now I try to texture map:
glBindTexture(GL_TEXTURE_2D, Tex0.GetID());
When the program runs, I get no errors, and I would if something was amiss with the code I have.
The cube I have drawn on the screen that the function glBindTexture applies to comes up solid white, no texturing.
I was reading documentation on glBindTexture, and I found this snippet:
"Texture names are unsigned integers. The value zero is
reserved to represent the default texture for each texture
target. Texture names and the corresponding texture
contents are local to the shared display-list space (see
glXCreateContext) of the current GL rendering context; two
rendering contexts share texture names only if they also
share display lists."
I feel that this might have something to do with the problem, but I am unsure how to resolve it.
Code:
bool
ResourceTexture::LoadResource( const std::string &filename )
{
assert( 0 == m_Texture );
//add texture loading process here.
Bitmap image; // Create Storage Space For The Textures
image.Load(filename);
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if ( image.GetImg() != NULL ) // If Texture Image Exists
{
glGenTextures(1, &m_Texture); // Create The Texture
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, m_Texture);
glTexImage2D(GL_TEXTURE_2D, 0, 3, image.GetWidth(), image.GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.GetImg());
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
SetFilename( filename );
return true;
}
else
return false;
}