Guidance Forums / wxWidgets (wxWindows) in C++ / wxGLCanvas implementation

Search 搜索
Home Home

Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. wxGLCanvas implementation
Posted by: 2004-07-06 00:02:59
By looking at the code of the file cube.cpp (provided as sample with the WxWidgets source code), I noticed the following lines in the Render method:
    // Init OpenGL once, but after SetCurrent
    if (!m_init)
        m_init = true;

My question (quite simple) is the following:
Since this code has to be executed only once, is it not logical to write it in the construcor of the Class (which is derived from wxGLCanvas) instead of the Render method?

Message2. Re: wxGLCanvas implementation
Posted by: upCASE 2004-07-06 15:07:18
Yes, that would be quite logic. Maybe there's a problem with SetCurrent() when using it in the ctor, since the comment said InitGL() is to be called after SetCurrent().
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: wxGLCanvas implementation
Posted by: 2004-07-07 13:14:41
Thx for the answer.
It works for both cases anyway (under Windows XP at least).
Maybe it was coded out of the constructor because of some old habits...
Anyway, good programming habits should put this part of the code into the constructor or in a member function called by the constructor.

If anyone knows a valid reason to keep it in the render (or Paint) method, I would be please to get a short explanation.

Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
© Fri 2024-6-21  Guidance Laboratory Inc. Hits:0