chrgibson
05-13-2002, 03:14 AM
Hi, i just put windows xp onto my pc and now my game project wont run in windowed mode.
I need it to run in windowed mode because i only have the Dx8 runtime library and i need to debug the code. Full screen gives an automation error when its interupted.
I am using the forms handle to display to. Would it work if i changed this to a picture box ?
AndreRyan
05-14-2002, 01:24 AM
1)Please post an example
2)Try to be more specific(DirectDraw or Direct3D, error, etc)
3)DirectX8.1 has different functions then DirectX8(Some functions requirew more parameters)
chrgibson
05-14-2002, 02:18 AM
Sorry, here you go. It was working in Windowed mode on 98 but XP wont have it. Any ideas?
'==============================================Initialises DX8
'==============================================Public Function Initialise(ByVal frmHwnd As Long, ByVal Width As Long, ByVal Height As Long) As Boolean
On Error GoTo ErrHandler:
Dim DispMode As D3DDISPLAYMODE '//Describes our Display Mode
Dim D3DWindow As D3DPRESENT_PARAMETERS '//Describes our Viewport
Set dx = New DirectX8 '//Create our Master Object
Set D3D = dx.Direct3DCreate() '//Make our Master Object create the Direct3D Interface
Set D3DX = New D3DX8 '//Create our helper library...
'//We're going to use Fullscreen mode because I prefer it to windowed mode :)
'DispMode.Format = D3DFMT_X8R8G8B8
DispMode.Format = D3DFMT_R5G6B5 'If this mode doesn't work try the commented one above...
DispMode.Width = Width
DispMode.Height = Height
D3DWindow.SwapEffect = D3DSWAPEFFECT_FLIP
D3DWindow.BackBufferCount = 1 '//1 backbuffer only
D3DWindow.BackBufferFormat = DispMode.Format 'What we specified earlier
D3DWindow.BackBufferWidth = DispMode.Width
D3DWindow.BackBufferHeight = DispMode.Height
D3DWindow.hDeviceWindow = frmHwnd
D3DWindow.EnableAutoDepthStencil = 1
D3DWindow.Windowed = 1
If D3D.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, DispMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16) = D3D_OK Then
'We can use a 16 bit Z-Buffer
D3DWindow.AutoDepthStencilFormat = D3DFMT_D16 '//16 bit Z-Buffer
Else
'We could now check for different modes available...
End If
'//This line creates a device that uses a hardware device if possible; software vertex processing and uses the form as it's target
Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmHwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
D3DWindow)
D3DDevice.SetRenderState D3DRS_LIGHTING, 1 '1 = use lighting
'0 = light all
'//We need to enable our Z Buffer
D3DDevice.SetRenderState D3DRS_ZENABLE, 1
D3DDevice.SetRenderState D3DRS_AMBIENT, &H202020 'The ambient value is a hex-RRGGBB code
D3DDevice.SetTextureStageState 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR
D3DDevice.SetTextureStageState 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR
D3DDevice.SetRenderState D3DRS_SHADEMODE, D3DSHADE_GOURAUD
Set DxSprite = D3DX.CreateSprite(D3DDevice)
Initialise = True
Exit Function
ErrHandler:
'//We failed; for now we wont worry about why.
Debug.Print "Error Number Returned: " & Err.Number
Call GetErrDescription(Err.Number)
Initialise = False
End Function
DrunkenHyena
05-15-2002, 11:36 PM
G'day!
When using Windowed mode, you should specify the currently active mode. Here's code snippet taken from Lebb's tutorial which allows Fullscreen or Windowed.
Dim oDisplayMode As D3DDISPLAYMODE
gD3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, oDisplayMode
ZeroMemory ByVal oD3Dpp, Len(oD3Dpp)
With oD3Dpp
'Whether we're full-screen or windowed these are the same.
.SwapEffect = D3DSWAPEFFECT_DISCARD 'Throw away previous frames;
' we don't need them
.hDeviceWindow = gMainWindow.hWnd 'This is our main (and only) window
.BackBufferCount = 1 'We only need a single back buffer
.Windowed = Not gFullScreen
If gFullScreen Then
'BackBufferWidth/Height have to be set for full-screen apps, these
' values are used (along with BackBufferFormat) to determine the
' display mode. They aren't needed in windowed mode since the size
' of the window will be used.
'BackBufferFormat is the pixel format we want. In full-screen we
' need to find a pixel format we like, see find_16bit_mode()
' below for more details.
.BackBufferWidth = FM_WIDTH
.BackBufferHeight = FM_HEIGHT
.BackBufferFormat = Find16bitMode()
Else
'In windowed mode we use the same format as the desktop (which we
' found by using GetAdapterDisplayMode() above).
.BackBufferFormat = oDisplayMode.Format
End If
End With