Advertisement

problem with GetPixelFormat()

Started by March 18, 2000 06:17 PM
2 comments, last by SoGreen 24 years, 11 months ago
as the title says im having a bit of a problem, here it is.. Im using GetPixelFormat() so i can use the dwRGBBitCount to set my little pixel drawing function to either 5.5.5 or 5.6.5 format. When I ouput the results to the screen i get The sizeof() ddpixel (my LPDDPIXELFORMAT) is 4, ddpixel.dwFlags is 0, and ddpixel.dwRGBBitCount is 0??? heres a snippet of the code from a little prog i did to get the pixel info and check the results, assume everything else is correct, ive tried it over and over and again this is the only part that doesnt work ... memset(&ddpixel, 0, sizeof(&ddpixel)); ddpixel.dwSize = sizeof(&ddpixel); lpddsprimary->GetPixelFormat(&ddpixel); sprintf(buffer, "RGBBitCount = %d ", ddpixel.RGBBitCount); TextOut(global_hdc, 2, 110, buffer, strlen(buffer)); sprintf(buffer, "Size of ddpixel.dwFlags = %d, ddpixel.dwFlags); TextOut(global_hdc, 2, 130, buffer, strlen(buffer)); sprintf(buffer, "Size of ddpixel.dwSize = %d ", ddpixel.dwSize); TextOut(global_hdc, 2, 150, buffer, strlen(buffer)); ps, i have error checking via FAILED and neither FAILED nor SUCCEEDED triggers when used. whats up with this? any help is appreciated. Edited by - SoGreen on 3/18/00 6:31:03 PM
There's always something smaller and something bigger. Don't sweat the small stuff and don't piss off the big stuff :)
maybe i went the wrong way with this question hows this.

after this...

lpddsprimary->GetPixelFormat(&ddpixel);

ddpixel.dwFlags should have an DDPF_RGB flag right, or is there any reason why it wouldnt be there?
There's always something smaller and something bigger. Don't sweat the small stuff and don't piss off the big stuff :)
Advertisement
I''m not sure if this is all of your problem but the reason you get 4 as the sizeof(&ddpixel) is that &ddpixel is a pointer to ddpixel and all pointers in windows are 32 bits long, that''s four bytes. When you memset only the first four bytes, you''re proly leaving bumb data, an impossible flag might be set. Try doing sizeof(ddpixel). It should work then.
Thanks, that worked. I''m going through Tricks of the windows programming gurus right now, and im a little rusty on my c++. Thanks again.
There's always something smaller and something bigger. Don't sweat the small stuff and don't piss off the big stuff :)

This topic is closed to new replies.

Advertisement