i spent to weeks solid trying to get texture mapping to work but i kept on getting all sorts of linker errors, like unresolved external LoadDIBimageA or sumthing like that and everyone i asked said it was the glaux lib either i didnt link it or it was damaged but i definatly linked it so i deleted all the glaux rubbish and found some code which didnt need the glaux lib, and after 10 minits it worked perfect. so take overminds word for it, the glaux lib is junk.
here is the steps for loading a bitmap;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration for WndProc
Underneath, the code above, in your programm(its near the start)put in the code below;
bool LoadBitmap(LPTSTR szFileName, GLuint &texid)
HBITMAP hBMP;
BITMAP BMP;
glGenTextures(1, &texid);
hBMP=(HBITMAP)LoadImage(GetModuleHandle(NULL), szFileName, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
if (!hBMP)
return FALSE;
GetObject(hBMP, sizeof(BMP), &BMP);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glBindTexture(GL_TEXTURE_2D, texid);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, BMP.bmWidth, BMP.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, BMP.bmBits);
DeleteObject(hBMP);
return TRUE;
}
After you have entered that go to the
int InitGL(GLvoid)
part and enter, before
return true;
this part of code
if (!LoadBitmap(“Data/(this is the name of your bimap ie its saved name which is put into a folder named Data. The Data folder is placed with the project and unit code wherever u saved that. ps The brackets around this are not here).bmp”, texture[0]))
{
return FALSE;
}
after this is in, go to the drawglscene part of the code and draw a normal square except before u do glBegin(QUADS) enter this
glBindTexture(GL_TEXTURE_2D, texture[0]);
after that u need to enter the coord points, which are entered before the each of these
glVertex3f(-1.0f, -1.0f, 1.0f);
the coord pionts are these
glTexCoord2f(0.0f, 0.0f);
and the second coord point would be
glTexCoord2f(1.0f, 0.0f);
then
glTexCoord2f(1.0f, 1.0f);
then
glTexCoord2f(0.0f, 1.0f);
notice they always go round in a anticlockwise direction so make sure u draw ur shape in a anticlockwise direction.
hope that helps if u dont understand anything just reply