Ok i don't know anything about DX8 and probably never will but for some reason i'm going ok (i've been learning from JR's Tutorial + another one i found on the net). I'm currently stuck rotating a simple 2D square. The problem seems to be in the way i initialise DX8 cause if i use code out of examples it works, but if i try and write the code it doesn't . I'm guessing its something very simple but i can't seem to figure it out.




VB Code:
  1. Public Const COLOR_DEPTH_16_BIT As Long = D3DFMT_R5G6B5
  2. Public Const COLOR_DEPTH_24_BIT As Long = D3DFMT_A8R8G8B8
  3. Public Const COLOR_DEPTH_32_BIT As Long = D3DFMT_X8R8G8B8
  4.  
  5. Public DirectX8 As DirectX8 'The master DirectX object.
  6. Public Direct3D As Direct3D8 'Controls all things 3D.
  7. Public Direct3DX As D3DX8
  8. Public Direct3D_Device As Direct3DDevice8 'Represents the hardware rendering.
  9.  
  10. Public Sub StartDirectX(MainForm As Form, ScreenWidth As Single, ScreenHeight As Single, ColourDepth As Single, FullScreen As Boolean)
  11. On Error GoTo errmsg
  12.  
  13.     Dim Display_Mode As D3DDISPLAYMODE 'Display mode desciption.
  14.     Dim Direct3D_Window As D3DPRESENT_PARAMETERS 'Backbuffer and viewport description.
  15.    
  16.     Set DirectX8 = New DirectX8 'Creates the DirectX object.
  17.     Set Direct3D = DirectX8.Direct3DCreate() 'Creates the Direct3D object using the DirectX object.
  18.        
  19.    
  20.     'Now that we are working with fullscreen mode, we must set up the
  21.     'screen resolution to switch to, rather than use the default screen
  22.     'resolution.
  23.     Select Case ColourDepth
  24.         Case 16
  25.             Display_Mode.Format = COLOR_DEPTH_16_BIT
  26.         Case 24
  27.             Display_Mode.Format = COLOR_DEPTH_24_BIT
  28.         Case 32
  29.             Display_Mode.Format = COLOR_DEPTH_32_BIT
  30.         Case Else
  31.             MsgBox "Invalid Colour Depth. Using Defualt"
  32.             Display_Mode.Format = COLOR_DEPTH_16_BIT
  33.     End Select
  34.    
  35.         Display_Mode.Width = ScreenWidth
  36.         Display_Mode.Height = ScreenHeight
  37.        
  38.         Direct3D_Window.BackBufferCount = 1 '1 backbuffer only
  39.         Direct3D_Window.BackBufferFormat = Display_Mode.Format 'Sets the format that was retrieved into the backbuffer.
  40.         Direct3D_Window.BackBufferWidth = Display_Mode.Width 'Match the backbuffer width with the display width
  41.         Direct3D_Window.BackBufferHeight = Display_Mode.Height 'Match the backbuffer height with the display height
  42.         Direct3D_Window.hDeviceWindow = MainForm.hWnd 'Use frmMain as the device window.
  43.         Direct3D_Window.AutoDepthStencilFormat = D3DFMT_D16
  44.        
  45.    
  46.     If FullScreen = True Then
  47.         Direct3D_Window.Windowed = False 'The app will be in fullscreen mode.
  48.     Else
  49.    
  50.         'Direct3D.GetAdapterDisplayMode D3DADAPTER_DEFAULT, Display_Mode 'Use the current display mode that you
  51.                                                                         'are already on. Incase you are confused, I'm
  52.                                                                         'talking about your current screen resolution. ;)
  53.        
  54.         Direct3D_Window.Windowed = True 'The app will be in windowed mode.
  55.    
  56.     End If
  57.    
  58.     Direct3D_Window.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC 'Refresh when the monitor does.
  59.      
  60.    
  61.     'Creates the rendering device with some useful info, along with the info
  62.     'we've already setup for Direct3D_Window.
  63.     Set Direct3D_Device = Direct3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, MainForm.hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, Direct3D_Window)
  64.  
  65.        
  66.     Direct3D_Device.SetVertexShader FVF_TLVERTEX 'Set the type of vertex shading. (Required)
  67.    
  68.     'Direct3D_Device.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
  69.     Direct3D_Device.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
  70.     Direct3D_Device.SetRenderState D3DRS_ALPHABLENDENABLE, True
  71.    
  72.     Direct3D_Device.SetRenderState D3DRS_LIGHTING, 0   '//Disable lighting.
  73.     Direct3D_Device.SetRenderState D3DRS_ZENABLE, 1
  74.     Direct3D_Device.SetRenderState D3DRS_CULLMODE, D3DCULL_NONE
  75.    
  76.    
  77.     Direct3D_Device.SetTextureStageState 0, D3DTSS_MINFILTER, D3DTEXF_POINT
  78.     Direct3D_Device.SetTextureStageState 0, D3DTSS_MAGFILTER, D3DTEXF_POINT
  79.    
  80.     Running = True 'Initializations all set. It's now ok to activate the game loop.
  81.    
  82.    
  83.    
  84. '    '//configure the world matrices
  85. '
  86. '    '//1. The World Matrix
  87. '    D3DXMatrixIdentity matWorld
  88. '    Direct3D_Device.SetTransform D3DTS_WORLD, matWorld 'commit this matrix to the device
  89. '
  90. '    '//2. The View Matrix
  91. '    D3DXMatrixLookAtLH matView, MakeVector(0, 5, 2), MakeVector(0, 0, 0), MakeVector(0, 1, 0)
  92. '    Direct3D_Device.SetTransform D3DTS_VIEW, matView
  93. '
  94. '    '//3. The projection Matrix
  95. '    D3DXMatrixPerspectiveFovLH matProj, pi / 3, 1, 0.1, 75
  96. '    Direct3D_Device.SetTransform D3DTS_PROJECTION, matProj
  97.    
  98.    
  99.    
  100.     MainForm.GameLoop
  101.    
  102. Exit Sub
  103. errmsg:
  104. MsgBox "Error number " & Err.Number & vbNewLine & Err.Description
  105. Running = False
  106. CloseDirectX
  107. End Sub
and to start DX i use
VB Code:
  1. StartDirectX Me, 1024, 768, 16, True
to rotate i use
VB Code:
  1. D3DXMatrixIdentity matWorld
  2.    
  3.     D3DXMatrixIdentity matTemp
  4.     D3DXMatrixRotationX matTemp, Angle * RAD
  5.     D3DXMatrixMultiply matWorld, matWorld, matTemp
  6.    
  7.     D3DXMatrixIdentity matTemp
  8.     D3DXMatrixRotationY matTemp, Angle * RAD
  9.     D3DXMatrixMultiply matWorld, matWorld, matTemp
  10.    
  11.     D3DXMatrixIdentity matTemp
  12.     D3DXMatrixRotationZ matTemp, Angle * RAD
  13.     D3DXMatrixMultiply matWorld, matWorld, matTemp
  14.    
  15.     Angle = Angle + 1
  16.    
  17.     Direct3D_Device.SetTransform D3DTS_WORLD, matWorld

Thanks