Hi shocky.
here is a quick solution that let you compile some demos.
just reolace the Start.bas file in your computer with this
#include once "windows.bi"
#include once "win/d3d9.bi"
#include once "win/d3dx9.bi"
''-----------------------------------------------------------------------------
'' GLOBALS
''-----------------------------------------------------------------------------
dim shared as HWND g_hWnd = NULL
dim shared as LPDIRECT3D9 g_pD3D = NULL
dim shared as LPDIRECT3DDEVICE9 g_pd3dDevice = NULL
''-----------------------------------------------------------------------------
'' PROTOTYPES
''-----------------------------------------------------------------------------
declare function WindowProc( byval hWnd as HWND, byval msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
declare sub init()
declare sub shutDown()
declare sub render()
sub InitDirectX9(wwidth as integer ,height as integer )
dim x = (GetSystemMetrics(SM_CXSCREEN)-wwidth) shr 1
dim y = (GetSystemMetrics(SM_CYSCREEN)-height) shr 1
SetWindowPos(g_hWnd,NULL,x,y,wwidth,height,SWP_NOZORDER or SWP_FRAMECHANGED)
g_pD3D = Direct3DCreate9( D3D_SDK_VERSION )
dim as D3DDISPLAYMODE d3ddm
IDirect3D9_GetAdapterDisplayMode( g_pD3D, D3DADAPTER_DEFAULT, @d3ddm )
dim as D3DPRESENT_PARAMETERS d3dpp
clear( d3dpp, 0, len(d3dpp) )
d3dpp.Windowed = TRUE
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD
d3dpp.BackBufferFormat = d3ddm.Format
d3dpp.EnableAutoDepthStencil = TRUE
d3dpp.AutoDepthStencilFormat = D3DFMT_D16
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE
d3dpp.BackBufferWidth = wwidth
d3dpp.BackBufferHeight = height
d3dpp.BackBufferCount = 2
IDirect3D9_CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, _
D3DCREATE_HARDWARE_VERTEXPROCESSING, _
@d3dpp, @g_pd3dDevice )
if(g_pD3D = NULL) then IDirect3D9_CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, _
D3DCREATE_HARDWARE_VERTEXPROCESSING, _
@d3dpp, @g_pd3dDevice )
if(g_pD3D = NULL) then end -1
'' create camera
dim as D3DXMATRIXA16 mView , Projection
dim as D3DXVECTOR3 Eye , LookAt , Up
Eye.x = 0.0 : Eye.y = 0.0 : Eye.Z =-1.0
LookAt.x = 0.0 : LookAt.y = 0.0 : LookAt.Z = 0.0
Up.x = 0.0 : Up.y = 1.0 : Up.Z = 0.0
D3DXMatrixLookAtLH(@mView, @Eye, @LookAt, @Up)
IDirect3DDevice9_SetTransform(g_pd3dDevice, D3DTS_VIEW, @mView)
dim as D3DXMATRIX mProjection
D3DXMatrixPerspectiveFovLH( @mProjection, D3DXToRadian( 45.0f ), 1.0f, 1.0f, 3000.0f )
IDirect3DDevice9_SetTransform(g_pd3dDevice, D3DTS_PROJECTION, @mProjection )
IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_LIGHTING, FALSE)
IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_CULLMODE, D3DCULL_NONE)
End sub
sub DX9_BiginScene(_color as integer)
IDirect3DDevice9_Clear( g_pd3dDevice, 0, NULL, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, _
_color, 1.0f, 0 )
IDirect3DDevice9_BeginScene(g_pd3dDevice)
end sub
sub DX9_EndScene()
IDirect3DDevice9_EndScene(g_pd3dDevice)
IDirect3DDevice9_Present(g_pd3dDevice, NULL, NULL, NULL, NULL )
end sub
sub closeDirectX9()
if( g_pd3dDevice <> NULL ) then
IDirect3DDevice9_Release(g_pd3dDevice)
end if
if( g_pD3D <> NULL ) then
IDirect3D9_Release( g_pD3D )
end if
end sub
''-----------------------------------------------------------------------------
'' Name: WinMain()
'' Desc: The application's entry point
''-----------------------------------------------------------------------------
function WinMain(byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval lpCmdLine as string, _
byval nCmdShow as integer _
) as integer
dim as WNDCLASSEX winClass
dim as MSG uMsg
with winClass
.lpszClassName = @"MY_WINDOWS_CLASS"
.cbSize = len(WNDCLASSEX)
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WindowProc
.hInstance = hInstance
.hIcon = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
.hIconSm = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
.hCursor = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = cast(HBRUSH,GetStockObject(BLACK_BRUSH))
.lpszMenuName = NULL
.cbClsExtra = 0
.cbWndExtra = 0
end with
if( RegisterClassEx( @winClass ) = FALSE ) then
return E_FAIL
end if
g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", _
"Direct3D (DX9) - Primitive Types", _
WS_OVERLAPPEDWINDOW or WS_VISIBLE, _
0, 0, 640, 480, NULL, NULL, hInstance, NULL )
if( g_hWnd = NULL ) then
return E_FAIL
end if
ShowWindow( g_hWnd, nCmdShow )
UpdateWindow( g_hWnd )
init()
do while( uMsg.message <> WM_QUIT )
if( PeekMessage( @uMsg, NULL, 0, 0, PM_REMOVE ) ) then
TranslateMessage( @uMsg )
DispatchMessage( @uMsg )
else
render()
end if
loop
shutDown()
UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance )
return uMsg.wParam
end function
''-----------------------------------------------------------------------------
'' Name: WindowProc()
'' Desc: The window's message handler
''-----------------------------------------------------------------------------
function WindowProc( byval hWnd as HWND, _
byval msg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM _
) as LRESULT
select case ( msg )
case WM_KEYDOWN
select case( wParam )
case VK_ESCAPE
PostQuitMessage(0)
end select
case WM_CLOSE
PostQuitMessage(0)
case WM_DESTROY
PostQuitMessage(0)
case else
return DefWindowProc( hWnd, msg, wParam, lParam )
end select
return 0
end function
''-----------------------------------------------------------------------------
'' Name: shutDown()
'' Desc: Release all Direct3D resources.
''-----------------------------------------------------------------------------
sub shutDown( )
closeDirectX9()
end sub