• ### Announcements

#### Archived

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

# OpenGL Designing GUI in OpenGL

## Recommended Posts

I''m about to design a GUI in my OpenGL Game and now I''m wondering if I''m o use glOrtho or not.

##### Share on other sites
I think that''s what I would use.

##### Share on other sites
quote:
Original post by Metus
I''m about to design a GUI in OpenGL

designing anything comes from designer''s head and
it doesn''t relate to rc api in any mean.

##### Share on other sites
You could also use glPerspective, just set all the Z coordinates to 0.0f.

##### Share on other sites
quote:
Original post by Terran Marine
You could also use glPerspective, just set all the Z coordinates to 0.0f.

You could use a constant Z, but there are two problems.

Firstly, it''s harder to design an interface in that way. You can''t just say, I want this to be five pixels to the right of the screen''s edge, because it''s tricky (but not impossible) to figure out where that is.

Secondly, it just wouldn''t look right - the UI would be squished at the corners of the screen. The amount of squish depends upon how far away the surface is. To produce no squish, you''d have to place the plane at infinity, but in practice you can get a convincing effect with it nearer.

You should use glOrtho because it''s easier, and because it''s technically correct.

Signatures? We don''t need no steenking signatures!

##### Share on other sites
When it comes to GUI, gluUnProject and bitmap fonts are your friends, unless I don''t know what you''re talking about

##### Share on other sites
What exactly doesn Unprojecting do?

##### Share on other sites
gluUnproject converts mouse coordinates to world coordinates its useful if you want to find if a button drawn in openGL is clicked or something similar.

##### Share on other sites
I agree with Mayrel that trying to draw a GUI using a perspective projection is a bit pointless, and fraught with problems (think z-fighting and distortion).

The absolute best way to do 2D and GUI stuff (and probably the way OpenGL was designed to accomplish this), is to set an orthographic projection, disable depth testing, and simply draw back-to-front.

The extra-super-that''s-fantastic bonus you get when using OpenGL this way is that you can make the GUI totally resolution independent... just work with internal dimensions... e.g. assume an 800 x 600 (logical units) display area, and let OpenGL handle converting it to the actual resolution.

BTW Masonium, I would argue that bitmap fonts have been sent by Satan to rape and pillage and suck the life out of your otherwise fast app... but that''s just my opinion

I prefer to use texture-mapped fonts (quads with textures on them), as they are generally quicker.

##### Share on other sites
This topic came up on our local forum... heres the solution :

"Switch to glPerspective to draw your level then afterwards, change to glOrtho to draw the HUD, messages etc."

So you do so :

MainLoop
{
glPerspective();
DrawScene();
glOrtho();
DrawHub();
}

problem solved.....
pay us a visit : www.sagamedev.co.za

##### Share on other sites
I''ve been trying to get this to work, but everytime i try it, it either complains that ortho doesnt take 4 paramaters, or that the main drawing function doesnt take 0 paramaters.

##### Share on other sites
glOrtho doesn''t take 4 parameters... it takes 6:

left, right, bottom, top, near, and far clipping planes

gluOrtho2D takes 4 (IIRC, near and far are set to -1 and 1 respectively)

##### Share on other sites
I think a GUI in perspective mode would be pretty cool, you could have your windows going into the screen as well!

Of course, you can still get some cool effects in ortho mode, my favorite is when opening/closing new windows, you can make them rotate in, or flip in, or fade in, or zoom in, or any of a number of effects. Heh, Windows XP eat your heart out!

codeka.com - Just click it.

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627674
• Total Posts
2978558
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 11
• 11
• 10
• 12
• 22