|
|

楼主 |
发表于 2005-8-15 17:03:00
|
显示全部楼层
Re: Re:求助:在DX9中如何实现窗口和全屏的切换
bigbook2000: Re:求助:在DX9中如何实现窗口和全屏的切换
VB.NET把
IDirect3DDevice9::Reset Method
多谢了,我试过了,的确可以改变窗口的模式,不过又出现了一个问题就是一但窗口改变,我的Render函数好像就不起作用了.
以下是编的窗口改变的小函数.不知道对不对.
Public Shared M_D3DDev As Microsoft.DirectX.Direct3D.Device '设备
Public Shared Sub ChangeDX(Optional ByVal M_Window As Boolean = True, Optional ByVal M_Width As Integer = 800, Optional ByVal M_Height As Integer = 600, Optional ByVal M_Depth As Integer = 32)
Dim pp As New PresentParameters
pp.Windowed = M_Window
pp.SwapEffect = SwapEffect.Discard
'pp.EnableAutoDepthStencil = True
'pp.AutoDepthStencilFormat = DepthFormat.D16 '16位位深
If M_Window = False Then
If IsDisplayModeOK(M_Width, M_Height, M_Depth) = True Then
pp.BackBufferHeight = M_Height
pp.BackBufferWidth = M_Width
Select Case M_Depth
Case 16
pp.BackBufferFormat = Format.R5G6B5
Case 32
pp.BackBufferFormat = Format.X8R8G8B8
End Select
Else
MessageBox.Show("显示模式初始化失败")
End If
End If
M_D3DDev.Reset(pp)
End Sub
Public Shared Function IsDisplayModeOK(ByVal M_Width As Integer, ByVal M_Height As Integer, ByVal M_Depth As Integer) As Boolean
Try
Dim AdapterInfo As AdapterInformation
Dim DispMode As DisplayMode
Dim fmt As Format
Dim D3DM As Manager
Select Case M_Depth
Case 16
fmt = Format.R5G6B5
Case 32
fmt = Format.X8R8G8B8
End Select
For Each AdapterInfo In D3DM.Adapters
For Each DispMode In AdapterInfo.SupportedDisplayModes(fmt)
If DispMode.Width = M_Width And DispMode.Height = M_Height Then Return True
Next
Next
Catch ex As Exception
Return False
End Try
Return False
End Function
|
|