Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CoolMike

OpenGL OpenGL bitmap blitting

This topic is 6512 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 have been learning a lot of openGL lately, but one thing I haven''t been able to figure out is how do I draw flat bitmaps at particular pixel locations on the screen? I want to be able to simply provide pixel coordinates (ex. 388, 100) and have my sprite drawn there. I want to be able to write a game in openGL much the way I already can in DirectDraw, but add all of the excellent 3D features of openGL. And I don''t want to use direct3D. I will eventually, but right now I want to focus on openGL, because it seems to be easier to learn. Any help would be appreciated. -Mike

Share this post


Link to post
Share on other sites
Advertisement
You have to set up of your projection matrix to be orthogonal so that it does not do perspective transformations... It''s best that you shut of your Z-BUFFER test (since your 2D engine will probably have its own z-sorting anyways) I''ve used code similar to the following to display the frame rate of my program using a texturemap of numbers.

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0f, screenWidth, 0.0f, screenHeight, -1.0f, 1.0f);

// disable the depth test so that the Z position of the
// numbers is irrelavant and they are drawn on top of
// everything else.
glDisable(GL_DEPTH_TEST);

glEnable(GL_TEXTURE_2D);

// -- DRAW YOUR QUADS --

glPopMatrix();

The only silliness is that the screen coordinates assume that (0, 0) is the lower left-hand corner of the screen, as opposed to the upper-right hand you may be more used to...

There are simple ways of remedying this in your code. I can''t exactly recall how to get OpenGL to fix it automatically, however.

There are several sources of information about this. I suggest you do a search with a reputable search engine for the string: OpenGL as a rasterizer


Good luck! Can''t wait to see what you come up with.

Danny

Share this post


Link to post
Share on other sites
Almost forgot!!! Before doing anything, make sure that your MODELVIEW Matrix is set to identity as well.

Danny

Share this post


Link to post
Share on other sites

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