PDA

Click to See Complete Forum and Search --> : Direct Draw (Blting to Screen)


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]

HarryW
Aug 23rd, 2000, 03:09 PM
I'm no expert on DirectX, but I thought a rect structure had a top and left. Not so?

hypnos
Aug 23rd, 2000, 05:38 PM
Indeed it does but if I don't set the top and left values they will remain on 0 which is what I want.

hypnos
Aug 24th, 2000, 12:30 PM
Thanks for looking guys but I fixed it now. The problem was:


'I put:
Rect2.Bottom = Me.Height
Rect2.Right = Me.Width

'But I should have put:
Rect2.Bottom = SurfDesc2.LHeight
Rect2.Right = SurfDesc2.LWidth