Original Post
I'm trying to load a mesh using a .x file that i made. It's based off the sdk tutorial since thats what im learning it from. I retyped it and try to make it so it only loads a mesh(instead of also applying a texture and rotating it).
the program had 29 errors originally, but I managed to get it down to these six that i cant figure out.
here is the errors:
(45) : error C2664: 'D3DXLoadMeshFromXA' : cannot convert parameter 7 from 'DWORD' to 'DWORD *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
(49) : error C2065: 'd3dxMaterials' : undeclared identifier
(56) : error C2065: 'd3dxMaterials' : undeclared identifier
(56) : error C2228: left of '.MatD3D' must have class/struct/union
(108) : error C2446: '<' : no conversion from 'D3DMATERIAL9 *' to 'DWORD'
There is no context in which this conversion is possible
(108) : error C2040: '<' : 'DWORD' differs in levels of indirection from 'D3DMATERIAL9 *'
here is the code:
MOD EDIT: Added source tags
[Edited by - Evil Steve on June 7, 2010 5:02:07 AM]
the program had 29 errors originally, but I managed to get it down to these six that i cant figure out.
here is the errors:
(45) : error C2664: 'D3DXLoadMeshFromXA' : cannot convert parameter 7 from 'DWORD' to 'DWORD *' Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
(49) : error C2065: 'd3dxMaterials' : undeclared identifier
(56) : error C2065: 'd3dxMaterials' : undeclared identifier
(56) : error C2228: left of '.MatD3D' must have class/struct/union
(108) : error C2446: '<' : no conversion from 'D3DMATERIAL9 *' to 'DWORD'
There is no context in which this conversion is possible
(108) : error C2040: '<' : 'DWORD' differs in levels of indirection from 'D3DMATERIAL9 *'
here is the code:
//includes#include <Windows.h>#include <mmsystem.h>#include <d3dx9.h>//global variablesLPDIRECT3D9 d3d = NULL;LPDIRECT3DDEVICE9 d3d_device = NULL;LPD3DXMESH mesh = NULL;D3DMATERIAL9* materials = NULL;DWORD NumMaterials = NULL;//initialize functionHRESULT InitD3D(HWND hWnd){ if(NULL == (d3d = Direct3DCreate9(D3D_SDK_VERSION))) return E_FAIL; D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; if(FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3d_device))) { return E_FAIL; } d3d_device->SetRenderState(D3DRS_ZENABLE, TRUE); d3d_device->SetRenderState(D3DRS_AMBIENT, 0xffffffff); return S_OK;}HRESULT InitGeometry(){ LPD3DXBUFFER buffer; if(FAILED(D3DXLoadMeshFromX("Cube.x", D3DXMESH_SYSTEMMEM, d3d_device, NULL, &buffer, NULL, NumMaterials, &mesh))) D3DXMATERIAL* d3dxMaterials;d3dxMaterials = ( D3DXMATERIAL* )buffer->GetBufferPointer(); materials = new D3DMATERIAL9[NumMaterials]; if( materials == NULL ) return E_OUTOFMEMORY; for( DWORD i = 0; i < NumMaterials; i++ ) { materials = d3dxMaterials.MatD3D; materials.Ambient = materials.Diffuse; } buffer->Release(); return S_OK;}VOID Cleanup(){ if(materials != NULL) delete[] materials; if( mesh != NULL ) mesh->Release(); if( d3d_device != NULL ) d3d_device->Release(); if( d3d != NULL ) d3d->Release();}VOID SetupMatrices(){ D3DXMATRIXA16 matWorld; D3DXMatrixRotationY( &matWorld, timeGetTime() / 1000.0f ); d3d_device->SetTransform( D3DTS_WORLD, &matWorld ); D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f ); D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f ); D3DXMATRIXA16 matView; D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec ); d3d_device->SetTransform( D3DTS_VIEW, &matView ); D3DXMATRIXA16 matProj; D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI / 4, 1.0f, 1.0f, 100.0f ); d3d_device->SetTransform( D3DTS_PROJECTION, &matProj );}VOID Render(){ d3d_device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 225), 1.0f, 0); if(SUCCEEDED(d3d_device->BeginScene() )) { SetupMatrices(); for( DWORD i = 0; i < materials; i++ ) { d3d_device->SetMaterial( &materials ); mesh->DrawSubset( i ); } d3d_device->EndScene(); } d3d_device->Present( NULL, NULL, NULL, NULL );}LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ){ switch( msg ) { case WM_DESTROY: Cleanup(); PostQuitMessage( 0 ); return 0; } return DefWindowProc( hWnd, msg, wParam, lParam );}INT WINAPI wWinMain( HINSTANCE hInst, HINSTANCE, LPWSTR, INT ){ WNDCLASSEX wc = { sizeof( WNDCLASSEX ), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle( NULL ), NULL, NULL, NULL, NULL, "meshes", NULL }; RegisterClassEx( &wc ); HWND hWnd = CreateWindow( "meshes", "meshes", WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL ); if( SUCCEEDED( InitD3D( hWnd ) ) ) { if( SUCCEEDED( InitGeometry() ) ) { ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd ); MSG msg; ZeroMemory( &msg, sizeof( msg ) ); while( msg.message != WM_QUIT ) { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else Render(); } } } UnregisterClass( "meshes", wc.hInstance ); return 0;}MOD EDIT: Added source tags
[Edited by - Evil Steve on June 7, 2010 5:02:07 AM]