Skip to main content
gamedev.net
🔒 Locked

Program 'forgets' its display lists

Started by Kwak 1 reply 550+ views
Original Post
Kwak
Kwak
I have a unit (cpp file and associated header file) wich contains the class of my form:
class TMain_Form : public TForm
{
__published:
    // Pointers to components
    ...
    // BasicFrameFunctions
    void __fastcall CreateMainForm(TObject *Sender);
    void __fastcall CloseMainForm(TObject *Sender, TCloseAction &Action);
    void __fastcall ResizeMainForm(TObject *Sender);
    // MainForm: Events
    ...
private:	// User declarations
    HDC hdcGridPanel;
    HDC hdcWorldPanel;
    HGLRC hrcGridPanel;
    HGLRC hrcWorldPanel;
    int PixelFormat;
    ...
public:		// User declarations
    __fastcall TMain_Form(TComponent* Owner);
    void __fastcall TMain_Form::SetPixelFormatDescriptor();
    void __fastcall TMain_Form::MainFormLoop(TObject*, bool&);
    ...
    // BasicGUIFunctions
    void __fastcall UpdateGridPanel();
    void __fastcall UpdateWorldPanel();
    ...
};


There is a function in the application that is looped. It calls the UpdateGridPanel and the UpdateWorldPanel functions. In another unit, i create a Display list that should exist until the form closes. For some reason the display list only works the first time it is called (that is immeadiately after it is created). After this it is just like the display list is empty. I heard that if you load textures, OpenGL automaticly clears the list of textures as soon as the window is closed or... (?) I thought the problem might be because i work with two hdc's (device contexts) and/ or two hrc's (rendering contexts). I'd better stop talking because i said more than i know So if you know why the display list doesn't work and/or what you can do about it, please let me know. greetings Kwak [Edited by - Kwak on April 21, 2006 9:59:06 AM]
Kalidor
Kalidor
Quote:
Original post by Kwak
...
I thought the problem might be because i work with two hdc's (device contexts) and/ or two hrc's (rendering contexts).
...
If you are trying to use the display list in both rendering contexts that is definitely a problem. Display lists, textures, VBOs, etc are context-specific. They can only be used in the context that created them or other contexts that share them with the creating context. To share them, use wglShareLists on Windows or its equivalent on other platforms. It seems odd that they work fine the first time you use them but after that they don't, unless of course the first time is within the creating context and the others aren't.

If that's not the problem I think we might need more code and/or a more detailed description of exactly what's going on.

Quote:
Original post by Kwak
...
I heard that if you load textures, OpenGL automaticly clears the list of textures as soon as the window is closed or... (?)
...
OpenGL is "managed" such that everything belonging to a context (such as textures) will be deleted when that owning context is deleted (or when the last context that references it, in the case of shared objects, is deleted). It's still a good idea to clean up after yourself though, plus for an application of any real size you will most likely need to load and unload things pretty frequently anyway.
Kwak
Kwak
Quote:
They can only be used in the context that created them or other contexts that share them with the creating context.

Yep I had made the display list while i was still in the wrong context.
Solved it with placing this before the display list's creation.
wglMakeCurrent(Main_Form->hdcGridPanel, Main_Form->hrcGridPanel);

I'll probably need the wglShareLists function later in my project.
Thanks for the clear explanation.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.