Jump to content
  • Advertisement
Sign in to follow this  
Kwak

OpenGL Program 'forgets' its display lists

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

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]

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

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!