Original Post
I''m writing a DirectDraw program, and in order to access the video memory, I want to be able to use one pointer variable, no matter what the bit depth is set to. For example, if the bit depth is 8-bit, then I need a UCHAR pointer, if it is 16-bit, then I need a USHORT pointer, etc.
This is what I''ve been trying to do, but to no avail. I''ve actually never seen this done before (and I may find out why after I receive a few replies
), and Google didn''t turn up any help.
#include <iostream>
using namespace std;
int main()
{
void *video_buffer = NULL;
switch (BIT_DEPTH_OF_PRIMARY_SURFACE)
{
case 8:
{
video_buffer = (UCHAR *)video_buffer;
video_buffer = (UCHAR *)VOID_POINTER_TO_SURFACE;
}
...... same for 16 and 32-bit, but with different casts
return 0;
}
Basically, I have two void pointers, and I need to convert both of them to the same pointer type so that I can assign one of them to the other. I could make video_buffer_8, video_buffer_16, etc, but I''m trying to do it this way so that I can just use video_buffer variable every single time in my code and it will automatically always be the right one.