VBGamer |
|||||||||||||||||||||||||||
Direct3D Question David (1 reply, 0 views) (2000-Aug-8) I am having trouble getting my 3d program to work. Everytime i run it, it gets to Device.Clear 1, Viewportrect(), D3DCLEAR_TARGET, 0, 0, 0 and then breaks and tells me that there has been an overflow error :(
Does anyone know whats going on??
Here is my Initialisation code:
Public Sub Init(Form As Form, w As Integer, h As Integer, bbp As Integer)
Dim BackCaps As DDSCAPS2
screenrect.Right = w
screenrect.Bottom = h
Set DDraw = Directx.DirectDrawCreate("")
Set Direct3D = DDraw.GetDirect3D
'Set the Cooperative Level and Display mode
Call DDraw.SetCooperativeLevel(Form.hWnd, DDSCL_FULLSCREEN Or DDSCL_EXCLUSIVE Or DDSCL_ALLOWREBOOT)
Call DDraw.SetDisplayMode(w, h, bbp, 0, DDSDM_DEFAULT)
With DdsdPrimary
.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT
.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_COMPLEX Or DDSCAPS_FLIP Or DDSCAPS_3DDEVICE
.lBackBufferCount = 1
End With
Set Primary = DDraw.CreateSurface(DdsdPrimary)
BackCaps.lCaps = DDSCAPS_BACKBUFFER
Set Backbuffer = Primary.GetAttachedSurface(BackCaps)
Set Enum3D = Direct3D.GetDevicesEnum
EnumString = Enum3D.GetGuid(Enum3D.GetCount)
Backbuffer.BltColorFill screenrect, 0
Set Device = Direct3D.CreateDevice(EnumString, Backbuffer)
Viewport.lWidth = w
Viewport.lHeight = h
Viewport.lX = 0
Viewport.lY = 0
Viewport.minz = 0
Viewport.maxz = 1
Device.SetViewport Viewport
With Viewportrect(0)
.X1 = 0
.X2 = h
.Y1 = 0
.Y2 = w
End With
Device.SetRenderState D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD
End Sub
Thanks in advance :-)
|