Results 1 to 6 of 6

Thread: VB: DX CLIPPER over window

  1. #1

    Thread Starter
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Resolved VB: DX CLIPPER over window

    previous topic:
    http://vbforums.com/showthread.php?p=1872279

    i have some problems with my map. using dx to draw it inside a window.
    but whenever i put a form over my map the map draws over a form

    i have search the forums and i came up with this code:

    Code:
    Private Sub Display_Paint()
        If StrMatch(ActiveControl.Name, Display.Name) Then
            Call DrawMap(Map) 'drawmap works perfectly
        End If
    End Sub
    
    Public Function StrMatch(Str1 As String, Str2 As String) As Boolean
        If LenB(Str1) = LenB(Str2) Then
            If InStr(1, Str1, Str2, vbTextCompare) Then
                Let StrMatch = True
            End If
        End If
    End Function
    and it dint work

    here is the screenshot:


    and here is my projectstill feel bad posting this )
    Last edited by _visual_basic_; Dec 25th, 2004 at 03:35 PM.

  2. #2
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB: DX CLIPPER over window

    The problem is that you aren't using a main game loop, which consist on clearing the window, drawing to the backbuffer surface, then blitting the backbuffer to the primary surface. This loop will do this over and over again until the program has been closed, and must be active the whole time the program is up. All you have right now are events that only clear it and blit it once until another action has taken place.

    Another problem is this right here in your InitDX sub:

    VB Code:
    1. Set DDC = DD.CreateClipper(0)

    You need more than that to set up the clipper. What I did with my DX7 projects to set up the clipper in my DirectX Initialization subs is this:

    VB Code:
    1. 'Creating clipping regions
    2.         '------------------------------------------------------------
    3.         Set dd_clip = dd.CreateClipper(0)
    4.         dd_clip.SetHWnd hWnd
    5.         primary.SetClipper dd_clip '<---- Why don't you have this?

    That's what you were missing. PrimarySurface.SetClipper DDC. One more thing I would like to add. You don't need Let statements (unless of course you are making properties in a class module). Using Let a = b was the old method back in the 80's. It's still supported and all, but not needed. You have a lot of them in your InitDX sub.

  3. #3

    Thread Starter
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: VB: DX CLIPPER over window

    oh you in teh DrawMap routine there is a piece of code that does this:

    VB Code:
    1. If hWnd > 0 Then
    2.         Call DDC.SetHWnd(hWnd)
    3.     Else
    4.         Let hWnd = DDC.GetHWnd
    5.        
    6.         If hWnd < 1 Then
    7.             Exit Sub
    8.         End If
    9.     End If

  4. #4

    Thread Starter
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: VB: DX CLIPPER over window

    OH wait i forgot to attack the clipper to the sirface i think...


  5. #5

    Thread Starter
    Banned
    Join Date
    Dec 2004
    Posts
    174

    Re: VB: DX CLIPPER over window

    attach*
    surface*

    i got it working now. THANKS ALOT

    sometimes when i code to much in one time i forget all kinds of things...

  6. #6
    Elite Hacker Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,349

    Re: VB: DX CLIPPER over window

    I'm just slick like that

    And now you know why it's sometimes always helpful to upload your projects.

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