I know somone just asked about meshes not being displayed, and i read it and checked and its not the problem i am having.
I cant get meshes to be displayed at all.
The app works, and runs in full screen, but all i get is blackness.
The following is the code i have used.
Game Init:
if( NULL == ( g_pd3d = Direct3DCreate9( D3D_SDK_VERSION )))
return;
#ifndef DEBUG
// Get Display modes
UINT displayModeCount = g_pd3d->GetAdapterModeCount( D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8 );
// Go Through the display modes
for( UINT displayMode = 0; displayMode < displayModeCount; displayMode++ )
{
//Check current display mode
g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8, displayMode, &g_d3dDisplayMode );
// If it matches what i want, break out
if( g_d3dDisplayMode.Width == SCREENWIDTH && g_d3dDisplayMode.Height == SCREENHEIGHT )
break;
}// End For
// Make sure the display mode was matched
if( g_d3dDisplayMode.Width != SCREENWIDTH && g_d3dDisplayMode.Height != SCREENHEIGHT )
{
MessageBox( NULL, "NO DISPLAY MODE FOUND", "No Display mode found", NULL );
PostQuitMessage( 0 );
return;
} // End if
// Setup the d3d Present parameters
ZeroMemory( &g_d3dpp, sizeof( g_d3dpp ));
g_d3dpp.BackBufferCount = 1;
g_d3dpp.BackBufferHeight = g_d3dDisplayMode.Height;
g_d3dpp.BackBufferWidth = g_d3dDisplayMode.Width;
g_d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
g_d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
g_d3dpp.BackBufferFormat = g_d3dDisplayMode.Format;
g_d3dpp.hDeviceWindow = g_hwnd;
g_d3dpp.Windowed = false;
g_d3dpp.EnableAutoDepthStencil = true;
g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
g_d3dpp.Flags = NULL;
g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;
g_d3dpp.FullScreen_RefreshRateInHz = g_d3dDisplayMode.RefreshRate;
// Create the d3d Device
if( FAILED( g_pd3d->CreateDevice( D3DADAPTER_DEFAULT, // Use the defualt adapter
D3DDEVTYPE_HAL, // Use hardware layer
g_hwnd, // focus window handle
D3DCREATE_SOFTWARE_VERTEXPROCESSING, // Use HARDWARE for vertex processing
&g_d3dpp, // Present params
&g_pd3dDevice ))) // Ponter to device
{
MessageBox( NULL, "Could not create Divice", "Could not create device", NULL );
return;
}
// Store Device type
g_d3dDevType = D3DDEVTYPE_HAL;
// Setup the view port
g_d3dVpMain.X = 0;
g_d3dVpMain.Y = 0;
g_d3dVpMain.Width = SCREENWIDTH;
g_d3dVpMain.Height = SCREENHEIGHT;
g_d3dVpMain.MinZ = 0.0f;
g_d3dVpMain.MaxZ = 1.0f;
// Set Viewport
g_pd3dDevice->SetViewport( &g_d3dVpMain );
Then Scene init
// init the camera
D3DXVECTOR3 vLookAt, vEyePt, vUpVec;
vLookAt.x = 0.0f; vLookAt.y = 0.0f; vLookAt.z = 5.0f;
vEyePt.x = 0.0f; vEyePt.y = 0.0f; vEyePt.z = 0.0f;
vUpVec.x = 0.0f; vUpVec.y = 1.0f; vUpVec.z = 0.0f;
g_Camera.SetViewParams( vEyePt, vLookAt, vUpVec );
g_Camera.SetProjParams( D3DX_PI / 4, SCREENWIDTH / SCREENHEIGHT, 0.0f, 500.0f );
// init the ground
g_Ground.Create( g_pd3dDevice, "xground.x" );
g_Ground.SetFVF( g_pd3dDevice, D3DFVF_CUSTOMVERTEX );
D3DXVECTOR3 vLoc;
D3DXMATRIX matTemp;
vLoc.x = 0; vLoc.y = 0; vLoc.z = 10;
D3DXMatrixTransformation( &matTemp, NULL, NULL, NULL, NULL, NULL, &vLoc );
g_Ground.SetMatrix( matTemp );
SAFERELEASE( &matTemp );
SAFERELEASE( vLoc );
Then in render
// This debug code will just set the camera and view matrices, and then render the temp ground.
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER | D3DCLEAR_TARGET,
D3DCOLOR_XRGB( 0,0,255 ), 1.0f, 0 );
// Set the world matrix
D3DXMatrixIdentity( &g_WorldMat );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &g_WorldMat );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &g_Camera.GetViewMatrix() );
g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &g_Camera.GetProjMatrix() );
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );
// Begin the scene
g_pd3dDevice->BeginScene();
g_Ground.Render( &g_pd3dDevice, g_WorldMat );
g_pd3dDevice->EndScene();
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
I have been playing with diffrent matries and moving the camera, but i get nothing.
Maybe i am using the CD3DFile class wrong? But i cant find any tuts or examples on it. I just am going from what i can figure out after reading all the code for it.
Anyone have any ideas what i am doing wrong?
Many thanks in advance