Results 1 to 4 of 4

Thread: Direct Draw (Blting to Screen)

  1. #1

    Thread Starter
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183

    Question

    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:

    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]

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I'm no expert on DirectX, but I thought a rect structure had a top and left. Not so?
    Harry.

    "From one thing, know ten thousand things."

  3. #3

    Thread Starter
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183
    Indeed it does but if I don't set the top and left values they will remain on 0 which is what I want.

  4. #4

    Thread Starter
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183
    Thanks for looking guys but I fixed it now. The problem was:

    Code:
    'I put:
    Rect2.Bottom = Me.Height
    Rect2.Right = Me.Width
    
    'But I should have put:
    Rect2.Bottom = SurfDesc2.LHeight
    Rect2.Right = SurfDesc2.LWidth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width