Jump to content
  • Advertisement
Sign in to follow this  

OpenGL A question about wglChoosePixelFormatARB()

This topic is 2155 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 a little confused. Whenever I call wglChoosePixelFormatARB() what exactly am I supposed to do with the returned pixel format? Should I call SetPixelFormat() passing int the returned pixel format as the second paramater? If so should I pass NULL for the PIXELFORMATDESCRIPTOR parameter?


Here's the bit of code in question:

UINT pixFormatCount = 0;

// Specify the desired pixel attributes for frame buffer.
int pixAttribs [] =
	WGL_DRAW_TO_WINDOW_ARB,                       1,  // Can be drawn to window.
	WGL_DEPTH_BITS_ARB,                          24,  // 24 bits for depth buffer.
	WGL_STENCIL_BITS_ARB,                         8,  // 8 bits for stencil buffer.
	WGL_SWAP_METHOD_ARB,      WGL_SWAP_EXCHANGE_ARB,  // Exchange front and back buffer instead of copy.
	WGL_SAMPLES_ARB,                              4,  // 4x MSAA.
	WGL_SUPPORT_OPENGL_ARB,                       1,  // Support OpenGL rendering.
	WGL_DOUBLE_BUFFER_ARB,                        1,  // Enable double-buffering.
	WGL_PIXEL_TYPE_ARB,           WGL_TYPE_RGBA_ARB,  // RGBA color mode.
	WGL_COLOR_BITS_ARB,                          32,  // 32 bit color.
	WGL_RED_BITS_ARB,                             8,  // 8 bits for red.
	WGL_GREEN_BITS_ARB,                           8,  // 8 bits for green.
	WGL_BLUE_BITS_ARB,                            8,  // 8 bits for blue.
	WGL_ALPHA_BITS_ARB,                           8,  // 8 bits for alpha.

int pixelFormat = 0;

// Find pixel formats that match our pixel attributes.
BOOL result = wglChoosePixelFormatARB(m_hDC, 
// <-- What do I do now?
SetPixelFormat(m_hDC, pixelFormat, NULL); // <-- Is this correct?

The book I'm reading explains how to choose a pixel format, how to enumerate available pixel formats, and how to query individual attributes, but it doesn't explain what I'm supposed to do with the pixel format.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!