Sign in to follow this  
Witchcraven

OpenGL I cant make OpenGL texture a quad.

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
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

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