Can't get a HGLRC
Ok, I''ve some experience coding for OpenGL using a Win32 surface. Now I tried to use it in my existing MFC Application (Own Software3D before...), and it compiles fine and stuff, but I can''t create a GL-Window.
The code below runs fine (minimum security, I know) until the point I check if wglMakeCurrent really did create the rDC. The point is, wglMakeCurrent runs, but rDC stays NULL. Can anyone help me? I need to run it in MFC because of all the dialog and object stuff I use.
void CChildView::CreateGLWindow()
{
#define alert(x) MessageBox(x, "Status", MB_OK);
GLuint PixelFormat;
static PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0, 0, 0, 0, 0, 0,
0,
0,
0,
0, 0, 0, 0,
16,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
CPaintDC paintdc(this); // I was fooling around with this a bit but it didn''t really help
hDC = (HDC)paintdc; // no matter what type of DC I used
PixelFormat = ChoosePixelFormat(hDC, &pfd);
if (!SetPixelFormat(hDC, PixelFormat, &pfd)) alert("!SetPixelFormat");
if (!wglCreateContext(hDC)) alert("!wglCreateContext");
if (!wglMakeCurrent(hDC, hRC)) alert ("!wglMakeCurrent");
if (hDC == NULL) alert("hDC = NULL");
if (hRC == NULL) alert("hRC = NULL");
ResizeGLView(800, 600);
InitGL();
}
January 18, 2002 02:24 PM
change
if( !wglCreateContext( hDC ) ) alert( "!wglCreateContext" );
to
if( !(hRC = wglCreateContext( hDC )) ) alert( "!wglCreateContext" );
if( !wglCreateContext( hDC ) ) alert( "!wglCreateContext" );
to
if( !(hRC = wglCreateContext( hDC )) ) alert( "!wglCreateContext" );
Well, that solved that problem. Still, I can''t get the app to initialise OGL. I have definitely set the background to different colors and cleared it, but it won''t show any activity...
I had thought it wasn''t too much of a problem, going on to MFC with it, but I am being taught the opposite...
Can you please look for more dummy-errors?
I had thought it wasn''t too much of a problem, going on to MFC with it, but I am being taught the opposite...
Can you please look for more dummy-errors?
|
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement