Sign in to follow this  
0311

Simple Texture Mapping problem

Recommended Posts

I am trying to map a bmp onto a quad following this tutorial: http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=06 To my knowledge, I have included and linked everything correctly. All of my files including the bmp are in the correct directories. When I run the app, the quad shows white, but no bmp is showed. The bmp is 64 x 64 pixels. Like I said, it seems like I've followed all of the rules. I have texture mapped once before, but on a different machine that I believe was running .NET 2003. I am running .NET 2002. If it makes any difference, I have an ATI Radeon 9800 pro. Can anyone help me???

Share this post


Link to post
Share on other sites
Quote:

* Make sure you glEnable(GL_TEXTURE_2D).

* Try setting the minification/magnification and texture wrap texture parameters to something.


This has been done already. Does not appear to be the problem, but thanks anyway.

Share this post


Link to post
Share on other sites
um...

something like this happended to me recently. i don't know what went wrong, but i ended up resaving the bitmap and it loaded without any change in the code. I'm not even sure why, but it solved the problem. maybe there is something wrong with the bitmap itself.

Share this post


Link to post
Share on other sites
Quote:
Original post by MrBeaner
I don't know what went wrong, but i ended up resaving the bitmap and it loaded without any change in the code.
There is a lot of variation possible in the bitmap format, and many of the loaders I've seen don't handle all cases. So a bitmap saved by one program might work whereas the same bitmap saved by another program won't.

This should be easy to detect through debugging, though, since you won't have valid data to pass in.

Share this post


Link to post
Share on other sites
Quote:
Original post by Myopic Rhino
Quote:
Original post by Myopic Rhino
Quote:
Original post by MrBeaner
I don't know what went wrong, but i ended up resaving the bitmap and it loaded without any change in the code.
There is a lot of variation possible in the bitmap format, and many of the loaders I've seen don't handle all cases. So a bitmap saved by one program might work whereas the same bitmap saved by another program won't.

This should be easy to detect through debugging, though, since you won't have valid data to pass in.

Have you tried debugging to make sure that you're passing a valid array of data to glTexImage2D()? What is your minification filter set to?

A)This bmp that I'm using is recognized by another texture mapping .cpp file.
B)Everything passed to glTexImage2D()seems to be on par and both of my filters are set to GL_LINEAR.
C)I might be able to narrow this down though... I have 2 files. One has my loadbmp, texture conversion, draw and main entry point functions. The other has all of the info needed to set up an opengl window. I link both of them to a header file that declares the draw function. This might be where the problem is, but I can't figure out what I should do. Any ideas? Thanks for the replies btw.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kalidor
Can you post your texture generation code? That will give us a better understanding of what could be going wrong.

I hope this helps...please let me know if you need anything else. Thanks.

GLuint texture[1]; // Storage For One Texture ( NEW )

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc

AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle

if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}

File=fopen(Filename,"r"); // Check To See If The File Exists

if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}

return NULL; // If Load Failed Return NULL
}

int LoadGLTextures() // Load Bitmaps And Convert To Textures
{
int Status=FALSE; // Status Indicator
AUX_RGBImageRec *TextureImage[1]; // Create Storage Space For The Texture
memset(TextureImage, 0 ,sizeof(void *) * 1);// Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP("w_pawn.bmp"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(1, &texture[0]); // Create The Texture

// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
// Generate The Texture
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);// Linear Filtering
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering
}

if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
}

free(TextureImage[0]); // Free The Image Structure
}

return Status; // Return The Status
}

Share this post


Link to post
Share on other sites
OK, I figured it out and I apologize for being such a retard. I figured out that because I had split my functions into 2 files, I wasn't calling a couple of them and thus the texture never existed in the first place. Thanks for all of your help.

[Edited by - 0311 on February 16, 2005 11:40:46 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this