I have windowed DirectX8 set up with a picturebox on my form. This works fine, except that the picture box changes shape as the form resizes. Perhaps I'm doing this wrong, or perhaps it's by default, but when the pixturebox changes size the blitting from directx warps to fit inside the picturebox. Here's my initialization code.
VB Code:
Public Function Initialize() As Boolean 'On Error GoTo ErrHandler: Dim DispMode As D3DDISPLAYMODE Dim D3DWindow As D3DPRESENT_PARAMETERS Dim ColorKeyVal As Long Set dx = New DirectX8 Set D3D = dx.Direct3DCreate() Set D3DX = New D3DX8 DispMode.Format = D3DFMT_X8R8G8B8 D3DWindow.Windowed = 1 D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC 'D3DWindow.BackBufferCount = 1 D3DWindow.BackBufferFormat = DispMode.Format 'D3DWindow.BackBufferHeight = 480 'D3DWindow.BackBufferWidth = 640 D3DWindow.hDeviceWindow = frmEditor.picMain.hWnd Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmEditor.picMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow) D3DDevice.SetVertexShader FVF D3DDevice.SetRenderState D3DRS_LIGHTING, False D3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA D3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA D3DDevice.SetRenderState D3DRS_ALPHABLENDENABLE, True Set DI = dx.DirectInputCreate() Set DIDEV = DI.CreateDevice("GUID_SysKeyboard") DIDEV.SetCommonDataFormat DIFORMAT_KEYBOARD DIDEV.SetCooperativeLevel frmEditor.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE DIDEV.Acquire Initialize = True Exit Function ErrHandler: Debug.Print "Error Number Returned: " & Err.Number Debug.Print "Error Description: " & Err.description Initialize = False End Function
Where frmEditor is a standard VB form and frmEditor.picMain is a regular picturebox. Do I need to reinitialize directX each time the picturebox changes shape or is there an easier way around this? Thanks.




Reply With Quote