Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetPixelFormat crash

279 views
Skip to first unread message

pro-grammer

unread,
Oct 25, 2010, 1:18:31 PM10/25/10
to
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

unread,
Oct 25, 2010, 1:28:38 PM10/25/10
to
On Oct 25, 7:18 pm, pro-grammer

You may want to give us more detail about
the actual SetPixelFormat parameters you used ?

fungus

unread,
Oct 25, 2010, 1:44:44 PM10/25/10
to
On Oct 25, 7:18 pm, pro-grammer <akhil.malho...@gmail.com> wrote:
> 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.

pro-grammer

unread,
Oct 26, 2010, 3:01:45 AM10/26/10
to
On Oct 25, 10:28 pm, Jean-Christophe <5...@free.fr> wrote:

>
> 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

unread,
Oct 26, 2010, 6:30:44 AM10/26/10
to
On Oct 26, 9:01 am, pro-grammer <akhil.malho...@gmail.com> wrote:
>
> I made a test application(no opengl at all) that just did this in the
> OnCreate of the dialog:
>
> PIXELFORMATDESCRIPTOR pfd = {
> ...
>     32,                    // 32-bit z-buffer

I would put 24 instead of 32 here...

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

There's no way that should crash. Definitely
a problem with the driver.


> 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.

> 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

unread,
Oct 26, 2010, 1:31:12 PM10/26/10
to

>
> > 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.

> > 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.

>
> 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...

Lawrence D'Oliveiro

unread,
Oct 26, 2010, 8:57:18 PM10/26/10
to
In message
<c304cd67-5cfb-4f1b...@m7g2000yqm.googlegroups.com>, pro-
grammer wrote:

> 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

unread,
Oct 27, 2010, 4:02:04 AM10/27/10
to
On Oct 27, 5:57 am, Lawrence D'Oliveiro <l...@geek-

central.gen.new_zealand> wrote:
>
> 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?

fungus

unread,
Oct 27, 2010, 6:26:47 AM10/27/10
to
On Oct 26, 7:31 pm, pro-grammer <akhil.malho...@gmail.com> wrote:
>
> I'm almost sure of this... but would someone really send out a driver
> into production that crashed SetPixelFormat??!!
>

Seems unlikely...

> 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.

Leclerc

unread,
Oct 27, 2010, 9:24:10 AM10/27/10
to
(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?

.....

jbwest

unread,
Oct 27, 2010, 8:50:58 PM10/27/10
to

"pro-grammer" <akhil.m...@gmail.com> wrote in message
news:0d6d3438-95e2-469e...@s4g2000yql.googlegroups.com...


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

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

jbw


fungus

unread,
Oct 28, 2010, 4:56:04 AM10/28/10
to
On Oct 27, 10:02 am, pro-grammer <akhil.malho...@gmail.com> wrote:
> On Oct 27, 5:57 am, Lawrence D'Oliveiro <l...@geek-
>
> central.gen.new_zealand> wrote:
>
> > 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

unread,
Nov 1, 2010, 4:49:33 AM11/1/10
to
On 25 Okt., 18:18, pro-grammer <akhil.malho...@gmail.com> wrote:
> 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

pro-grammer

unread,
Nov 2, 2010, 2:35:34 AM11/2/10
to
Thanks for your suggestions... my responses are below:

> 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?

>* 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

>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

unread,
Nov 2, 2010, 4:29:11 PM11/2/10
to

>> * 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

unread,
Nov 9, 2010, 7:06:08 PM11/9/10
to

"pro-grammer" <akhil.m...@gmail.com> wrote in message
news:4d47badd-6ecf-4aea...@t35g2000yqj.googlegroups.com...


re-install a proper driver for that machine.

-jbw


uwe.ko...@web.de

unread,
Dec 13, 2016, 1:49:40 PM12/13/16
to
Am Montag, 1. November 2010 09:49:33 UTC+1 schrieb 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

unread,
Jan 1, 2017, 7:08:29 PM1/1/17
to

Uwe Kotyczka

unread,
May 30, 2018, 6:58:34 PM5/30/18
to
Am Montag, 2. Januar 2017 01:08:29 UTC+1 schrieb Uwe Kotyczka:
> Am Dienstag, 13. Dezember 2016 19:49:40 UTC+1 schrieb Uwe Kotyczka:
> > Am Montag, 1. November 2010 09:49:33 UTC+1 schrieb 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
0 new messages