Jump to content
  • Advertisement
Sign in to follow this  
tomsh

OpenGL c++ opengl texture problem

This topic is 2480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I tried to draw a tringale, but the texture didn't work... it drew the triangle but with no a texture...

here the code(the relevant part of the code):



GLuint Texture;




load the texture:
[color="#222222"][font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"]

AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image{
FILE *File=NULL;
if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}
File=fopen(Filename,"r");
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()
{
int Status=FALSE;
AUX_RGBImageRec *TextureImage;
memset(TextureImage,0,sizeof(void *)*1);
if (TextureImage=LoadBMP("EnglishPic.bmp"))
{
Status=TRUE;
glGenTextures(3, &Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //
}
}


[/font]
[color="#222222"][font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"] [/font]
[color="#222222"][font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"] [/font]
[color="#222222"][font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"]draw the triangle:[/font]
[color="#222222"][font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"]int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix


glTranslatef(-1.5f,0.0f,-6.0f);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, Texture);
glBegin(GL_TRIANGLES);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(1.1f, 1.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(-0.5f,-1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f( 0.5f,-1.0f, 0.0f);
glEnd();

[/font]
[color="#222222"][font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"] [/font]
[font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"][color="#222222"]I used this tutorial: [/font][color="#222222"][font="Verdana, Arial, Arial, Calibri, Geneva, sans-serif"]http://nehe.gamedev...._mapping/12038/[/font]

why is it happand?

thank you all!

Share this post


Link to post
Share on other sites
Advertisement
thank you a lot. it works, it had another problem, I don't know excatly what she is, but I compared my code with NEHE's code and then I fixed my code...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!