Can someone explain me how to write pixels using directdraw? I have something similar: -lock surface call paint_proc unlock surface how to really paint pixels on the surface(paint_proc)? Tnx
Posted on 2001-01-12 15:40:00 by
When you lock the surface, using IDirectDrawSurface::Lock, you must pass a RECT, a pointer to a DDSURFACEDESC structure, flags, and an unused parameter (NULL). After it's locked, unless there was an error, you can use the buffer pointed to in the DDSURFACEDESC structure by lpSurface to draw directly to the surface. This is confusing so I'll give an example: ; Assuming lpDDSurfaceInQuestion is your back buffer (or ; primary buffer if you're not doing double buffering), and ; that ddsd is a DDSURFACEDESC structure ; With a RECT of NULL (the first NULL), you access the entire ; video screen. DDINVOKE mLock,lpDDSurfaceInQuestion,NULL,addr ddsd,DDLOCK_WAIT,NULL ; Assuming no error. You should perform checks just to be safe. ; Also assuming a 640x480 16bpp resolution push edi ; Just for safety mov edi,ddsd.lpSurface ; The surface offset xor eax,eax ; black mov ecx,480 ; height @@: push ecx push edi mov ecx,640 rep stosw pop edi pop ecx add edi,ddsd.lPitch ; Not all DirectX resolutions are equal dec ecx jnz @B pop edi ; Just for safety DDINVOKE Unlock,lpDDSurfaceInQuestion,ddsd.lpSurface This is just an example (and if you need the macros, download the DirectDraw tutorial written by X-Calibre). You can also use the loop above for a fast fill screen routine if you want. I promise not to get mad. :)
Posted on 2001-01-12 16:24:00 by Racso