hypnos
Aug 23rd, 2000, 12:22 PM
Hi,
I'm new to DirectX and have tried to create a program that bits to the Screen using direct draw. Here's my code:
Dim DX As New DirectX7 'Main DX Object
Dim DD As DirectDraw7 'Main DD object
Dim SurfPrime As DirectDrawSurface7 'Primary Surface
Dim SurfBack As DirectDrawSurface7 'None Prime Surface
Dim SurfDesc1 As DDSURFACEDESC2 'For Prime Surface
Dim SurfDesc2 As DDSURFACEDESC2 'For none prime
Dim DDC As DirectDrawClipper
Private Sub Form_Activate()
Call Blt
End Sub
Private Sub Form_Load()
Call Setup
End Sub
Private Sub Setup()
Set DD = DX.DirectDrawCreate("") 'Initialize DD
Call DD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL)
'Setup Primary surface
SurfDesc1.lFlags = DDSD_CAPS
SurfDesc1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
Set SurfPrime = DD.CreateSurface(SurfDesc1)
'Setup Back Buffer/Surface
SurfDesc2.lFlags = DDSD_CAPS
SurfDesc2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
Set SurfBack = DD.CreateSurfaceFromFile("C:\Test.bmp", SurfDesc2)
'Setup Clipper
Set DDC = DD.CreateClipper(0)
DDC.SetHWnd Me.hWnd
SurfBack.SetClipper DDC
End Sub
Private Sub Blt()
Dim Rect1 As RECT
Dim Rect2 As RECT
Rect2.Bottom = Me.Height
Rect2.Right = Me.Width
DX.GetWindowRect Me.hWnd, Rect1
SurfPrime.Blt Rect1, SurfBack, Rect2, DDBLT_WAIT
End Sub
It just doesn't display the picture. Please help. Thanks
[Edited by hypnos on 08-23-2000 at 01:24 PM]
I'm new to DirectX and have tried to create a program that bits to the Screen using direct draw. Here's my code:
Dim DX As New DirectX7 'Main DX Object
Dim DD As DirectDraw7 'Main DD object
Dim SurfPrime As DirectDrawSurface7 'Primary Surface
Dim SurfBack As DirectDrawSurface7 'None Prime Surface
Dim SurfDesc1 As DDSURFACEDESC2 'For Prime Surface
Dim SurfDesc2 As DDSURFACEDESC2 'For none prime
Dim DDC As DirectDrawClipper
Private Sub Form_Activate()
Call Blt
End Sub
Private Sub Form_Load()
Call Setup
End Sub
Private Sub Setup()
Set DD = DX.DirectDrawCreate("") 'Initialize DD
Call DD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL)
'Setup Primary surface
SurfDesc1.lFlags = DDSD_CAPS
SurfDesc1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
Set SurfPrime = DD.CreateSurface(SurfDesc1)
'Setup Back Buffer/Surface
SurfDesc2.lFlags = DDSD_CAPS
SurfDesc2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
Set SurfBack = DD.CreateSurfaceFromFile("C:\Test.bmp", SurfDesc2)
'Setup Clipper
Set DDC = DD.CreateClipper(0)
DDC.SetHWnd Me.hWnd
SurfBack.SetClipper DDC
End Sub
Private Sub Blt()
Dim Rect1 As RECT
Dim Rect2 As RECT
Rect2.Bottom = Me.Height
Rect2.Right = Me.Width
DX.GetWindowRect Me.hWnd, Rect1
SurfPrime.Blt Rect1, SurfBack, Rect2, DDBLT_WAIT
End Sub
It just doesn't display the picture. Please help. Thanks
[Edited by hypnos on 08-23-2000 at 01:24 PM]