Модератор: gaidar
Option Explicit
Dim dx As New DirectX8
Dim d3d As Direct3D8
Dim d3dDevice As Direct3DDevice8
Dim MainC As Direct3DSurface8
Dim TexRT As Direct3DTexture8
Dim NewC As Direct3DSurface8
Dim Running As Boolean
Private Sub InitD3D()
Dim DispMode As D3DDISPLAYMODE
Dim d3dpp As D3DPRESENT_PARAMETERS
Set d3d = dx.Direct3DCreate
d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode
d3dpp.Windowed = True
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
d3dpp.BackBufferFormat = DispMode.Format
Set d3dDevice = d3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Me.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp)
Set MainC = d3dDevice.GetRenderTarget
Set TexRT = d3dDevice.CreateTexture(128, 128, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT)
Set NewC = TexRT.GetSurfaceLevel(0)
End Sub
Private Sub Render()
d3dDevice.SetRenderTarget NewC, Nothing, 0
d3dDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0, 1, 0
d3dDevice.SetRenderTarget MainC, Nothing, 0
d3dDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0, 1, 0
d3dDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
End Sub
Private Sub Form_Load()
' On Local Error Resume Next
Me.Show
InitD3D
Running = True
Do While DoEvents
Render
Loop
Set MainC = Nothing
Set NewC = Nothing
Set TexRT = Nothing
Set d3dDevice = Nothing
Set d3d = Nothing
Set dx = Nothing
End Sub
Option Explicit
Dim dx As New DirectX8
Dim d3d As Direct3D8
Dim d3dDevice As Direct3DDevice8
Dim MainC As Direct3DSurface8
Dim TexRT As Direct3DTexture8
Dim NewC As Direct3DSurface8
Private Sub InitD3D()
Dim DispMode As D3DDISPLAYMODE
Dim d3dpp As D3DPRESENT_PARAMETERS
Set d3d = dx.Direct3DCreate
d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode
d3dpp.Windowed = True
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
d3dpp.BackBufferFormat = DispMode.Format
Set d3dDevice = d3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Me.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp)
Set MainC = d3dDevice.GetRenderTarget
Set TexRT = d3dDevice.CreateTexture(128, 128, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT)
Set NewC = TexRT.GetSurfaceLevel(0)
End Sub
Private Sub Form_Load()
Me.Show
InitD3D
Do While DoEvents
d3dDevice.SetRenderTarget NewC, Nothing, 0
d3dDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0, 1, 0
d3dDevice.SetRenderTarget MainC, Nothing, 0
d3dDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0, 1, 0
d3dDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
Loop
Set MainC = Nothing
Set NewC = Nothing
Set TexRT = Nothing
Set d3dDevice = Nothing
Set d3d = Nothing
Set dx = Nothing
End Sub
Private Sub Form_Load()
On Error GoTo ErrLabel
Me.Show
InitD3D
Running = True
Do While DoEvents
Render
Loop
Set MainC = Nothing
Set NewC = Nothing
Set TexRT = Nothing
Set d3dDevice = Nothing
Set d3d = Nothing
Set dx = Nothing
Exit Sub
ErrLabel:
MsgBox Err.Description
End Sub
Option Explicit
Dim dx As New DirectX8
Dim d3d As Direct3D8
Dim d3dDevice As Direct3DDevice8
Dim MainC As Direct3DSurface8
Dim TexRT As Direct3DTexture8
Dim NewC As Direct3DSurface8
Dim Running As Boolean
Private Sub InitD3D()
Dim DispMode As D3DDISPLAYMODE
Dim d3dpp As D3DPRESENT_PARAMETERS
Set d3d = dx.Direct3DCreate
d3d.GetAdapterDisplayMode D3DADAPTER_DEFAULT, DispMode
d3dpp.Windowed = True
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
d3dpp.BackBufferFormat = DispMode.Format
Set d3dDevice = d3d.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Me.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp)
Set MainC = d3dDevice.GetRenderTarget
Set TexRT = d3dDevice.CreateTexture(128, 128, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R5G6B5, D3DPOOL_DEFAULT)
Set NewC = TexRT.GetSurfaceLevel(0)
End Sub
Private Sub Render()
MsgBox "5"
d3dDevice.SetRenderTarget MainC, Nothing, 0
MsgBox "6"
d3dDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0, 1, 0
MsgBox "7"
d3dDevice.Present ByVal 0, ByVal 0, 0, ByVal 0
MsgBox "8"
End Sub
Private Sub Form_Load()
' On Local Error Resume Next
Me.Show
InitD3D
Running = True
MsgBox "1"
Do While DoEvents
MsgBox "2"
d3dDevice.SetRenderTarget NewC, Nothing, 0
MsgBox "3"
d3dDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &H0, 1, 0
MsgBox "4"
Render
MsgBox "9"
Loop
Set MainC = Nothing
Set NewC = Nothing
Set TexRT = Nothing
Set d3dDevice = Nothing
Set d3d = Nothing
Set dx = Nothing
End Sub
Vovik писал(а):Как можно обмануть эту заразу?
Mikle писал(а):Vovik писал(а):Как можно обмануть эту заразу?
Переходи уже на девятку, эта ошибка скрыта в недрах dx8vb.dll.
Vovik писал(а):Это не дерект виноват. Просто нужно использовать D3DXRenderToSurface.
Видишь, только она работает корректно.Mikle писал(а):Vovik писал(а):Это не дерект виноват. Просто нужно использовать D3DXRenderToSurface.
Виноват, естественно, не директ, а его порт, зашитый в dx8vb.dll. Функция D3DXRenderToSurface портирована без ошибок, но это ещё не значит, что более низкоуровневая SetRenderTarget не обязана корректно работать.
Vovik писал(а):Видишь, только она работает корректно.
Хотелось бы DX9 под VB6, но толкового враппера до сих пор нет...Mikle писал(а):Vovik писал(а):Видишь, только она работает корректно.
Да, для тех, кто хочет продолжать использовать DX8 под VB6 - это вариант.
Вернуться в Раздел для Профессионалов
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 9