Jump to content
  • Advertisement
Sign in to follow this  
starfleetrp

OpenGL Troulbe loading BMP

This topic is 4444 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

Hi, I am using a class from a tutorial from ultimategameprogramming.com. The tut loads the image perfectly, however I can not seem to acheive the same result. I included the class into my code, and daclared the class as a public variable in one of my own classes. I call it like this: // This will load all the textures into memory. if(!Texture.LoadBitmap("image.bmp")) MessageBox(NULL,"Could not load water2.bmp","",MB_OK); //Texture.LoadBitmap("water2.bmp"); // Generate the texture id. glGenTextures(1, &Texture.ID); // Here we bind the texture and set up the filtering. Linear // gives up a nice look while NEAREST the quality is not as good. glBindTexture(GL_TEXTURE_2D, Texture.ID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Load the image data into the OpenGL texture that is currently // binded. gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, Texture.imageWidth, Texture.imageHeight, GL_RGB, GL_UNSIGNED_BYTE, Texture.image); And draw the image like: glBindTexture(GL_TEXTURE_2D, Texture.ID); glScalef(50,50,1); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Texture and Quad glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Texture and Quad glEnd(); However the image does not appear and all I get is a dull grey which changes to a blue, when my sprite moves... I have no idea what is going wrong, I am even using the image provided in the tut, just to make sure?

Share this post


Link to post
Share on other sites
Advertisement
Ok, well I tried another tut and now it works. I have no idea why it works now, because it worked in the other tut. However now that I have included an image everything seems to have gotten very dull. Before the colors were very vibrant, but as soon as the image was included everything went dull. If I specify an invlaid image path, so the image isnt used everything is bright and vibrant again. I am wondering why this is happening and how can I fix it?

Edit: Also when my sprite moves arround the image fades out and then to black, almost like alpha blending is effecting it. However I am not sure why, because it doesnt have an alpha channel and its just above my map/background layer which has an alpha of 100 or solid. This is also done in ortho. Could the alpha channel of the last item drawn be effecting the image, since it was done with a glColor4ub(...)? If so how could I also fix this?

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!