Hi Gian

On 2/19/07, Gian Lorenzetto <[EMAIL PROTECTED]> wrote:

Hi Thibault,

>Great ! I like the simplicity of this viewer as there is no longer this
>complex event handling stuff. Better: I don't have the manipulator's
weird
>behaviour anymore. Almost (see below) everything runs smoothly.

Yeah, the original example was pretty complicated for what it did. Glad
you
like the new example!

>I compiled it against today's OpenSceneGraph SVN and wxWidgets 2.8.0(latest
>stable) without a hitch. At runtime, however, the cow would not appear
>unless I resize the window (and sometimes not at all). I'll dive in the
code
>and try to get rid of this behaviour.

First thing that comes to mind is to check that the OpenGL context is
created and
current when the OSG init code is called. I'm not sure how wx 2.8.xcreates the
context, but it might be a start ... will look into this myself tomorrow
if you don't
find anything.


I think I have found the "bug" - under Linux at least. In the
OsgGLCanvas::OnSize() method, you place the line
viewer_->getEventQueue()->windowResize(0, 0, w, h );
inside an if (GetContext()) condition. This causes the viewer not to
initially know its size, and thus not draw any object.
This event should be passed to the viewer independently of the context being
already created or not, i.e. you can place it above the condition.
The only code inside the condition would then be SetCurrent() then nothing
else. So except if we want to draw something in the OnSize() method - which
we should not in my opinion - we can remove this block altogether.
The OnSize() method thus becomes:

void OsgGLCanvas::OnSize(wxSizeEvent& event)
{
   // this is also necessary to update the context on some platforms
   wxGLCanvas::OnSize(event);

   // set GL viewport (not called by wxGLCanvas::OnSize on all
platforms...)
   int w, h;
   GetClientSize(&w, &h);

   // update the window dimensions, in case the window has been resized.
   viewer_->getEventQueue()->windowResize(0, 0, w, h );
}

Could you test it and see if it works on your platform ?

Just for the info: I used the attached Makefile, which I think does not
>conform at all to the OSG standards (as I am normally working under
Windows,
>I'm no Makefile expert), but does the job.

Might need to work out some way of sharing the source as this is going to
get
messy if we keep emailing zips ;)


Sure, the code I've just sent is another proof we need that :) I can set up
a dedicated SVN server and let you access it through an SSH tunnel if you
wish.

Cheers

--
Thibault
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to