Typecasting DDSURFACEDESC::lpSurface?

Started by
0 comments, last by JwayneT 23 years, 10 months ago
More than likely it''s something I''m doing,

But something weird is happening when I use this pointer (and yes I lock the surface before I use it to draw). The Microsoft tutorial casts it to an unsigned char * (BYTE *), if I cast it to any other type it crashes my computer. By my calculations a BYTE cast should only give it a range of 511 different adresses. I set the pointer to the middle of the screen 320x240 (it''s at 640x480 resolution) and it comes up at the lower left hand of the screen (almost the middle of the third quatrant). I know the pointer gives a linear address and to get the location right you have to multiply it to DDSURFACEDESC::lPitch and add it to X.

What''s goin'' on man?!?! a.h{text-decoration:none;color:blue;};a.h:hover{text-decoration:underline;background:red;};

Snootchie Bootchies!

-=CF=-
a.h{text-decoration:none;color:blue;};a.h:hover{text-decoration:underline;background:red;};

Why is it called a hot water heater? Isn't it cold when it goes in the tank?

[email=jtaylor@gtemail.net" class="h]-=CF=-[/email]
Advertisement
Your problem is in the color resolution you have your surface set to. If you are in 640,480 256bpp mode, then there is one on byte per pixel on the screen. If you are 16bpp mode (hicolor mode)then there are two bytes (or a WORD) per pixel. so then for each pixel you would have to set your pointer to (WORD *) resolution to read one pixel. In most cases in hicolor mode, the color format for each word is 5-6-5, which means, 5 bits for red 6 bits for green and 5 bits for blue.

The same pointer notation is true for any other color mode, if you are in 32bpp color mode, then you would have to read a double word (DWORD *) for each pixel.

This topic is closed to new replies.

Advertisement