Ok... this is the code I use to load an empty surface:
VB Code:
Public Type KSurface SURF As DirectDrawSurface7 DESC As DDSURFACEDESC2 Width As Long Height As Long End Type 'Loads an empty surface, based on width/height Sub LoadEmptySurface(Width As Long, Height As Long, Dest As KSurface, Optional SpecialEffect As Boolean = False) 'Set the surface's width and height Dest.Width = Width Dest.Height = Height 'Set the flags Dest.DESC.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH If Not SpecialEffect Then 'Load it as a regular surface Dest.DESC.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Else 'System memory is faster when it comes to special effects :) Dest.DESC.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY End If 'Width/height of the image... Dest.DESC.lWidth = Width Dest.DESC.lHeight = Height 'Create it... Set Dest.SURF = DDraw.CreateSurface(Dest.DESC) 'Set the color key to black Dim Key As DDCOLORKEY Key.low = 0 Key.high = Key.low Dest.SURF.SetColorKey DDCKEY_SRCBLT, Key End Sub
And this one to manipulate it as an array:
VB Code:
Dim EmptyRect As RECT Dim DestArray() As Byte Backbuffer.SURF.Lock EmptyRect, Backbuffer.DESC, DDLOCK_NOSYSLOCK Or DDLOCK_WAIT, 0 Backbuffer.SURF.GetLockedArray DestArray() 'Manipulate it here... I assume you already know how the array is organized :) (BGR-BGR-BGR...) Backbuffer.SURF.Unlock EmptyRect
Hope that helps
You can remove the NOSYSLOCK flag to speed up your app, but that means that windows won't be running while the surface is locked so you can't use any Windows APIs and NO errors can occur or your computer will crash![]()








Reply With Quote