Advertisement

A Question about copying a back buffer

Started by November 07, 1999 01:15 PM
1 comment, last by GameDev.net 25 years, 2 months ago
If the video card is linear pitch, just use memcpy (can optimize in assembly for better speed)

memcpy(video_buffer, double_buffer, SCREEN_WIDTH * SCREEN_HEIGHT);

else u copy row by row like so

source = double_buffer; // both pointers
dest = video_buffer;

for (i=0; i < SCREEN_HEIGHT; i++)
{
memcpy(dest, source,SCREEN_WIDTH);
source += SCREEN_WIDTH;
dest += lpitch;
}

if yo use this code:
lpddsprimary->Lock(NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR,NULL);
video_buffer = (UCHAR *)ddsd.lpSurface;
lpitch = ddsd.lPitch;
Then to plot a pixel yo use:
double_buffer[x+y*lpitch] = color;
I believe

How would yo copy the double_buffer to the video_buffer without doing that computation every pixel, just when yo copy the double_buffer,
Thanks for the Help,

Advertisement
If you are trying to copy the back surface into the primary surface, which it looks like you are, the Flip command is probably what you're looking for. Just call it on the primary surface and it will exchange its data with that of the back buffer in the most efficient manner possible. Also, there is the Blt command to copy one surface into another if you are not in fullscreen mode.

This topic is closed to new replies.

Advertisement