Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Arrow Mk84

Problem with Choosing Pixel Format

This topic is 5888 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m having a problem with creating an OpenGL window. What happens is that regardless of what my pixel format description is, ChoosePixelFormat always returns zero. Everything before that point works perfectly. I''ve tried several PFDs, including ones that work from downloaded tutorial/example source. Any ideas as to what is causing my problems? Thanks.
void OpenGLWindow::CreateOGLWindow(int mode, HINSTANCE hInstance, WNDPROC windowsProcedure)
	/* Create Window */
		// add in resolution switching and a switch/case statement for mode
		CreateBaseWindow(hInstance, windowsProcedure, CS_HREDRAW | CS_VREDRAW, WS_OVERLAPPEDWINDOW | WS_SYSMENU, 100, 100, 800, 600);
	catch(BaseWindowError bwe)
		throw OpenGLWindowError(KString("Unable to create base window: ") + bwe.errorMsg, KString("CreateOGLWindow -> ") + bwe.triggerMethod, 
			KString("OpenGLWindow -> ") + bwe.triggerClass, KString(__FILE__) + KString(" -> ") + bwe.sourceFile, __LINE__);

	/* Get Device Context */
	window_hDC = GetDC(window_hWnd);

	if(window_hDC == NULL)
		throw OpenGLWindowError("Unable to get device context", "CreateOGLWindow", "OpenGLWindow", __FILE__, __LINE__);
	/* Describe Pixel Format */
		sizeof(PIXELFORMATDESCRIPTOR),  //  size of this pfd 
		1,                     // version number 
		PFD_DRAW_TO_WINDOW |   // support window 
		PFD_SUPPORT_OPENGL |   // support OpenGL 
		PFD_DOUBLEBUFFER,      // double buffered 
		PFD_TYPE_RGBA,         // RGBA type 
		32,                    // 24-bit color depth 
		0, 0, 0, 0, 0, 0,      // color bits ignored 
		0,                     // no alpha buffer 
		0,                     // shift bit ignored 
		0,                     // no accumulation buffer 
		0, 0, 0, 0,            // accum bits ignored 
		16,                    // 32-bit z-buffer     
		0,                     // no stencil buffer 
		0,                     // no auxiliary buffer 
		PFD_MAIN_PLANE,        // main layer 
		0,                     // reserved 
		0, 0, 0                // layer masks ignored 

	/* Get and Set Pixel Format*/
	int format = 0;

	format = ChoosePixelFormat(window_hDC, &pfd);
	if(format == 0)
		throw OpenGLWindowError("Could not find pixel format", "CreateOGLWindow", "OpenGLWindow", __FILE__, __LINE__);
	if(!SetPixelFormat( window_hDC, format, &pfd ))
		throw OpenGLWindowError("Could not set pixel format", "CreateOGLWindow", "OpenGLWindow", __FILE__, __LINE__);

	/* Get Rendering Context */
	render_hRC = wglCreateContext( window_hDC );
	if(render_hRC == NULL)
		throw OpenGLWindowError("Could not get rendering context", "CreateOGLWindow", "OpenGLWindow", __FILE__, __LINE__);

	/* Make Context Current*/
    if(!wglMakeCurrent( window_hDC, render_hRC ))
		throw OpenGLWindowError("Could not make rendering context current", "CreateOGLWindow", "OpenGLWindow", __FILE__, __LINE__);

	/* Set Viewport */
	RECT rect;					// rectangle of window
	GetWindowRect(window_hWnd, &rect);
	glViewport(0, 0, rect.right - rect.left, rect.bottom - rect.top);

	/* Set Projection and View */

Share this post

Link to post
Share on other sites
After some debugging, I''ve found that ChoosePixelFormat fails with an error code of 126, which is "The specified module could not be found."

Any ideas?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!