I am busy climbing the learning curve for OpenGL, using Delphi (pascal); I am using an excellent text, but every example in the book draws to the entire Form. I want to place an image component on the from, and draw to that. I tried assigning the Device context handle (GDC) to the handle of the image control’s canvas, rather than to the handle of the form, but that returns an error when ChoosePixelFormat is invoked.
So, if anyone knows how to get this to occur, I’d appreciate any suggestions.
Thanks in advance for any help.
jrDoner
I always use the following code to setup the window HWND for OpenGL output:
As you know (?), there is a huge difference between window handles (HWNDs) and device contexts (DCs). Every window has a HWND, and every window that you can draw to has a HDC. Given a form,
Handleis its HWND, andCanvas.Handleis its HDC.To get the DC associated with a window, you can use
GetDC(HWND).You have to setup OpenGL on a window, that is, on a HWND. So you cannot render OpenGL on a control without a window handle, such as a
TImage. Use aTPanelor some other decendant ofTWinControl.