Jump to content
  • Advertisement
Sign in to follow this  
xilup

OpenGL OpenGL GUI

This topic is 3177 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

First of all i would like to say hello to everybody, since this is my first post. For a couple of weeks i am working on a 2D side-scrolling game, and guess where i stuck, at the GUI system. You might say that it is simple to do one, or there are many other GUI libraries, but i want to do my own, after all, i am working on that game for fun and for learning. Where exactly i'm stucked? I want to draw all of my elements inside of a window space(client space).I thought maybe if i will render all my gadgets to a texture might work, but the window has to be a POT, so that is not to flexible.Also, doing a list box gadget i get stuck in the same place.I tried to draw only the elements that fir my list box size, but, if my list box height is like 5elements and a half, then it will look a little bit funny. I recently discovered that i can use a special OpenGL extension, GL_ARB_rect_texture, but my Video Card doesn't support that extension. An other way i tried to solve this problem is by resizing my viewport, repositioning it, and then call glOrtho().
glViewport(myWindowSize)
glOrtho(myWindowSize)
glDrawGadgets()
glViewport(glOriginalSize)
glOrtho(glOriginalSize)
That works, my gadget renders only inside the window rect, but i use the same way of rendering for the listbox
glViewport(myListBoxSize)
glOrtho(myListBoxSize)
for(x;x;x;) glDrawListBoxItem()
glViewport(glOriginalSize)
glOrtho(glOriginalSize)
Drawing a list box inside a window won't work. Is there any other way of doing this? How the other GUI libraries handle this?I tried reading the code but it is pretty hard, made to be understood only by pros i guess. Thank you everybody!Have a nice day!

Share this post


Link to post
Share on other sites
Advertisement
I render to a texture and simply make it POT over the display size and ignore the remainder.

Regarding the list box, either you need to force the height to be integral or implement partial drawing of text.

How do you draw the text, what functions do you use? Your own? The GDI? Bitmaps?

(i.e what does glDrawListBoxItem actually do to draw the text)

Share this post


Link to post
Share on other sites
Quote:
Original post by empirical2
I render to a texture and simply make it POT over the display size and ignore the remainder.

Regarding the list box, either you need to force the height to be integral or implement partial drawing of text.

How do you draw the text, what functions do you use? Your own? The GDI? Bitmaps?


I'm using FreeType2.
Anyway i found a better way to do all these things by using glScissor.
Thank you anyway!

Share this post


Link to post
Share on other sites
I was about to suggest glScissor.

And the other hand, as empirical2 suggested, use integral height. As I do in my GUI, which is self implemented (look at signature).

But why would the gadgets stick out of the GUI window?

Share this post


Link to post
Share on other sites
Sign in to follow this  

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