🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

A Question about copying a back buffer

Started by
1 comment, last by GameDev.net 24 years, 7 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;
}

Advertisement
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,

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