Skip to main content
gamedev.net
🔒 Locked

C++ Question

Started by JonW Oct 5, 2002 at 7:57 PM 0 replies 200+ views
Original Post
JonW
JonW
Hey, Say I have code like this: if (bpp == 16) { USHORT *pBuffer = (USHORT)ddsd.lpSurface; // Draw on buffer... } else if (bpp == 32) { UINT *pBuffer = (UINT)ddsd.lpSurface; // Draw on buffer... } Could I created a single pointer called pBuffer, assign an unsigned short or unsigned int to it depending on bpp, and still be able to increment the pointer on the correct boundaries? For example, void *pBuffer; if (bpp == 16) pBuffer = (USHORT)ddsd.lpSurface; else if (bpp == 32) pBuffer = (UINT)ddsd.lpSurface; // Increment pBuffer so that it points to the next ushort or uint pBuffer++; Naturally, my code wouldn''t work as you can''t cast something to ushort or uint and assign to a void, but is there someway I can do this without using a bunch of if''s everywhere? Thanks a million!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.