Hi,

On Wed, 2009-10-07 at 17:05 +0200, Johannes Brunen wrote:
> Hello,
> 
> initialization of class WIN32Window leads to problems.
> 
> I do have the following initialization code for a small windows viewer
> which fails on execution:
> 
> WIN32WindowUnrecPtr window = WIN32Window::create();
> window->setHwnd(_hWnd);
> window->init();
> window->deactivate();
> 
> The problem goes as follows:
> 
> window->init() calls ReleaseDC(...) prior to calling
> Inherited::init(oFunc) which uses the device context for setting the
> rendering context.
> 
> 
> If the class does not permanentely hold the device context it should set
> the member to NULL. This would then lead to a proper reinitialization
> the next time it is needed. In any case the order of the calls in
> window->init()
> 
> ReleaseDC(getHwnd(), getHdc());
> Inherited::init(oFunc);
> 
> should be swapped.
> 

that still is a weak point in the code (and copied from some other
online tutorial). It is still on my todo list to recheck it or at least
make it more robust. One question though, because you are not the first
one for which it fails, does the window class you register to create
your window (the one behind getHWND()) have the CS_OWNDC style bit
set ?. That one missing was usually the cause of problems.

With this bit set a single DC is attached to the window and the whole
GetDC/ReleaseDC cycle seem to be noops. And somewhere it was IIRC
written that OpenGL windows should (must) have CS_OWNDC set.

kind regards,
  gerrit


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to