OpenGL and VC++ 2005 EE
-
Hi, i'm not sure if i've chosen correct place for my post, but I'm writing an app in VC++ 2005 EE which is going to display some 3D figures on System::Windows::Forms::Panel^ panel The problem: I've written my own class which handles all OpenGL stuff. So all I have to do is: Create new 3D figure object, and draw it with panel's Paint method. Constructor needs panel's HWND, so i did something like this:
TFigure *Figure; //pointer to my base class objects Figure = new TCuboid( (HWND)panel->Handle.ToPointer() , panel->Width, panel->Height, 3, 3, 7 );
But this solution doesn't work properly. When i'm trying to initialize OpenGl machine with this code (inside TCuboid construcor):m_gHDC = GetDC( hwnd ); //identifier (window HWND) SetupPixelFormat(); m_hRC = wglCreateContext( m_gHDC ); //identifier (OpenGL graphic context)
the variable: m_hRC is NULL and it shouldn't be. GetLastError() returns 2000, which is ERROR_INVALID_PIXEL_FORMAT. I've tried my class code with other IDE and all was fine. This is SetupPixelFormat() definition:void TFigure::SetupPixelFormat() { int nPixelFormat = 0; 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 }; nPixelFormat = ChoosePixelFormat( m_gHDC, &pfd ); SetPixelFormat( m_gHDC, nPixelFormat, &pfd ); }
ChoosePixelFormat( m_gHDC, &pfd ); returns 7 Can somebody help me please?