osgViewer not drawn properly in wxSplitterWindow (win32)

Reint Boer Iwema rboeriwema at virtualproteins.com
Tue Mar 4 05:52:02 PST 2008


Hello,

I've added the following code to the default osgViewerWX example of 
OpenSceneGraph (with cow.osg), in order to split the window vertically:

     ...
     attributes[5] = 8;

     wxSplitterWindow *m_splitter = new wxSplitterWindow(frame, 
wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);

     wxTextCtrl *m_textctrl = new wxTextCtrl(m_splitter, wxID_ANY, 
wxT("Some text"), wxDefaultPosition, wxDefaultSize);

     GraphicsWindowWX* gw = new GraphicsWindowWX(m_splitter, wxID_ANY, 
wxDefaultPosition, wxSize(width, height), wxSUNKEN_BORDER, 
wxT("osgviewerWX"), attributes);

     m_splitter->SplitVertically(m_textctrl, gw, 200);

     osgViewer::Viewer *viewer = new osgViewer::Viewer;
     ...

When the window is split is the following way, the blue background 
(clearColor?) is shown but not the cow:
* m_splitter->SplitVertically(m_textctrl, gw, 200);

If the window is split in other ways, the cow is drawn properly:
* m_splitter->SplitVertically(m_textctrl, gw, -200);
* m_splitter->SplitVertically(m_textctrl, gw, 0);
* m_splitter->SplitVertically(m_textctrl, gw);

Although the cow isn't shown on screen, the window is repainted 
constantly, as checked with the following code in the OnIdle function. 
This repaints the background constantly:

     ...
     float r = float(rand()) / float(RAND_MAX);
     float g = float(rand()) / float(RAND_MAX);
     float b = float(rand()) / float(RAND_MAX);

     _viewer->getCamera()->setClearColor(osg::Vec4(r, g, b, 1));
     _viewer->frame();
     ...

I'm not sure whether this is entirely a wxWidgets-problem because the 
wxWidgets-OpenGL examples (eg. the penguin) don't behave like this. So I 
posted this on the OpenSceneGraph-list as well.

I used:
* OpenSceneGraph 2.3.4;
* wxWidgets 2.8.7;
* Windows XP with VisualStudio 2005;
* Linux with gcc-4.2 works fine.

Thanks in advance,
Reint





More information about the wx-users mailing list