PDA

View Full Version : Can I make UI using texel modification on OpenGL?



onlysoda
03-20-2014, 07:57 PM
Can I make UI using texel modification on OpenGL?

I wonder how to make GUI like buttons, textbox, listbox and something like that.

I know I can manipulate texture pixel(texel). Have you tried that before?

Agent D
03-21-2014, 10:53 AM
Can I make UI using texel modification on OpenGL?
Yes.


I know I can manipulate texture pixel(texel). Have you tried that before?
Again, yes.


I wonder how to make GUI like buttons, textbox, listbox and something like that.
There are three possible things I can think of, having done that myself in the past:


Roll your own GUI library and draw things "manually" (actually, the CPU does it, not you) into a buffer, upload changes to the texture (glTexSubImage2D) and "display" the texture by rendering a rectangle (i.e. your GUI window)

Getting the things on the texture is the easy part. The harder part is implementing all the fancy widgets. Depending on your needs, the whole thing could be done quite fast.
You could use an existing 2D drawing library (e.g. Cairo or Anti Grain Geometry) to draw stuff to the buffer


Use an existing GUI library and convince it to draw to a buffer, then do the same thing as above

A few years back, I hacked together a canvas implementation for Qt 4 to render QT dialogs into a texture, paste it onto a 3D object, backproject the mouse position and send input to QT
QT is extremely bloated. There are tons of other GUI libraries out there (GTK+, FLTK, Fox, xclass, .... to name a few) that could probably be "convinced" to do the same thing
There are already "game GUI" libraries out there


Roll your own GUI library and drawing things on the fly using legacy/compatibillity profile functions (not what I would call "modifying texels")

onlysoda
03-23-2014, 03:23 AM
Thank for you reply. Really Thanks. Sir.