Hi,

On Mon, 2009-06-22 at 14:29 +0200, Andreas Halm wrote:
> Hi,
> 
> I found the problem.
> 
> > hmm interesting it's stuck while logging. But nothing really indicates
> > why, it does not look like a loop, more like a lock or barrier. And it
> > is outside any OpenSG loop and also does not seem to hit OpenSG the
> > lock inside Log. Hmm, I'll have to think about it a little.
> 
> This was because wglMakeCurrent failed in WIN32Window::doActivate and
> therefore glGetError always returns an error in Window::doFrameExit -
> calling glGetError without a valid context is illegal. Therefore it never
> left the while loop in OSGWindow.cpp line 1527.
> 
> So now to why a call to wglMakeCurrent could possibly fail: My window class
> did not have the CS_OWNDC flag set, so every call to GetDC() might return a
> different, new handle. 

Using CS_OWNDC for OpenGL windows is strongly recommended as as far as I
remember from general OpenGL discussions, some drivers might not work
without it. I'll see if we can find a way to query for that so we can
warn if it is missing. Is there a reason why you would not want to set
it ?

> The handle that I set using WIN32Window::setHdc was
> correct, however OpenSG does overwrite it in WIN32Window::init
> (OSGWIN32Window.cpp line 116) which is obviously not the way to do it
> (otherwise the setHdc method is useless).
> 
> I would prefer init() something like:
> 
> {
>       bool we_used_getdc = false;
>       if (getHdc() == NULL) {
>               setHdc(GetDC(getHwnd()));
>               we_used_getdc = true;
>       }
> 
>     if(getHglrc() == NULL )
>     {
>         setHglrc(wglCreateContext(getHdc()));
>         
>         if(getHglrc() == NULL)
>         {
>             std::cerr << "WIN32Window::init: failed: "
>                       << GetLastError() 
>                       << std::endl;        
>         }
>     }
> 
>       if (we_used_getdc)
>               ReleaseDC(getHwnd(), getHdc());
> 
>     this->doActivate();
> 
>     Inherited::init(oFunc);
> 
>     this->doDeactivate();
> }
> 
> At least my application starts now and crashes later ...

this is only half the part, doRelease also contains a ReleaseDC with
no matching getDC in doActivate, so that too will fail without CS_OWNDC
set.

kind regards,
  gerrit




------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to