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:
http://vbforums.com/attachment.php?a...id=32956&stc=1
and here is my project:(still feel bad posting this :( )
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:
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:
'Creating clipping regions
'------------------------------------------------------------
Set dd_clip = dd.CreateClipper(0)
dd_clip.SetHWnd hWnd
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.
Re: VB: DX CLIPPER over window
oh you in teh DrawMap routine there is a piece of code that does this:
VB Code:
If hWnd > 0 Then
Call DDC.SetHWnd(hWnd)
Else
Let hWnd = DDC.GetHWnd
If hWnd < 1 Then
Exit Sub
End If
End If
Re: VB: DX CLIPPER over window
OH wait i forgot to attack the clipper to the sirface i think...
:blush: :lol:
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...
Re: VB: DX CLIPPER over window
I'm just slick like that :D
And now you know why it's sometimes always helpful to upload your projects.