Results 1 to 14 of 14

Thread: [Vb6] Windowed DirectX8[Resolved]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Resolved [Vb6] Windowed DirectX8[Resolved]

    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:
    1. Public Function Initialize() As Boolean
    2.   'On Error GoTo ErrHandler:
    3.  
    4.   Dim DispMode As D3DDISPLAYMODE
    5.   Dim D3DWindow As D3DPRESENT_PARAMETERS
    6.   Dim ColorKeyVal As Long
    7.  
    8.   Set dx = New DirectX8  
    9.   Set D3D = dx.Direct3DCreate()
    10.   Set D3DX = New D3DX8
    11.  
    12.  
    13.  
    14.   DispMode.Format = D3DFMT_X8R8G8B8    
    15.   D3DWindow.Windowed = 1
    16.   D3DWindow.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC
    17.   'D3DWindow.BackBufferCount = 1
    18.   D3DWindow.BackBufferFormat = DispMode.Format
    19.   'D3DWindow.BackBufferHeight = 480
    20.   'D3DWindow.BackBufferWidth = 640
    21.   D3DWindow.hDeviceWindow = frmEditor.picMain.hWnd
    22.  
    23.  
    24.   Set D3DDevice = D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frmEditor.picMain.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, D3DWindow)
    25.  
    26.   D3DDevice.SetVertexShader FVF
    27.  
    28.   D3DDevice.SetRenderState D3DRS_LIGHTING, False
    29.  
    30.   D3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
    31.   D3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
    32.   D3DDevice.SetRenderState D3DRS_ALPHABLENDENABLE, True
    33.  
    34.   Set DI = dx.DirectInputCreate()
    35.   Set DIDEV = DI.CreateDevice("GUID_SysKeyboard")
    36.  
    37.   DIDEV.SetCommonDataFormat DIFORMAT_KEYBOARD
    38.   DIDEV.SetCooperativeLevel frmEditor.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE
    39.   DIDEV.Acquire
    40.  
    41.   Initialize = True
    42.   Exit Function
    43. ErrHandler:
    44. Debug.Print "Error Number Returned: " & Err.Number
    45. Debug.Print "Error Description: " & Err.description
    46. Initialize = False
    47. 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.
    Last edited by Nove; Nov 6th, 2005 at 12:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width