PDA

View Full Version : Switching between 2x and 4x multisampling; can you call SetPixelFormat() twice?



halo
04-18-2005, 06:23 PM
I can initialize and enable/disable either 2x or 4x antialiasing. However, if I try SetPixelFormat() with 4x, and then SetPixelFormat() with 2x, the second attempt fails. Do I have to recreate the window? There is already one pre-existing window created before, to intialize my real window.

The only thing I can think of is:

1) SetPixelFormat() cannot be called twice on the same hdc with two different pixel formats.

or

2) I am doing something else wrong that I am unaware of.

mikael_aronsson
04-18-2005, 09:28 PM
Hi !

One of the best ways to solve this kind of problems is to read the documentation that is available....

msdn.microsoft.com


Remarks
If hdc references a window, calling the SetPixelFormat function also changes the pixel format of the window. Setting the pixel format of a window more than once can lead to significant complications for the Window Manager and for multithread applications, so it is not allowed. An application can only set the pixel format of a window one time. Once a window's pixel format is set, it cannot be changed.

You should select a pixel format in the device context before calling the wglCreateContext function. The wglCreateContext function creates a rendering context for drawing on the device in the selected pixel format of the device context.

An OpenGL window has its own pixel format. Because of this, only device contexts retrieved for the client area of an OpenGL window are allowed to draw into the window. As a result, an OpenGL window should be created with the WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles. Additionally, the window class attribute should not include the CS_PARENTDC style.
Mikael

04-19-2005, 07:47 AM
Wow, bummer. You have to re-create the display object each time you change antialias modes.