Discussion:
wglCreateContext failed part 2
(too old to reply)
Sam Brown
2006-04-19 09:49:08 UTC
Permalink
Hi guys,

I have a problem with wglCreateContext failing on a particular
machine. Now, I know this is normally supposed to be either a pixel
format problem, or a problem with the graphics drivers. However, I'm
getting no error whatsoever from GetLastError, and the pixel format
seems fine.

These are the flags DescribePixelFormat gives me for the one chosen by
ChoosePixelFormat (which is unchanged from the NeHe tutorials):

PFD_TYPE_RGBA
PFD_MAIN_PLANE
PFD_DOUBLEBUFFER
PFD_DRAW_TO_WINDOW
PFD_SUPPORT_OPENGL
PFD_SWAP_EXCHANGE

(The system is using W2K, I don't know the SP).

From that, wglCreateContext returns NULL, but GetLastError gives me
"The operation completed sucessfully".

I'm not yet in a position to actually get my hands on one of the
offending machines, so I'm in a bit of a fix. Does anyone have any
ideas?

Cheers,

- Sam
Gernot Frisch
2006-04-19 11:43:30 UTC
Permalink
Post by Sam Brown
I have a problem with wglCreateContext failing on a particular
machine. Now, I know this is normally supposed to be either a pixel
format problem, or a problem with the graphics drivers. However, I'm
getting no error whatsoever from GetLastError, and the pixel format
seems fine.
These are the flags DescribePixelFormat gives me for the one chosen by
PFD_TYPE_RGBA
PFD_MAIN_PLANE
PFD_DOUBLEBUFFER
PFD_DRAW_TO_WINDOW
PFD_SUPPORT_OPENGL
PFD_SWAP_EXCHANGE
(The system is using W2K, I don't know the SP).
From that, wglCreateContext returns NULL, but GetLastError gives me
"The operation completed sucessfully".
I'm not yet in a position to actually get my hands on one of the
offending machines, so I'm in a bit of a fix. Does anyone have any
ideas?
First, make sure the customner has installed the latest driver for his
card. I suggest Omega Drivers for ATI cards (google for it). I don't
have a nvidia on a Windows system.
Check what glGetVendor() returns.
Sam Brown
2006-04-19 13:49:57 UTC
Permalink
Post by Gernot Frisch
First, make sure the customner has installed the latest driver for his
card. I suggest Omega Drivers for ATI cards (google for it). I don't
have a nvidia on a Windows system.
Ah, sorry, I should have said this is for a Pixel Perfect Widescreen
AGP card, not one of the usual suspects, and the chances of the
customer updating the drivers are fairly remote. It's for a
proprietry display system, and there's over a thousand of them across
the country.

I fully appreciate that it may well boil down to a driver problem (in
which case I'm stuck, because they refuse to update them accross their
estate - it would cost too much, apparantly). I'm clutching at any
other possibilties that may exist.

Cheers,

- SamB
Gernot Frisch
2006-04-19 14:19:39 UTC
Permalink
Post by Sam Brown
Post by Gernot Frisch
First, make sure the customner has installed the latest driver for his
card. I suggest Omega Drivers for ATI cards (google for it). I don't
have a nvidia on a Windows system.
Ah, sorry, I should have said this is for a Pixel Perfect Widescreen
AGP card, not one of the usual suspects, and the chances of the
customer updating the drivers are fairly remote. It's for a
proprietry display system, and there's over a thousand of them
across
the country.
I fully appreciate that it may well boil down to a driver problem (in
which case I'm stuck, because they refuse to update them accross their
estate - it would cost too much, apparantly). I'm clutching at any
other possibilties that may exist.
If it's an NeHe, unmodified and it does not run, chances are 99%
there's something really bad with the driver. Send him a opengl32.dll
from Mesa and put it in the .exe's directory (yuck!)
jbwest
2006-04-19 14:37:34 UTC
Permalink
Post by Gernot Frisch
Post by Sam Brown
I have a problem with wglCreateContext failing on a particular
machine. Now, I know this is normally supposed to be either a pixel
format problem, or a problem with the graphics drivers. However, I'm
getting no error whatsoever from GetLastError, and the pixel format
seems fine.
These are the flags DescribePixelFormat gives me for the one chosen by
PFD_TYPE_RGBA
PFD_MAIN_PLANE
PFD_DOUBLEBUFFER
PFD_DRAW_TO_WINDOW
PFD_SUPPORT_OPENGL
PFD_SWAP_EXCHANGE
(The system is using W2K, I don't know the SP).
From that, wglCreateContext returns NULL, but GetLastError gives me
"The operation completed sucessfully".
I'm not yet in a position to actually get my hands on one of the
offending machines, so I'm in a bit of a fix. Does anyone have any
ideas?
First, make sure the customner has installed the latest driver for his
card. I suggest Omega Drivers for ATI cards (google for it). I don't have
a nvidia on a Windows system.
Check what glGetVendor() returns.
PFD_SWAP_EXCHANGE is a little unusual...

What's your requested Zbuffer depth? I've seen a failure asking for 32 bits
(or 16) when only 24 bits are available.

Also, are you sure that the window hWND from which you get the hDC is
created ?
And, are you sure that the setPixelFormat is working (note: you can only
setPixelFormat once)

Are you asking for planes that aren't there (Alpha, stencil...) Does you
procedure look like this ?

static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), //size of structure
1, //default version
PFD_DRAW_TO_WINDOW | //window drawing
support
PFD_SUPPORT_OPENGL | //opengl support
PFD_DOUBLEBUFFER, //double buffering
support
PFD_TYPE_RGBA, //RGBA color mode
32, //32 bit color mode
0, 0, 0, 0, 0, 0, //ignore color bits
0, //no alpha buffer
0, //ignore shift bit
0, //no accumulation
buffer
0, 0, 0, 0, //ignore
accumulation bits
16, //16 bit z-buffer
size
0, //no stencil buffer
0, //no aux buffer
PFD_MAIN_PLANE, //main drawing plane
0, //reserved
0, 0, 0 }; //layer masks
ignored

/* Choose best matching format*/
nPixelFormat = ChoosePixelFormat(hDC, &pfd);

/* Set the pixel format to the device context*/
SetPixelFormat(hDC, nPixelFormat, &pfd);
Sam Brown
2006-04-19 15:07:45 UTC
Permalink
Post by jbwest
PFD_SWAP_EXCHANGE is a little unusual...
Yes, I noticed that too. When I get the chance I'm going to force it
to use a PF with PFD_SWAP_COPY instead to see if that fixes the
problem.

This _is_ quite an unusual graphics card mind you... it's not one
that's actually sold to the public.
Post by jbwest
What's your requested Zbuffer depth? I've seen a failure asking for 32 bits
(or 16) when only 24 bits are available.
16 - which is available according to DescribePixelFormat.
Post by jbwest
Also, are you sure that the window hWND from which you get the hDC is
created ?
Yes.
Post by jbwest
And, are you sure that the setPixelFormat is working (note: you can only
setPixelFormat once)
Yes.
Post by jbwest
Are you asking for planes that aren't there (Alpha, stencil...) Does you
procedure look like this ?
[snip]

Yes, apart from the fact I'm asking for 16 bit (although it doesn't
work with 24 or 32 bit either).

