VBGamer |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
RE: Clipping problems.. Peter (6 replies, 0 views) (2000-Jul-4) Why's everything commented out? I don't know why my clipping sample wouldn't work for you, since it works in DDCK clipping everything left, top, right, and bottom. I think you are implementing *something* wrong.
But here is how clipping is coded into DDCK. Basically there is one sub that does the blitting (or bltfasting) with the clipping code in it. You would just call this for anything you would want to draw to the screen and if it is over the boundaries it is clipped (with this clipping can be toggled on and off). :
Public Sub DDBltFast(surface As DirectDrawSurface7, RECTvar As RECT, x As Integer, y As Integer, Optional transparent As Boolean = True, Optional Clip As Boolean = True)
'This subroutine will BltFast a surface to the
'backbuffer. This wont work with clipper.
'CLIPPING
'Temporary rect
Dim RectTEMP As RECT
RectTEMP = RECTvar
If Clip = True Then
'Set up screen rect for clipping
Dim ScreenRECT As RECT
With ScreenRECT
.Top = y
.Left = x
.Bottom = y + RECTvar.Bottom
.Right = x + RECTvar.Right
End With
'Clip surface
With ScreenRECT
If .Bottom > 600 Then
RectTEMP.Bottom = RectTEMP.Bottom - (.Bottom - 600)
.Bottom = 590
End If
If .Left < 0 Then
RectTEMP.Left = RectTEMP.Left - .Left
.Left = 0
x = 0
End If
If .Right > 800 Then
RectTEMP.Right = RectTEMP.Right - (.Right - 800)
.Right = 800
End If
If .Top < 0 Then
RectTEMP.Top = RectTEMP.Top - .Top
.Top = 0
y = 0
End If
End With
End If
If transparent = False Then
Call ddsBack.BltFast(x, y, surface, RectTEMP, DDBLTFAST_WAIT)
Else
Call ddsBack.BltFast(x, y, surface, RectTEMP, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY)
End If
End Sub
That is copy & pasted directly from the DDCK project file. The only thing is, you have to adjust the numbers to your resolution (pherhaps that is your problem). If you are running in 640x480 res, change 800 to 640 and 600 to 480, since the above is for a 800x600 resolution
Peter
DDCK:MoC
A Mythical RTS
www.talosstudios.com
|