Persisent transparency issue with DirectDraw using VB .NET & DX9.0c

Reactive

New member
Joined
Oct 26, 2006
Messages
1
Programming Experience
3-5
Hi all,

I've seen a few people on the forum having transparency issues with DirectDraw, but they always seem to come right. My situation, however, is not showing any improvements at all!

I keep getting the infamous "Value does not fall within expected range." error whenever I call the DrawFast() method and pass the DrawFastFlags.SourceColorKey arguments. Whenever I use the DrawFastFlags.DoNotWait option it works fine, but then obviously my surface doesn't get any transparency applied to it.

My code to set the ColorKey is as follows:

VB.NET:
Dim ck As ColorKey
ck.ColorSpaceHighValue = 0 ' Black.
ck.ColorSpaceLowValue = 0 ' Black.
TargetSurface.SetColorKey(ColorKeyFlags.SourceDraw, ck)
Which also seems fine. I've tested the code on various other machines and the error keeps occuring. Is there something I don't understand about what I'm doing, or is it perhaps the way I'm initializing my devices and surfaces? The code is as follows:

VB.NET:
Public Sub New(ByVal RenderControl As Control)
' Initialise
Me._Target = RenderControl
Me._GraphicsDevice = New Device
Me._GraphicsDevice.SetCooperativeLevel(Me._Target, CooperativeLevelFlags.Normal)
Me._GraphicsDevice.SetDisplayMode(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, 16, 0, False)
Me.CreateSurfaces()
End Sub
 
Private Sub CreateSurfaces()
' Create primary surface
Dim desc As SurfaceDescription = New SurfaceDescription
desc.SurfaceCaps.PrimarySurface = True
Me._SurfacePrimary = New Surface(desc, Me._GraphicsDevice)
' Reconfigure for the secondary surface
desc.Clear()
With desc
.Width = Me._SurfacePrimary.SurfaceDescription.Width
.Height = Me._SurfacePrimary.SurfaceDescription.Height
.SurfaceCaps.OffScreenPlain = True
End With
Me._SurfaceSecondary = New Surface(desc, Me._GraphicsDevice)
Me._GraphicsClipper = New Clipper(Me._GraphicsDevice)
Me._GraphicsClipper.Window = Me._Target
Me._SurfacePrimary.Clipper = Me._GraphicsClipper
End Sub
 
Private Sub initializeSurfaceDescription() ' Used only in my BitmapObject class.
_SurfaceDesc = New SurfaceDescription
With _SurfaceDesc
.SurfaceCaps.OffScreenPlain = True
.Width = _BitmapDim.Width
.Height = _BitmapDim.Height
End With
End Sub
Which works for everything else... As soon as I start setting the BackBuffers and all that I get errors (which don't happen in C# for some reason.)

I'm using VB .NET 2003, DirectDraw using DirectX9.0c September 2006 release. I'd REALLY appreciate any tips or if someone could at least point me in the right direction. I'm clueless now.
 
Last edited by a moderator:
Back
Top