Roderick Colenbrander thunderbird2k@gmx.net writes:
Subject: [PATCH] Move WineD3D_CreateFakeGLContext and friends over to WGL. For this we need a HDC and one received from lets say GetDC(0) won't do. Further this HDC needs CS_OWNDC set. For this reason we need our own window class.
Why does it need CS_OWNDC? That sounds like a bug.
On Tuesday 07 August 2007 06:54:37 am Alexandre Julliard wrote:
Roderick Colenbrander thunderbird2k@gmx.net writes:
Subject: [PATCH] Move WineD3D_CreateFakeGLContext and friends over to WGL. For this we need a HDC and one received from lets say GetDC(0) won't do. Further this HDC needs CS_OWNDC set. For this reason we need our own window class.
Why does it need CS_OWNDC? That sounds like a bug.
I ran across mailing list posts a while ago talking about OpenGL on Windows, and it mentioned that the window class had to have CS_OWNDC otherwise strange anomolies and crashes could pop up. Stefan Dösinger also said it's implied that D3D windows need the same. Searching google for 'opengl cs_owndc' brought up pages that mentioned buggy drivers need it, and as well, opengl.org's FAQ has it mentioned:
"error: Multiple access violations appear when running a Microsoft OpenGL MFC-based application.
solution: Set the CS_OWNDC style in the PreCreate*() routines in the view class."
http://www.opengl.org/resources/faq/technical/gettingstarted.htm
I can't say I know much about how HDCs work, but since OpenGL operates on HDCs and expects their state to remain constant through the life of the window, wouldn't it be a problem if DCs switched after a call to SetPixelFormat, or while it's part of the current context?
Alexandre Julliard wrote:
Roderick Colenbrander thunderbird2k@gmx.net writes:
Subject: [PATCH] Move WineD3D_CreateFakeGLContext and friends over to WGL. For this we need a HDC and one received from lets say GetDC(0) won't do. Further this HDC needs CS_OWNDC set. For this reason we need our own window class.
Why does it need CS_OWNDC? That sounds like a bug.
I came across this today in the wxWidgets library. Although it's not clear it affects newer windows versions, this comment tries to explain, quoting src/msw/glcanvas.cpp:
/* From Angel Popov jumpo@bitex.com
Here are two snips from a dicussion in the OpenGL Gamedev list that explains how this problem can be fixed:
"There are 5 common DCs available in Win95. These are aquired when you call GetDC or GetDCEx from a window that does _not_ have the OWNDC flag. OWNDC flagged windows do not get their DC from the common DC pool, the issue is they require 800 bytes each from the limited 64Kb local heap for GDI."
"The deal is, if you hold onto one of the 5 shared DC's too long (as GL apps do), Win95 will actually "steal" it from you. MakeCurrent fails, apparently, because Windows re-assigns the HDC to a different window. The only way to prevent this, the only reliable means, is to set CS_OWNDC." */