- Home
·
- Graphics
·
- DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/
DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/
DirectX 7 Example of DirectDraw. See Microsoft website for further info: https://msdn.microsoft.com/library/psdk/directx/vbddtut_0k4i.htm
API Declarations
' Visual Basic 6.0 Source Code
' illustrating Direct Draw via DirectX 7.0 API
'
' Developed using http://msdn.microsoft.com/library/psdk/directx/vbddtut_0k4i.htm example.
Dim objDX As New DirectX7 'DirectX Object
Dim objDD As DirectDraw7 'Direct Draw Object
Dim ddsd1 As DDSURFACEDESC2 'Surface Desc
Dim ddsd2 As DDSURFACEDESC2 'Surface Desc
Dim objDDSurf As DirectDrawSurface7 'Surface
Dim objDDPrimSurf As DirectDrawSurface7 'Surface
Dim ddClipper As DirectDrawClipper 'Clipper
Dim rSource As RECT
Dim rDestination As RECT
Dim bInit As Boolean
Dim lResult As Long
Rate DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/
(1(1 Vote))
On Error GoTo ErrorHandler
Set objDD = objDX.DirectDrawCreate("") 'Create empty DirectDraw7 Object
Call objDD.SetCooperativeLevel(Me.hWnd, DDSCL_NORMAL) 'Set behaviour
'//Create Surface - Onscreen
ddsd1.lFlags = DDSD_CAPS 'Surface Type
ddsd1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE 'Set type to Primary Surface
Set objDDPrimSurf = objDD.CreateSurface(ddsd1) 'Create the Surface
'//Create Surface - Offscreen
ddsd2.lFlags = DDSD_CAPS 'Surface Type
ddsd2.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN 'Offscreen surface in memory
Set objDDSurf = objDD.CreateSurfaceFromFile(App.Path & "\dot.bmp", ddsd2)
Set ddClipper = objDD.CreateClipper(0)
ddClipper.SetHWnd oPicture.hWnd
objDDPrimSurf.SetClipper ddClipper
bInit = True
DoEvents
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description, vbExclamation, App.Title
End Sub
Private Sub Form_Resize()
'Source Rectangle
rSource.Right = ddsd2.lWidth
rSource.Bottom = ddsd2.lHeight
'Destination Rectangle
Me.ScaleMode = vbPixels
oPicture.Width = Me.ScaleWidth
oPicture.Height = Me.ScaleHeight
Call objDX.GetWindowRect(oPicture.hWnd, rDestination)
lResult = objDDPrimSurf.Blt(rDestination, objDDSurf, rSource, DDBLT_WAIT)
If (lResult <> 0) Then
MsgBox lResult, vbExclamation, App.Title
End If
Exit Sub
ErrorHandler:
MsgBox Err.Number & ": " & Err.Description, vbExclamation, App.Title
End Sub
DirectX 7 Example of DirectDraw. See Microsoft website for further info: http://msdn.microsoft.com/ Comments
No comments yet — be the first to post one!
Post a Comment