Jump to content
  • Advertisement
Sign in to follow this  
Witchcraven

OpenGL I cant make OpenGL texture a quad.

This topic is 5037 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 am rather new to OpenGL, having no desire to make 3d games and all, but it turns out GL seemed like it would work rather well for a 2d game I am working on that needs to rotate and zoom every sprite every frame. So I stared simple, texturing a quad. And to my dismay, it just displays a white quad. Here is my code: glGenTextures(1, (ampersand get mangled)image[0]); glBindTexture(GL_TEXTURE_2D, image[0]); glTexImage2D(GL_TEXTURE_2D, 0, 3, ts->w, ts->h, 0, GL_RGB, GL_UNSIGNED_BYTE, ts->pixels); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); A little later: void blitImage(Pimage *image, int x, int y){ glBindTexture(GL_TEXTURE_2D, image->image[0]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2i(-100, -100); glTexCoord2f(1.0f, 0.0f); glVertex2i(100, -100); glTexCoord2f(1.0f, 1.0f); glVertex2i(100, 100); glTexCoord2f(0.0f, 1.0f); glVertex2i(-100, 100); glEnd(); } As far as I know, I adapted NeHe properly.

Share this post


Link to post
Share on other sites
Advertisement
You could use a larger texture than you need that encompasses the size you want. say you want to have a 100X200 texture, you would use a 128x256 and the use the UV coordinates clip to the 100x200 area with in the texture.

Share this post


Link to post
Share on other sites
That would work. Although that is just so...unclean :P Thanks. If I didnt know about that power of 2 thing I may ave just gone insane trying to fix a bug that was not even in 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!