Jump to content
  • Advertisement
Sign in to follow this  
sunnysideup

OpenGL A question about wglChoosePixelFormatARB()

This topic is 1826 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_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,  // Use hardware acceleration.
	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.
	0                                              
};

int pixelFormat = 0;

// Find pixel formats that match our pixel attributes.
BOOL result = wglChoosePixelFormatARB(m_hDC, 
	                              &pixAttribs[0], 
                                      NULL, 
                                      1, 
				      &pixelFormat, 
				      &pixFormatCount);
		
// <-- 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
Advertisement
Sign in to follow this  

  • 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!