disply list

i want t create a menu with each entry display a shape
but i need the previously displayed ones to be still on the screen will the display list be helpful?
and how where i call it

OpenGL tends to be used in a double buffered rendering paradigm where the entire contents are redrawn each frame. It is not restricted to this but it is probably best to stick to it.

So you redraw everything in the menu every time you make a small change or addition.

Alternatively before you swap you could capture the backbuffer to memory and draw it to the screen bfore rendering and incremental changes OR you could render to the frontbuffer (not recommended).

[quote=dorbie]‘so you redraw everything in the menu every time you make a small change or addition.’
i can’t guess the sequence of choosing what will be drawn next so ,how can i do that?

‘Alternatively before you swap you could capture the backbuffer to memory and draw it to the screen bfore rendering and incremental changes’ how can i do this also???

i can’t guess the sequence of choosing what will be drawn next so ,how can i do that?

What Dorbie is saying is this.

Your application must retain a concept of what things are currently being shown on the screen. What menu is currently open, what objects are on display, etc. You must retain enough information to be able to completely redraw the scene. Thus, when this information changes, how you redraw the scene changes.

For example, you have some menu open on the screen. So in your application, you have a “menu object” that is open. This object says what the menu items are, where they are on screen, and which one the user is currently mousing over. If the user selects a menu item that causes the creation of some object, your GUI state removes the menu object and creates the thing the user asked for. Now your rendering state consists of no menu and some visual object the user selected.

Basically, you need to build your application as if what you draw is not kept around. Because it isn’t.

thax a lot for the replay :slight_smile:

‘Your application must retain a concept of what things are currently being shown on the screen. What menu is currently open’
how can i do that?
so, a display list will be helpful?and where can i call it?
plllllllllllllz help me i am very newbie in this field

Display lists are not really the best way for this IMHO.

You’re really only using them as a substitute for rendering code in this case and it’s not a good plan since your data may be dynamic in some ways.

The simplest way to do this right now is just redraw EVERYTHING.

Every time something changes in the menu redraw the entire menu. This is how a lot of 3D menus work and they do this because of the need to use doublebuffered rendering in combination with the invalidation of the backbuffer after swap (there are workarounds to this invalidation on some platforms).

Alternatively an image from glReadPixels drawn to the screen with glDrawpixels would be another way. Remember to call read before calling swap, then draw what you read back to the screen just after your swap and update with any changes before swapping again, whether you reread before the swap depends on whether you want the changes to be persistent.

Our answers assume some baseline understanding, some tutorials on basic double buffered rendering and animation may be helpful to you before you code GUIs in OpenGL.

thax a lot for the replay :smiley:

i am working on it right now i hope it will work :slight_smile: