Discussion:
SetPixelFormat crash
(too old to reply)
pro-grammer
2010-10-25 17:18:31 UTC
Permalink
Hi.. I am experiencing a crash in my opengl program at the intial
SetPixelFormat API for a particular system(it works on all other
systems I have access to). Please let me know why this may happen.

The system specifcs first(from dxdiag):
Win XP Professional (5.1 Build 2600) Service Pack 2
Dell Lattitude D600
Intel Pentium M Processor
Card : MOBILITY RADEON 9000
Chip : MOBILITY RADEON 9000 AGP
Display Memory: 32MB

Acceleration is not available on this system. The parameters given to
SetPixelFormat are as per the MSDN recommendation.

ChoosePixelFormat and DescribePixelFormat work fine, as expected.
However it crashes at SetPixelFormat.
Jean-Christophe
2010-10-25 17:28:38 UTC
Permalink
On Oct 25, 7:18 pm, pro-grammer
Post by pro-grammer
Hi.. I am experiencing a crash in my opengl program at the intial
SetPixelFormat API for a particular system(it works on all other
systems I have access to). Please let me know why this may happen.
Win XP Professional (5.1 Build 2600) Service Pack 2
Dell Lattitude D600
Intel Pentium M Processor
Card : MOBILITY RADEON 9000
Chip : MOBILITY RADEON 9000 AGP
Display Memory: 32MB
Acceleration is not available on this system. The parameters given to
SetPixelFormat are as per the MSDN recommendation.
ChoosePixelFormat and DescribePixelFormat work fine, as expected.
However it crashes at SetPixelFormat.
You may want to give us more detail about
the actual SetPixelFormat parameters you used ?
pro-grammer
2010-10-26 07:01:45 UTC
Permalink
Post by Jean-Christophe
You may want to give us more detail about
the actual SetPixelFormat parameters you used ?
I made a test application(no opengl at all) that just did this in the
OnCreate of the dialog:

PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
24, // 24-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
32, // 32-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
HDC hdc = ::GetDC(m_hwnd); //hwnd of this dialog
int iPixelFormat;
iPixelFormat = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, iPixelFormat, &pfd);

I even tried replacing iPixelFormat with 1, which should be the
default pixel format. i.e.:
SetPixelFormat(hdc, 1, &pfd);

Still crashed. Anything wrong with this?

If not, is there another way of setting the pixel format? Or are there
any known issues with certain ATI drivers?
fungus
2010-10-26 10:30:44 UTC
Permalink
Post by pro-grammer
I made a test application(no opengl at all) that just did this in the
PIXELFORMATDESCRIPTOR pfd = {
...
    32,                    // 32-bit z-buffer
I would put 24 instead of 32 here...
Post by pro-grammer
I even tried replacing iPixelFormat with 1, which should be the
SetPixelFormat(hdc, 1, &pfd);
There's no way that should crash. Definitely
a problem with the driver.
Post by pro-grammer
is there another way of setting the pixel format?
Nope. There's other ways of choosing them
(for multisampling, etc.) but only one way
to set them.
Post by pro-grammer
Or are there any known issues with certain ATI drivers?
A lot of laptops come with fairly 'beta' drivers,
the manufacturers never bother to update them so
long as GDI doesn't crash.

You can download new drivers from ATI and try those.
Normally they'll refuse to install, Google for
"force ati driver install" for ways around this.
nb. Generic drivers work just fine, it's just
manufacturer politics...
pro-grammer
2010-10-26 17:31:12 UTC
Permalink
Post by fungus
Post by pro-grammer
PIXELFORMATDESCRIPTOR pfd = {
...
    32,                    // 32-bit z-buffer
I would put 24 instead of 32 here...
Tried putting 16, and it still crashed. It is a Divide By Zero
exception crash.
Post by fungus
Post by pro-grammer
SetPixelFormat(hdc, 1, &pfd);
There's no way that should crash. Definitely
a problem with the driver.
I'm almost sure of this... but would someone really send out a driver
into production that crashed SetPixelFormat??!!

As a side note, I tried running GLView (http://www.realtech-vr.com/
glview/) on this system. It too gave me a divide by zero exception and
crashed.
Post by fungus
You can download new drivers from ATI and try those.
Normally they'll refuse to install, Google for
"force ati driver install" for ways around this.
I wish I could. This is actually a production crash.. if only there
was a way to automatically update a customers drivers... sigh...
fungus
2010-10-27 10:26:47 UTC
Permalink
Post by pro-grammer
I'm almost sure of this... but would someone really send out a driver
into production that crashed SetPixelFormat??!!
Seems unlikely...
Post by pro-grammer
As a side note, I tried running GLView (http://www.realtech-vr.com/
glview/) on this system. It too gave me a divide by zero exception and
crashed.
Ok, so we can assume it's not your program...

The only thing that occurs to me is a corrupted
driver installation. Open regedit and go to
HKLM\software\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers

There should be a folder in there with the name
of the graphics card ("ATI...").

Inside that folder there should be an entry called
"dll" which gives the name of the .dll with the
OpenGL driver in it (probably "atioglxx.dll").

Make sure that file exists in Windows\system32\
and check its properties to see if it looks ok.
pro-grammer
2010-11-02 06:35:34 UTC
Permalink
Post by fungus
The only thing that occurs to me is a corrupted
driver installation. Open regedit and go to
HKLM\software\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers
There should be a folder in there with the name
of the graphics card ("ATI...").
Inside that folder there should be an entry called
"dll" which gives the name of the .dll with the
OpenGL driver in it (probably "atioglxx.dll").
Make sure that file exists in Windows\system32\
and check its properties to see if it looks ok.
I checked the registry, and found that the file (atioglxx.dll) exists
in system32, and has the version 6.13.10.3446

Are there any other places in the registry or elsewhere that I can
check?
Post by fungus
* are you sure you are using correct pointer in call to SetPixelFormat
(or ChoosePixelFormat)
* what did ChoosePixelFormat return?
* have you checked contens of pfd after ChoosePixelFormat?
* does m_hwnd has correct value?
Yes, 4, yes, yes
Post by fungus
just iterate over the available pixelformats.
I tired to solve it by avoiding HW accelerated formats.
The machine has 39 pixelformats, both accelerated and non accelerated.
I tried both - setting an accelerated pixel format and setting a non
accelerated pixelformat. Both crashed.

Any more ideas?
Leclerc
2010-11-02 20:29:11 UTC
Permalink
Post by pro-grammer
Post by Leclerc
* are you sure you are using correct pointer in call to SetPixelFormat
(or ChoosePixelFormat)
* what did ChoosePixelFormat return?
* have you checked contens of pfd after ChoosePixelFormat?
* does m_hwnd has correct value?
Yes, 4, yes, yes
You obviously misunderstood me, (frankly my dear) I don't care for your
"yes, 4, yes, yes" answer.


* download wglinfo.c:
http://www.xmission.com/~nate/siggraph97/src/wglinfo.c

* compile it from command line prompt using following command ( I assume
you are using M$ compiler)

cl wglinfo.c opengl32.lib glu32.lib user32.lib gdi32.lib

*(from command line prompt) start wglinfo.exe:

* if it executes correctly, you have problem with your code, but you
will also see all relevant info regarding OpenGL

* if it reports same error concerning OpenGL, you probably have problem
with driver installation, and/or compiler installation
jbwest
2010-11-10 00:06:08 UTC
Permalink
Post by pro-grammer
Post by fungus
The only thing that occurs to me is a corrupted
driver installation. Open regedit and go to
HKLM\software\Microsoft\Windows NT\CurrentVersion\OpenGLDrivers
There should be a folder in there with the name
of the graphics card ("ATI...").
Inside that folder there should be an entry called
"dll" which gives the name of the .dll with the
OpenGL driver in it (probably "atioglxx.dll").
Make sure that file exists in Windows\system32\
and check its properties to see if it looks ok.
I checked the registry, and found that the file (atioglxx.dll) exists
in system32, and has the version 6.13.10.3446
Are there any other places in the registry or elsewhere that I can
check?
Post by fungus
* are you sure you are using correct pointer in call to SetPixelFormat
(or ChoosePixelFormat)
* what did ChoosePixelFormat return?
* have you checked contens of pfd after ChoosePixelFormat?
* does m_hwnd has correct value?
Yes, 4, yes, yes
Post by fungus
just iterate over the available pixelformats.
I tired to solve it by avoiding HW accelerated formats.
The machine has 39 pixelformats, both accelerated and non accelerated.
I tried both - setting an accelerated pixel format and setting a non
accelerated pixelformat. Both crashed.
Any more ideas?
re-install a proper driver for that machine.

-jbw
Leclerc
2010-10-27 13:24:10 UTC
Permalink
(besides what fungus already suggested)


I suppose you already checked these, but to be on a safe side:

* are you sure you are using correct pointer in call to SetPixelFormat
(or ChoosePixelFormat)

* what did ChoosePixelFormat return?

* have you checked contens of pfd after ChoosePixelFormat?

* does m_hwnd has correct value?

.....
fungus
2010-10-25 17:44:44 UTC
Permalink
Post by pro-grammer
Hi.. I am experiencing a crash in my opengl program at the intial
SetPixelFormat API for a particular system(it works on all other
systems I have access to). Please let me know why this may happen.
Make sure you only call SetPixelFormat once per DC,
don't ever use it on the desktop DC.

If you're not doing that and you're sure the parameters
are all legal then try a different pixel format and
see what happens (dump a list of all pixel formats
for the card using DescribePixelFormat and pick a few
formats manually).

If all else fails, blame the driver. Has it ever been
updated on that machine? Try updating it.
Lawrence D'Oliveiro
2010-10-27 00:57:18 UTC
Permalink
In message
Post by pro-grammer
Hi.. I am experiencing a crash in my opengl program at the intial
SetPixelFormat API for a particular system(it works on all other
systems I have access to).
Which version of OpenGL is this?
pro-grammer
2010-10-27 08:02:04 UTC
Permalink
Post by Lawrence D'Oliveiro
Which version of OpenGL is this?
How do I find out?

glGetString gives me a GL_INVALID_OPERATION, as I am not able to do a
SetPixelFormat before the call.
SetPixelFormat consistently crashes on this machine, be it in my app
or any sample app or any other opengl app I download from the
internet(like GLView).

Is there another way to find out the opengl version used on a system?
jbwest
2010-10-28 00:50:58 UTC
Permalink
Post by Lawrence D'Oliveiro
Which version of OpenGL is this?
How do I find out?

glGetString gives me a GL_INVALID_OPERATION, as I am not able to do a
SetPixelFormat before the call.
SetPixelFormat consistently crashes on this machine, be it in my app
or any sample app or any other opengl app I download from the
internet(like GLView).

Is there another way to find out the opengl version used on a system?


=============

try getting glinfo, or just iterate over the available pixelformats.

jbw
fungus
2010-10-28 08:56:04 UTC
Permalink
Post by pro-grammer
Post by Lawrence D'Oliveiro
Which version of OpenGL is this?
How do I find out?
You can't find out until you've created a context,
which you can't do.

If SetPixelFormat(..., 1, &pfd) crashes, if GLView
crashes, then something is fundamentally broken
on that machine. No amount of fiddling with your
code will help.

You need to fix the machine, not your program.
Uwe Kotyczka
2010-11-01 08:49:33 UTC
Permalink
Post by pro-grammer
Acceleration is not available on this system. The parameters given to
SetPixelFormat are as per the MSDN recommendation.
ChoosePixelFormat and DescribePixelFormat work fine, as expected.
However it crashes at SetPixelFormat.
Some time ago I had a similar problem with some
Matrox (IIRC) OpenGL driver.
I tired to solve it by avoiding HW accelerated formats.
Therefore I wrote my own ChoosePixelFormat function
over the ::ChoosePixelFormat API in order to avoid
HW accelerated formats.

You may check my demo
http://home.arcor.de/kotyczka/opengl_en.html

Search for "m_bNoHardwareAcceleration" in the source code
to see how it works.

HTH
u***@web.de
2016-12-13 18:49:39 UTC
Permalink
Post by Uwe Kotyczka
You may check my demo
http://home.arcor.de/kotyczka/opengl_en.html
Update: Now it can be found at
http://kotyczka.000webhostapp.com/opengl_en.html
Uwe Kotyczka
2017-01-02 00:08:28 UTC
Permalink
Post by u***@web.de
Post by Uwe Kotyczka
You may check my demo
http://home.arcor.de/kotyczka/opengl_en.html
Update: Now it can be found at
http://kotyczka.000webhostapp.com/opengl_en.html
Moved once again to
http://kotyczka.webspace4free.net/opengl_en.html
Uwe Kotyczka
2018-05-30 22:58:32 UTC
Permalink
Post by Uwe Kotyczka
Post by u***@web.de
Post by Uwe Kotyczka
You may check my demo
http://home.arcor.de/kotyczka/opengl_en.html
Update: Now it can be found at
http://kotyczka.000webhostapp.com/opengl_en.html
Moved once again to
http://kotyczka.webspace4free.net/opengl_en.html
It seems that free webhosting services do not last very long nowadays.
Now it can be found at
http://kotyczka.byethost24.com/opengl_en.html

Loading...