Jump to content
  • Advertisement

Archived

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

RWarden

ChoosePixelFormat

This topic is 6689 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

When I typed in the tutorials word-by-word, everything works great. But, when I do anything from scratch, ChoosePixelFormat fails. I''m basically going through exactly the same steps as in the tutorials, and creating the windows with exactly the same specifications. It can''t be a problem with my hardware not supporting it, because I''m using the same pixel format I used in the tutorial. It can''t be a problem with the PIXELFORAMTDESCRIPTOR struct, because after it failed the first time I c&p''d it from the tutorials. I''ve tried everything I can possibly think of, and a whole bunch of things that would seem to have nothing to do with the problem, but it still never works. Finally, when I used FormatMessage with GetLastError, I get the message "The Operation Completed Successfully". (Also, I know that ChoosePixelFormat is setting the last error because before I called it I used SetLastError (1) and ChoosePixelFormat set it back to zero). Please help, I''m kind of paralyzed trying to fix this problem. -RWarden (roberte@maui.net)

Share this post


Link to post
Share on other sites
Advertisement
could you possibly show some of the code. i have been using ChoosePixelFormat for years, and may be able to help.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Here''s all the code minus error checking, in the order it''s called in my init function. This is the first code that executes when the program starts up:

// Window class:
wc.style = CS_HREDRAW / CS_VREDRAW / CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = 0;
wc.hIcon = LoadIcon ( NULL, IDI_WINLOGO );
wc.hCursor = LoadCursor ( NULL, IDC_ARROW );
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = NAME;
RegisterClass ( &wc );

// Fullscreen switch:
memset ( &dm, 0, sizeof ( dm ) );
dm.dmSize = sizeof ( dm );
dm.dmPelsWidth = 800;
dm.dmPelsHeight = 600;
dm.dmBitsPerPel = 16;
dm.dmFields = DM_BITSPERPEL / DM_PELSWIDTH / DM_PELSHEIGHT;
ChangeDisplaySettings ( &dm, CDS_FULLSCREEN );

// Window creation:
g_hwndMain = CreateWindowEx ( WS_EX_APPWINDOW, NAME, TITLE, WS_POPUP / WS_CLIPSIBLINGS / WS_CLIPCHILDREN, 0, 0, 800, 600, NULL, NULL, hInstance, NULL );

// Pixelformatdescriptor:
static PIXELFORMATDESCRIPTOR pfd =
{ sizeof ( PIXELFORMATDESCRIPTOR ), 1, PFD_DRAW_TO_WINDOW /
PFD_SUPPORT_OPENGL / PFD_DOUBLEBUFFER, PFD_TYPE_RGBA,
16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0,
PFD_MAIN_PLANE, 0, 0, 0, 0 };

// GetDC/ChoosePixelFormat:
g_hDC = GetDC ( g_hwndMain );
pf = ChoosePixelFormat ( g_hDC, &pfd );

ChoosePixelFormat always returns zero.

-RWarden (roberte@maui.net)

Share this post


Link to post
Share on other sites
Yes... ChoosePixelFormat returns zero every time you execute it! But it's not an error!!!

I don't know why, but it works with pixelformat=0. I thought that a zero indicates that your PF is the PF you've requested, but if you do nothing about choosing,setting,etc. it won't work!

try this:

pixelformat = ChoosePixelformat( hDC, &pfd );
SetPixelFormat( hDC, pixelformat, &pfd );
DescribePixelFormat( -what ever it expects- );

Edited by - WickedImp on June 28, 2000 11:07:16 AM

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!