getting pixels from a ddraw surface in video mem

Started by
1 comment, last by Andrew Newton 24 years, 1 month ago
why is it so slow to access video memory? supposing i wanted to process every pixel on a back buffer in video memory, is there a quick way to access the surface without first copying it to system memory first?!
Advertisement
Nope, no real way to do it that I know of. Video memory must be accessed by the cpu through the PCI bus (or AGP, depending what you''ve got), and therefore it''s MUCH slower than system memory. It''s faster to copy it in one big chunk from videomem to system memory, work on it there, then copy it back than to deal with little bits at a time from video memory.

David
-- black eyez
dgoodlad@junction.net
to add on to what he said, you'd have to make a pointer, like UCHAR *video_buffer (UINT for 32-bit and USHORT for 16-bit), and the - DIRECTDRAWSURFACE7::Lock(LPRECT lpDestREct, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD flags, HANDLE hEvent) - Function returns a pointer to the surface in the DDSURFACEDESC2 structure. so do like:
lpddsmysurface->Lock(&lock_rect, &descofsurface, DDLOCK_SURFACEMEMORYPTR, NULL);
video_buffer = descofsurface.lpSurface;

and you can access the memery through video_buffer

Edited by - Zipster on 3/28/00 5:57:15 PM

This topic is closed to new replies.

Advertisement