Silly questions about Hwnd and HDC

Ole Jacob Hagen waterthrill at yahoo.no
Sat Nov 6 01:13:42 CET 2004


Hi.

As you already knows, I am making the opengl module.
But I have encountered some problems. It might be an error, bug or just 
me. ;-)

To create Context's for rendering, I need to have a valid HDC value.
To get the HDC -value (HDC = handle device context for GDI), which can 
be obtained by:
GetDC(WinID), where the WinId can be collected from winId = 
((QWidget*)d->paintDevice)->winId(), or can be set to NULL. I've 
experienced HDC values to 345432, and so on.

After I've collected the HDC aDc, and WId win,  and after choosing, 
setting and desribing the  pixelformat,then I want to create a context, 
with wglCreateContext(aDc), that has a rendering context, named rc as 
output.

all these functions fails:

1.  ChoosePixelFormat( hdc, pfd )
2.  SetPixelFormat( hdc, pixelFormat, pfd ))
3.  DescribePixelFormat( hdc, pixelFormat, sizeof( PIXELFORMATDESCRIPTOR 
), pfd ):
4.  wglCreateContext(aDc) fails.

1-3 can be found in the method choosePixelFormat, while 4 can be found 
in chooseContext.

I wonder if there could be something wrong with the winId and/or HDC value.
When I run the gear-example, and prints out the winId to the GearWidget, 
it gives me:
"gear.cpp: w.winId() = 969982032"
In the QGLContext::chooseContext( const QGLContext* shareContext ), the 
WinId is equal NULL, or another value.
They are never the same as the gear.cpp WinId. Is this right?

What behaviour is expected?

Sorry if my questions are totally wrong, but the opengl implementation 
needs both HDC and WId, to work on windows.

Cheers,

Ole J.







More information about the kde-cygwin mailing list