VB.NET and DirectX Surfaces
I'm trying to create an application using VB.NET and DirectX 9 (Microsoft.DirectX). I'm having a problem with the surfaces (Microsoft.DirectX.DirectDraw.Surface).
After I create one surface, DirectDraw raises an error when I attempt to create another. For example:
Dim
Dim capsAsNew SurfaceCaps
m_DirectDraw.SetCooperativeLevel(m_MainForm, CooperativeLevelFlags.FullscreenExclusive)
m_DirectDraw.SetDisplayMode(m_DisplayWidth, m_DisplayHeight, m_DisplayDepth, 0,False)
desc.SurfaceCaps.PrimarySurface =True
desc.SurfaceCaps.Flip =
Truedesc.SurfaceCaps.Complex =
Truedesc.BackBufferCount = 1
m_PrimarySurface =
New Surface(desc, m_DirectDraw)caps.BackBuffer =
Truem_BackBuffer = m_PrimarySurface.GetAttachedSurface(caps)
m_BackBuffer.ForeColor = Color.White
m_BackBuffer.FillStyle = 0
desc.Clear()
Dim surfaceAsNew Surface(desc, m_DirectDraw)There are two lines highlighted in the above code. Both of them are exactly the same, aside from the fact that the object names are different. The first object (m_PrimarySurface) is created without a problem and functions properly. However, the 2nd object (surface), will not be created. The following error is raised:Value does not fall within the expected range.To make things even more odd, if I place the 2nd object's (surface) line of code before the first one, so that surface is created before m_PrimarySurface, then surface is successfully created, and m_PrimarySurface raises the same error as above.
Any thoughts?

