Advertisement

16 bit color modes and surface pointers

Started by February 20, 2003 08:45 PM
5 comments, last by MattS423 21 years, 8 months ago
Ok, i have a draw function that i want to be able to draw polys in both 16 and 32 bit modes, using ddraw 7. After the surface lock, i have to cast the surface pointer into a DWORD for 32 bit, or a USHORT for 16 bit. The DrawLine() function takes a DWORD. so my question: Can i simply do a bit shift and a typecast and then re-cast for DrawLine(), and have the line drawer still only write to 16 bits? you might want to know that I draw the pixels like this:

Buffer[(y*Pitch) + x] = LineColor;
 
I know i''m leaving out some vital information here...if you have any questions please ask.
Programmers of the world, UNTIE!
You have to right shift your pitch by 1 for 16 bit surfaces.
Advertisement
humm...ok, thanks...but that still doesn''t answer my question...
Programmers of the world, UNTIE!
If your function takes a pointer to the buffer, you can just cast it to the size you want.

i.e.
buffer = (USHORT) screen;

of

buffer = (DWORD) screen;

It would probably make more sense to have the function accept a void type pointer since to denote that the pointer could point to different types - but that''s not too important.

The pitch value, should be measured in pixels not bytes, though.

I don''t know why you would want to do a bit shift.
would i have to implement anything withing the drawline() to accept a void pointer? (i.e. cast it depending on the display mode?)
Programmers of the world, UNTIE!
Well, yes. That was what my response was based on.
Advertisement
so just do a typecast?
Programmers of the world, UNTIE!

This topic is closed to new replies.

Advertisement