Fbo / texture approach to create user windows


i dont arrive to see what is the best to use with the following needs:

i want to render a user interface inside a delimited window
this window will co exist with other windows inside the main OF window

the point of view of this interface can be movable by mouse
user select inside the window elements with mouse.
what is not inside of the window is not printed to screen

what is the best approach to print to screen this interface ? fbo ? tetxure object ?

i m dioscovering step by step OF, so i dont have a clear idea to wich tool is preferable for it


Personally i use an ofFbo because its more precise, acting like a mask. You also can check if the ui elements are inside the bounds that you need, with this you can choose if draw or not. But its not so precise like an fbo.

Also don’t forget to avoid the interaction with the user of the “hided” ui elements.

thanks lolo.
i m quite puzzled because i m not seeing any cropping of the fbo in its functions. resize ok, but cropping inside of it ?

do you know any example around ?

Ok i m just getting up this subject.

how to crop the FBO before printing it to screen ? or this should be done in another way ?

Think in the fbo like another screen.

ofFbo fbo;
fbo.allocate(320,240,GL_RGBA);  // create the texture, with alpha channel, if you don't need it, use GL_RGB. You need to make this one time, in the setup for example. (320,240) are the resolution of the fbo.

// in the update

// in the draw

If you between the “begin” and “end” draw something in the positions (-100,-100) you are drawing of the screen, so , that elements won’t be see, when you make the draw.

1 Like

Ah yes !!! indeed !!! thanks a lot, i was used to crop functions on other libs.
is the size of the FBO rescalable on the fly (size of the window) ?

No , you need to do that manually calling allocate!

ok thanks a lot lolo.
do you agree that drawing out of the fbo ( minus coordonates or coordonates out of the size of the fbo) is not ressource consumming ?

your welcome!

Mmm i dont know,technically youre charging data onto a texture. So i think its taking resources . You can check also the coordinates of the “to draw” objects, if they are out of bounds avoid the draw.
Also of you dont need alpha channel in your fbo,use GL_RGB instead of GL_RGBA

yep… but testing its presence takes also ressources… anyway thanks a lot :slight_smile: now pushing inside the troubles with ofxDatGui…

:ok_hand: !!!