View Full Version : 2d work and 3d
04-30-2000, 04:06 PM
could someone explain to me how does the opengl interacts with 2d and 3d?
For example if i wan't to make a bar in 2d on the top of the screen, and then a cube rotating, what do i have to do?
I know it has something to do with the glortho and glmatrixmode, but i really don't understand....
05-02-2000, 10:09 PM
Heh...good luck getting 2D to work in OpenGL without your framerate dropping to say 1 frame per 10 seconds http://www.opengl.org/discussion_boards/ubb/tongue.gif
what? 2d is just 3d but without the depth. and, no, that's not a silly thing to say.
(opengl 2D is drawing on a PLANE with z=0 in three dimensions. same thing....)
05-03-2000, 01:51 AM
John's right, 2D need not be a performance issue in OpenGL if you do it right. The only real problem is if you're coming from DOS and are used to having direct access to the framebuffer. In which case, you need to get over it, because those days are gone.
05-03-2000, 07:08 AM
Use this 2 functions:
After calling Enter2dMode() you have (0,0) at upper left corner of screen, and (1,1) at lower right corner. Now you can use glVertex2f() to specify 2d coords. After you've done your 2d work you can return to previous state with Exit2dMode().
05-03-2000, 01:05 PM
thanks a lot
Humus is proposing a unit square reference frame for 2D work in OpenGL. This does have it's merits, because it's sometimes more logical/easier to think of placement as a proportion of the window.
An alternative is to map the projection matrix to the pixels, so you'd have left=top=0 and right=width and bottom=height of the screen. That way you can say glVertex(5,5) maps to the pixel 5,5 of the screen.
Both techniques, i would argue, have their place.
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.