PDA

View Full Version : texture mapping



Andrew Waller
10-28-2005, 06:58 AM
Hi all, when I try to map this texture Im getting just a white box as if to show texture not found. the image is in the same directory as the cpp files and project. can anyone please tell me what Im doing wrong?

if (TextureImage[0]=LoadBMP("test.bmp"))
{
Status=TRUE; // Set The Status To TRUE

glGenTextures(3, &texture[0]); // Create Three Textures

// Create Nearest Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

// Create Linear Filtered Texture
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);

// Create MipMapped Texture
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}

jide
10-28-2005, 07:20 AM
Can you ensure in LoadBMP that the function can access the file you enter in argument ?

Notes: if you don't stipple and directory for your texture, the program will expect to find it in the same directory where it resides (where you click on the exe).

Andrew Waller
10-28-2005, 07:28 AM
yea I have the file in the same directory its odd cause when I use a different bitmap file it works no problem. its just when I changed the bitmap file now it just gives a white background.

Aeluned
10-28-2005, 07:33 AM
are you sure the image you are using is a power of two dimension?

Andrew Waller
10-28-2005, 07:43 AM
yea thats what it is it works fine now I resized it to 256*256 thanks for that. I have a new problem now though lol. I want to soomth the image so that I dont see the edges any idea how I can do this?

Aeluned
10-28-2005, 07:58 AM
I'm assuming you rendered the image as a texture mapped quad. Are the edges you are talking about the aliased edges of the quad (this has nothing to do with the image).

You can enable multisampling in recent graphics cards to deal with this problem. This can sometimes be turned on using the driver application (usually embeded in the display adapter properties dialog) or can be forced on in your application using the GL_MULTISAMPLE_ARB extension.

Andrew Waller
10-28-2005, 08:25 AM
ok how do I use GL_MULTISAMPLE_ARB? where in the code should I declare this for use and then use it? can u give me an example?

Aeluned
10-28-2005, 08:40 AM
here is a demo from NeHe on using the extension:
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=46