OpenGL Child Windows?

OK, I am working on a level editor for my OpenGL 3D game, but even though the child window is created, the level and textures are loaded, and OpenGL is initialized, it won’t draw ANYTHING on the screen! What’s up with that, can you not have a child window that is OpenGL? The program compiles with no errors and it runs fine (I have a logging function to lgo what it’s doing), but the window won’t show me ANYTHING. Any ideas?

Some code fragments would be good…

OK, here’s the code I use to create my OpenGL child window. Right now the editor is just the game engine, but I create a normal window and then create this OpenGL window as it’s child, as you see here.

BOOL CreateGLWindow(int bits)
{
static PIXELFORMATDESCRIPTOR pfd;
GLuint PixelFormat;
WNDCLASS wc;

glinst = minst;
wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = (WNDPROC)GLCalls;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = glinst;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = VIEW_CLASS_NAME;

if(!RegisterClass(&wc))
{
MessageBox(NULL, “Failed To Register The Window Class!”, “Startup Error”, MB_OK | MB_ICONEXCLAMATION);
return FALSE;
}

if(!(glwnd = CreateWindowEx(WS_EX_CLIENTEDGE, VIEW_CLASS_NAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, mwnd, (HMENU)ID_VIEW, glinst, NULL)))
{
KillGLWindow();
MessageBox(NULL, “OpenGL window creation error.”, “Error”, MB_OK | MB_ICONEXCLAMATION);
addlog(“Error: Couldn’t create an OpenGL window!”);
return FALSE;
}

pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = bits;
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;

if(!(gldc = GetDC(glwnd)))
{
KillGLWindow();
MessageBox(NULL, “Can’t create a GL device context.”, “Error”, MB_OK | MB_ICONEXCLAMATION);
addlog(“Error: Couldn’t create a GL device context!”);
return FALSE;
}

if(!(PixelFormat = ChoosePixelFormat(gldc, &pfd)))
{
KillGLWindow();
MessageBox(NULL, “Can’t find a suitable pixel format.”, “Error”, MB_OK | MB_ICONEXCLAMATION);
addlog(“Error: Couldn’t find a suitable pixel format!”);
return FALSE;
}

if(!SetPixelFormat(gldc, PixelFormat, &pfd))
{
KillGLWindow();
MessageBox(NULL, “Can’t set the pixel format.”, “OpenGL Error”, MB_OK | MB_ICONEXCLAMATION);
addlog(“Error: Couldn’t set a pixel format!”);
return FALSE;
}

if(!(hrc = wglCreateContext(gldc)))
{
KillGLWindow();
MessageBox(NULL, “Can’t create a GL rendering context.”, “OpenGL Error”, MB_OK | MB_ICONEXCLAMATION);
addlog(“Error: Couldn’t create the GL rendering context!”);
return FALSE;
}

if(!wglMakeCurrent(gldc, hrc))
{
KillGLWindow();
MessageBox(NULL, “Can’t activate the GL rendering context.”, “OpenGL Error”, MB_OK | MB_ICONEXCLAMATION);
addlog(“Error: Couldn’t activate the GL rendering context!”);
return FALSE;
}

ShowWindow(glwnd, SW_SHOW);
ResizeGLScene();

if(!InitGL())
{
KillGLWindow();
MessageBox(NULL, “Initialization failed.”, “OpenGL Error”, MB_OK | MB_ICONEXCLAMATION);
addlog(“Error: Could not initialize OpenGL!”);
return FALSE;
}

return TRUE;
}

Like I said, everythign else is the same as in the game, which works, so i can’t understand why the child window (takes up 1/4 of the parent) won’t display anything.

I recently tried the same thing and go the same result. It was suggested that I use wglMakeCurrent(…) to map the rendering context to the desired window before drawing. I haven’t tred it yet though (I don’t really know where to use it and haven’t had time to research). I assume it would be used in the OnPaint function though.

HI,
could it be in the CreateWindowEx function? I’ve heard that openGL requires WS_CLIPCHILDREN | WS_CLIPSIBLINGS in the third parameter.

	if (!(hWnd=CreateWindowEx(	dwExStyle,							// Extended Style For The Window
								"OpenGL",							// Class Name
								title,								// Window Title
								dwStyle |							// Defined Window Style
								WS_CLIPSIBLINGS |					// Required Window Style
								WS_CLIPCHILDREN,					// Required Window Style
								0, 0,								// Window Position
								WindowRect.right-WindowRect.left,	// Calculate Window Width
								WindowRect.bottom-WindowRect.top,	// Calculate Window Height
								NULL,								// No Parent Window
								NULL,								// No Menu
								hInstance,							// Instance
								NULL)))								// Dont Pass Anything To WM_CREATE

bye,
mathias_123

sorry, I meant in the 4th parameter.