Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / wxGLCanvas implementation

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. wxGLCanvas implementation
#4725
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)
    {
        InitGL();
        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
#4727
Posted by: upCASE 2004-07-06 15:07:18
Hi!
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().
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: wxGLCanvas implementation
#4737
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.

Thx
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2022-9-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0