View Full Version : Windows troubles

Allan Walton
06-21-2002, 07:22 AM
Hi there,

I'm trying to get a GL window up and running in windows rather than using glut. the program i've wrote works fine on my win2k machine at work but fails on my home machine with win98 when it's trying to choose the pixel format for the window. i.e ChoosePixelFormat() returns 0 which isnt a valid pixel format.

any ideas?



06-21-2002, 08:51 AM
Maybe the hardware in your win2K system supports the features you asked for in a pixel format, while the win98 box does not. What is your PixelFormatDescriptor requesting?

Windows 98 also has a buggy pixel format interface--you'll get exceptions thrown. It usually won't affect your program, just for reference.

Allan Walton
06-24-2002, 12:11 AM
The Win2k machine uses a matrox dual monitor card (sorry but i dont know the specifics) and the win98 machine uses a Geforce 2 GTS. the pixel format i'm requesting is nothing special, heres the code


memset(&pfd, 0, sizeof(pfd));

pfd.nVersion = 1;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = GLSCREEN_DEPTH;
pfd.dwLayerMask = PFD_MAIN_PLANE;
pfd.cDepthBits = GLSCREEN_DEPTH;

int PixelFormat = 0;

if((PixelFormat = ChoosePixelFormat(g_Hdc, &pfd)) == FALSE)
MessageBox(NULL, TEXT("ERROR : Could Not Find A Suitable Pixel Format"), sClassName, MB_ICONERROR);
return FALSE;

(Sorry if the spacing is broke)

I actually copied this from another example and it works so i'm proberbly not doing something i should but i dont know what (i stepped through both programs and i cant see anything). i also check that everything else is alright (i.e Hwnd , Hinstance and such like) so it's not that

Cheers for your help so far


06-24-2002, 04:01 AM

I had this problem also one time... is your OpenGL library loaded?


Allan Walton
06-24-2002, 05:07 AM
I've just found something about this on the net. my program doesnt have any opengl calls in it at the minute so the compiler doesnt link to opengl32.lib. when ChoosePixelFormat trys to use it it fails , returning 0.

It sounds like it's the best bet (win2k proberbly does something a bit different to win98 with respect to libraries) so i'll try it tonight when i get home and post a reply tomorrow.

Cheers for the help everyone.


Allan Walton
06-25-2002, 12:22 AM
Thanks for the help everyone but it's sorted. The problem was that the "Helpful" compiler wasnt linking to opengl32.lib as i wasnt making any gl calls so ChoosePixelFormat (which uses it internally) was always failing.

i put a glGetString Call in the program and it worked fine.

Thanks again everyone