hi there
i want to have more than one texture in my program but the problem is that no matter which one i bind before drawing it always uses the texture that i built last here is my code :
GLuint texture[2];///space for 2 textures
…//in my initilization function
glEnable(GL_TEXTURE_2D);
…
void GenerateTexture(void) {
glGenTextures(2,&texture[0]);
HBITMAP hBMP;
BITMAP BMP;
byte crosshairtex[] = { IDB_CROSSHAIRMASK1 };
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(crosshairtex[0]),IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3,mesh.texsizex,mesh.texsizey, GL_RGB, GL_UNSIGNED_BYTE, mesh.texdata);
if (hBMP) {
GetObject(hBMP,sizeof(BMP), &BMP);
glPixelStorei(GL_UNPACK_ALIGNMENT,4);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, BMP.bmWidth, BMP.bmHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
DeleteObject(hBMP);
}
if(mesh.texdata)
free(mesh.texdata);
}
…//in my drawscene function
glBindTexture(GL_TEXTURE_2D,texture[0]);// here is the problem. what nomatter what i do here it always selects the same texture. what am i doing wrong?
DrawObject();
…