Advertisement

Pixel specific plotting...

Started by June 03, 2000 08:12 PM
2 comments, last by Bucket_Head 24 years, 8 months ago
Hey there. In my GL programming exploits, I have been learning a lot, and I''d like to first off give Jeff my thanks for setting up this site and for all the tutorials he has here. Now, onto what this post is about: I''d like to be able to render 2d images onto specific portions of the screen, in front of other 3d rendered objects behind them. What I speak of is similar to how it is in many 3d games, where you have your 3d view and a little HUD with bitmaps rendered on your screen. I''d like to be able to render it in such a way that you could use fractions between 0.0 and 1.0, such that when you change the resolution you are rendering at, the same image is in the same spot. I figure you could do something like this: Say you wanted a rectangular image to be on pixels 50,99 to 100,270 in a 640x480 res. Then you''d have it at 50/640,99/480 to 100/640,270/480. And so on and so forth. What''s the best way to set this up? If this is already covered in one of the tutorials, I apologize, but it wouldn''t hurt for someone to reiterate the technique specifically. Thank you very much for your time! - Hai, watashi no chichi no kuruma ga oishii deshita! ...or, in other words, "Yes, my dad's car was deliscious!"
- Hai, watashi no chichi no kuruma ga oishikatta desu!...or, in other words, "Yes, my dad's car was delicious!"
I think you might like glScale.

Eric Laberge
----------------------------------------"Inash neteia haeg joa kavari quilm..." SD4
Advertisement
Basically you render everything in 3D, then you render everything in 2D last. You can use the following code (not sure on speed though, I get fairly good results though), I think you might need glPushAttrib() & glPopAttrib() around it:

glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glOrtho( 0, 640, 0, 480, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();

// Draw 2D stuff here

glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );

Hope it helps, as for the drawing in 2D, I usually keep my 2D rendering in 640x480 (see above code) because it scales it all to the current resolution you''re rendering whether it''s 512x384 or 1024x768.

Morgan
Demon Lord - problem with glScale is, while it works fine in terms of 3D things, it doesn''t really help me get things lined up right in 2D...

Morgan - thank you very much! That got me on the way to getting it to work! I now have tex; YES! ...And onto bigger and better things; making a level editor for my game.

- Hai, watashi no chichi no kuruma ga oishii deshita!
...or, in other words, "Yes, my dad's car was deliscious!"
- Hai, watashi no chichi no kuruma ga oishikatta desu!...or, in other words, "Yes, my dad's car was delicious!"

This topic is closed to new replies.

Advertisement