Archived

This topic is now archived and is closed to further replies.

Sponge99

LPDDPIXELFORMAT problems

Recommended Posts

I am trying to use LPDIRECTDRAWSURFACE7::GetPixelFormat() to retrieve the pixel format for my primary surface, but it doesn''t work. If I simply call the function without initializing my LPDDPIXELFORMAT structure, it will just fail. But the program will stay loaded until I close it. However, if I use memset to set all of it to 0 and the set it''s dwSize variable to: sizeof(lpDDPixel), then the program quits running, exits by itself. What gives? If you need some more info (and, ofcourse, would like to help...) I''m sure I could provide. -Sponge99

Share this post


Link to post
Share on other sites
LPDDPIXELFORMAT *IS NOT* a structure...

its a *Long Pointer* (LP) to DDPIXELFORMAT!!

So if you are saying:

LPDDPIXELFORMAT ddpf;
memset( ddpf, sizeof(DDPIXELFORMAT), 0 );
ddpf->dwSize = sizeof(DDPIXELFORMAT);
...->GetPixelFormat( ddpf )

Thats wrong, its a pointer which doesn''t point to anywhere, you end up memsetting the pointer and the variables following in memory to 0!!! - You should be saying something like:

DDPIXELFORMAT ddpf;
memset( &ddpf, sizeof(DDPIXELFORMAT), 0 );
ddpf.dwSize = sizeof(DDPIXELFORMAT);
...->GetPixelFormat( &ddpf )

[Note the &''s and .''s]


--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Is there no way I can do it with LPDDPIXELFORMAT? Cause the app works with DDPIXELFORMAT, but my book tells me to work the long pointer?

Side question (if anyone has the time): What''s the diff between a ptr and a long ptr?

Anyway, is there a way I can convert DDPIXELFORMAT into LPDDPIXELFORMAT? I tried returning DDPIXELFORMAT from my function with:
return &DDPelTemp;

but it gave me a warning: returning address of local variable. Horrible or OK?

I hope that made sense, cause I need some help!

Thanks!--Sponge99

Share this post


Link to post
Share on other sites