I've just had the results of a test app I sent him back, where I tried
every single available resolution on the machine. None of them
worked, so next I'm trying all the different pixel formats...

This application works perfectly on all the other PC on the clients
estate (about 7000 machines, 6 or 7 different mixes of SW and HW).
This is the only configuration my app fails on.

It's really irritating - all the problems of PC game development, but
I'm not allowed to use any of the solutions! Normally I'd just tell
him to update his driver... ;)

Cheers,

- SamB
Gernot Frisch
2006-04-19 15:44:04 UTC
Permalink
Post by Sam Brown
It's really irritating - all the problems of PC game development, but
I'm not allowed to use any of the solutions! Normally I'd just tell
him to update his driver... ;)
If it fails, rename the mesa32.dll into opengl32.dll in the exe's
folder and restart your app. If it's only for 6 machines of 6000 - who
cares?
Sam Brown
2006-04-19 16:08:35 UTC
Permalink
Post by Gernot Frisch
If it fails, rename the mesa32.dll into opengl32.dll in the exe's
folder and restart your app. If it's only for 6 machines of 6000 - who
cares?
Not quite, I said there were 6 or 7 different mixes of SW and HW -
there's 1000 of this particular configuration! ;)

Cheers,

- SamB
fungus
2006-04-19 18:59:39 UTC
Permalink
Post by Sam Brown
Hi guys,
I have a problem with wglCreateContext failing on a particular
machine. Now, I know this is normally supposed to be either a pixel
format problem, or a problem with the graphics drivers. However, I'm
getting no error whatsoever from GetLastError, and the pixel format
seems fine.
I've seen something similar once - the card doesn't
like a pixel format returned by ChoosePixelFormat().
You can look at all the pixel formats yourself and
pick one, or if this is a weird one-of-a-kind graphics
card then just force it to something suitable, ie.
"SetPixelFormat(3)" or some other pixel format which
you know works on that card.
--
<\___/>
/ O O \
\_____/ FTB. For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again. They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful. But it happens
every day. I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address
Loading...