Advertisement

so if opengl can render to any hwnd...

Started by May 09, 2005 12:18 PM
3 comments, last by adam17 19 years, 4 months ago
is it possible to render an gl window to any hwnd object? for example if you create a dialog box can you render to a rich edit box, static box, buttons, or custom controls?
yes, provided you take over drawing of that object and initalise an OpenGL context on the hwnd in question
Advertisement
so all i really need to do is

HDC hDC = GetDC(hWnd); //hWnd is the object
As Phantom said, you'll also need a GL context, which can be created using wglCreateContext.

HDC hDC = GetDC(hWnd); //hWnd is the objectHGLRC hglrc = wglCreateContext (hDC);// set the newly created context to render to the windowwglMakeCurrent (hDC, hglrc);


And of course you'll need to clean up when done. See the MSDN page linked above for more info.

-bodisiw
-bodisiw
ok this is all starting to make sense now. im trying to make several different rendering areas. what do i only need one of for the entire program and what do need per area? i have a seperate HWND, DC, and RC. they all share the same pixelformatdescriptor. i know something isnt right because im not seeing anything in the box. here is some of my code:

this portion is under the WM_PAINT msg in the window's proc
HWND tWnd = GetDlgItem(hWnd, IDC_COL_PALETTE);RECT rect;	GetClientRect(tWnd, ▭);DC = GetDC(tWnd);PixelFormat = ChoosePixelFormat(DC, &pfd);SetPixelFormat(DC, PixelFormat, &pfd);RC = wglCreateContext(DC);wglMakeCurrent(DC, RC);glViewport(0,0,rect.right - rect.left,rect.bottom - rect.top);glMatrixMode(GL_MODELVIEW);/****DRAW & INIT SCENE HERE****/


this is under the WM_CLOSE msg:
ReSizeGLScene(AppWidth, AppHeight);  //resets back to base app sizewglMakeCurrent(hDC, hRC);wglDeleteContext(RC);DestroyWindow(hWnd);


i doubt this has anything to do with it but im trying to render to a static box (that is not disabled) inside of a dialog box.

This topic is closed to new replies.

Advertisement