Accelerated PixelFormat problem

17 views
Skip to first unread message

pro-grammer

unread,
Jul 14, 2010, 1:27:42 AM7/14/10
to
Hi,

I am working on adding opengl animations to an MFC application. I am
having a problem on a some systems. This is what happens:
1) my app is not able to find a single Pixelformat that is accelerated
(ie not PDF_GENERIC_FORMAT).
2) but if I create a sample MFC app that only checks for the pixel
format, an accelerated pixelformat is found.

Any idea why this would happen?

It appears asif something about this MFC app(not the sample) is
preventing accelerated pixel formats from being available.
Are there any MFC or Win32 API's that could do this?

Uwe Kotyczka

unread,
Jul 14, 2010, 8:22:16 AM7/14/10
to
On 14 Jul., 07:27, pro-grammer <akhil.malho...@gmail.com> wrote:
> Any idea why this would happen?

Sounds strange. Can you show us some code from your app
and from the demo app, where the pixel format is chosen?

pro-grammer

unread,
Jul 15, 2010, 1:53:13 AM7/15/10
to

I use the same code in the app and the demo app to list the pixel
formats:
PIXELFORMATDESCRIPTOR pfd;
ZeroMemory(&pfd,sizeof(pfd));
pfd.nSize=sizeof(pfd);
pfd.nVersion=1;
int num=DescribePixelFormat(hdc,1,sizeof(pfd),&pfd);
for (int i=1; i<=num; i++)
{
ZeroMemory(&pfd,sizeof(pfd));
pfd.nSize=sizeof(pfd);
pfd.nVersion=1;
DescribePixelFormat(hdc,i,sizeof(pfd),&pfd);

//print the pixel format details in pfd
}

The demo app is a dialog based application, with this code at the end
of the OnInitDialog function.

My app which has the problem - it is a large mfc application, which
uses opengl occasionally to render animations. I put this code just
before setting the pixel format. After setting the pixelformat, I
start opengl initialization(create a context, etc), and then i render
the animation. But no opengl calls before listing the pixel formats in
the above code.

Uwe Kotyczka

unread,
Jul 15, 2010, 7:36:08 AM7/15/10
to
On 15 Jul., 07:53, pro-grammer <akhil.malho...@gmail.com> wrote:
> I use the same code in the app and the demo app to list the pixel
> formats:
> PIXELFORMATDESCRIPTOR pfd;
> ZeroMemory(&pfd,sizeof(pfd));
> pfd.nSize=sizeof(pfd);
> pfd.nVersion=1;
> int num=DescribePixelFormat(hdc,1,sizeof(pfd),&pfd);
> for (int i=1; i<=num; i++)
> {
> ZeroMemory(&pfd,sizeof(pfd));
> pfd.nSize=sizeof(pfd);
> pfd.nVersion=1;
> DescribePixelFormat(hdc,i,sizeof(pfd),&pfd);
>
> //print the pixel format details in pfd
>
> }
>
> The demo app is a dialog based application, with this code at the end
> of the OnInitDialog function.
>
> My app which has the problem - it is a large mfc application, which
> uses opengl occasionally to render animations. I put this code just
> before setting the pixel format. After setting the pixelformat, I
> start opengl initialization(create a context, etc), and then i render
> the animation. But no opengl calls before listing the pixel formats in
> the above code.

So if this code in both your app and your demo app yields
different results, I guess that it might have something to do
with the device context and the rendering context. Your code
does not show how "hdc" is set, nor if a corresponding rendering
context exists (and if they were "set current").

You might have a look at my demo app
http://home.arcor.de/kotyczka/opengl.html

BTW there you will also find my own implementation of
ChoosePixelFormat, which enables you to decide wheather
to take an accelerated or a generic format.

HTH

And maybe comp.graphics.api.opengl would suit better.

pro-grammer

unread,
Jul 21, 2010, 8:41:31 AM7/21/10
to
Thanks for that hint Uwe.

I searched for accelerated pixel formats on the dc of the opengl-to-be
window, and there were none available.

I then searched for accelerated pixel formats on dc of the topmost
window of my mfc application. And they were available!

Whats more, when I put in the code for the topmost window(basically a
DescribePixelFormat on all available pixelformats), the opengl-to-be
window suddenly started giving me accelerated pixel formats.

Keep in mind that this issue happens only on some systems not all.

Anyone know whats happeing here?

> You might have a look at my demo apphttp://home.arcor.de/kotyczka/opengl.html


>
> BTW there you will also find my own implementation of
> ChoosePixelFormat, which enables you to decide wheather
> to take an accelerated or a generic format.
>
> HTH
>

> And maybe comp.graphics.api.opengl would suit better.- Hide quoted text -
>
> - Show quoted text -

Uwe Kotyczka

unread,
Jul 26, 2010, 3:18:42 AM7/26/10
to
On 21 Jul., 14:41, pro-grammer <akhil.malho...@gmail.com> wrote:
> I searched for accelerated pixel formats on the dc of the opengl-to-be
> window, and there were none available.
>
> I then searched for accelerated pixel formats on dc of the topmost
> window of my mfc application. And they were available!
>
> Whats more, when I put in the code for the topmost window(basically a
> DescribePixelFormat on all available pixelformats), the opengl-to-be
> window suddenly started giving me accelerated pixel formats.
>
> Keep in mind that this issue happens only on some systems not all.

No idea, maybe you ask is comp.graphics.api.opengl?
(F'up2 set)

Reply all
Reply to author
Forward
0 new messages