Hello folks I need urgent help I am near to my deadline I am working on a small project similar to bloxorz. In this project the rendered box texture is not visible, I had used nehe opengl code to load bmp image and I had used same logic for render the box but I don't know where I am lacking please need a help.
I am pasting code below of Texture load of an image and draw the box funtions and attached the output photo. Please need good suggestions. Thanks in advance.
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 *TextureImageBox[1]; // Create Storage Space For The Texture
memset(TextureImageBox,0,sizeof(void *)*1); // Set The Pointer To NULL
// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImageBox[0]=LoadBMP("Data/Crate.bmp"))
{
Status=TRUE; // Set The Status To TRUE
glGenTextures(3, &texturebox[0]); // Create Three Textures
if (TextureImageBox[0]) // If Texture Exists
{
if (TextureImageBox[0]->data) // If Texture Image Exists
{
free(TextureImageBox[0]->data); // Free The Texture Image Memory
}
free(TextureImageBox[0]); // Free The Image Structure
}
return Status; // Return The Status
}
////////////////////////////////Texture//////////////////////////////////
int DrawGLBox(GLvoid) // Here's Where We Do All The Drawing
{
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glNormal3f(0,0,1);
//glTexCoord2f(0,1);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-2,0,4);
//glTexCoord2f(0,0);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-2,0,0);
//glTexCoord2f(1,0);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(0,0,0);
//glTexCoord2f(1,1);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(0,0,4);
One error I can see is the first quads texture coordinates are wrong - you have 2 with 1,0 coordinates. But that is not you main problem. Does "filter" have a valid value? Put a call to glError after you bind the texture to see if it is ok.
Thank you very much sir you are rite. I finished with texture mipmap but I had been stuck with the matter when the box is moved either left or right in the lean position the texture of top and bottom of the box texture changes to some other texture pattern but not same as start pattern I had observed that when ever the draw function called each time texture loads every time may be changes occurred due to this reason, still I am in dilemma is it correct or wrong Is there any solution for that how to maintain the const texture for respective plane. Thanks in advance.
I am not sure I understand you problem. The texture is mapped across the side of the box. This does not change as the image is rotated or translated; but the image will appear different as the box side is stretched because of the perspective view effect. Perhaps you could post 2 images showing me what is happening.
In the first picture when the box is rotated to its right as in the second picture the front face portion texture diagonal line strip is similar to previous stage but here the diagonal line strip should of in opposite side due to texture re draw its happening like this how to over come this sir. I appreciate your interest and Advance thanks for suggestions.
I haven't looked over your code again but I would look at the winding of your triangles. When an image is the wrong way around it is caused by one of two things
1) your uv coordinates at back to front
or
2) your triangle front face is say clockwise when you think it is counterclockwise and your are actually looking at the back of the triangle.
You can see if you are looking at the back of a triangle by enabling cull with glEnable(GL_CULL_FACE) and the triangle will vanish.