Just a silly little question for a silly newbie

Started by
8 comments, last by Zaphod- 22 years, 8 months ago
Hello, I am TOTALLY new to openGL, and I''ve been trying to do some basic stuff with these tutorials, but for a quick question, how do you just put in a bitmap at whatever coords. I''ve seen something like loadBMP("...") and some other predefined stuff for texturing, but is there some way for just 2d bitmaps to be shown at different places? I''ve seen the Zelda game here at NeHe, but I guess there is no available code for that, because that is exactly the idea of design I want to try as a project down the road. Thanks for your time, whomever this is! Zaphod-
Advertisement
No, there''s no way to natively just put a bitmap on the screen (OpenGL''s 3D, not 2D...). But you can do the following to achieve the same effect:
- start a 2d perspective (glOrtho2D() I /think/, I can''t remember exactly...)
- draw a quad textured with your bmp at whatever coordinates you want.

Remember that gl''s 0,0 is normally in the bottom left not the top left. You''ll need to load the texture and bind it etc as well. If you''ve looked through the tuts you should be able to figure out how to do that.

If I were you I''d make sure you understand how the first 10 or so tutorials work before you try much yourself (apart from fiddling with the tuts to learn about them). If you don''t understand how OpenGL works then you''ll find it very hard to do anything new yourself

Hope my explanation was clear enough; I''m pretty tired Feel free to reply back with all your questions...
I''m with Illuzion w/r/t going through the tutorials first; one point, however -- I believe that you can specify the viewport such that 0,0 is at the top-left corner of the screen. I''m not sure if this is considered kosher, but I''m a creature of habit, and like my origin up there.

- Thoams
So with this texturing of a square or other polynomial using glOrtho2D()... is it safe to say that openGL is more 3d, and I should probably learn something else if I want to use 2d?
ps, how many units are there on the screen? Does units translate to pixels?
Thanks a whole heap load
Zaphod-
use a projection matrix of gluOrtho2D(0,windowWidth,0,windowHeight);

now anthing u draw will be in the exact window coords

eg glBegin( GL_LINES )
glVertex2i(0,0)
glVertex2i(100,5)
glEnd();

will draw a line from the lower left hand of the window to the coord (100,5)

check my site for a couple of 2d opengl games
Oh and one more thing, when you do points like glTranslatef(), why is there an "f" after everthing ex:
glTranslatef(3.0f,0.0f,0.0f);
Why is there all these f''s everwhere? hehe
Thanks a lot
Zaph
The f indicates that floats are being used, as opposed to doubles, ints, or any other primitive type.


~~~~~~~~~~
Martee
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Illuzion: On the contrary, OpenGL can do both 2D and 3D check out glCopyPixels and similar functions.

the ''f'' after so many functions means that it should take floats as arguments. You can append a ''d'' to make it take doubles, i for integers, etc.

ex.

glTranslatef(1.0f, 1.0f, 1.0f);
glTranslated(1.0, 1.0, 1.0);
glTranslatei(1, 1, 1);
try learning DirectDraw
DirectDraw, that''s like graphics.h right?
so with Float you can get really exact right
like glTranslatef(3.0123f,3.0123f,3.0123f)?
What are the coords for the screen, or is that the matrix projection thing a replyer was talking about?
And in the tutorial it says that you should set depth to 6.0 generally.. any thoughts on that. And to finish my list of questions, is there any point to make 2d stuff if it isn''t easy. Why wouldn''t I just make 2d on the default 3d or some sheet...
A million thank yous
Zaphod-

This topic is closed to new replies.

Advertisement