j'ai réaliser un code ou je charge un ballon de foot sous format .x puis je lui applique une texture wood.bitmap

le probéme rencontrer est que la texture ne s'applique pas.

voici le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);
 
 	// TODO: Place code here.
	MSG msg;
	HACCEL hAccelTable;
 
	// Initialize global strings
	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
	LoadString(hInstance, IDC_BALLWISARD, szWindowClass, MAX_LOADSTRING);
	MyRegisterClass(hInstance);
 
	// Perform application initialization:
	if (!InitInstance (hInstance, nCmdShow))
	{
		return FALSE;
	}
     init();
	hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_BALLWISARD));
 
	// Main message loop:
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (!TranslateAccelerator(g_hWnd, hAccelTable, &msg))//msg.hwnd, hAccelTable, &msg))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		 render();
	}
    shutDown();
	return (int) msg.wParam;
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
void loadTexture( void )
{
	D3DXCreateTextureFromFile( g_pd3dDevice,CA2W("woodfloor.bitmap"), &g_pTexture );
 
	g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
	g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
void init( void )
{
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
 
    D3DDISPLAYMODE d3ddm;
 
    g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );
 
    D3DPRESENT_PARAMETERS d3dpp;
	//D3DPRESENT_PARAMETERS presParams;
	memset(&d3dpp,0,sizeof(d3dpp));
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
 
    d3dpp.Windowed               = TRUE;
    d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat       = d3ddm.Format;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
    d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE;
    g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd,
                          D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                          &d3dpp, &g_pd3dDevice );
 
     loadTexture();	
 
	 HRESULT hr = 0;
	ID3DXBuffer* adjBuffer = 0;
ID3DXBuffer* mtrlBuffer = 0;
DWORD numMtrls = 0;
 hr = D3DXLoadMeshFromX(CA2W("Tiger.x"),D3DXMESHTYPE_MESH,g_pd3dDevice,&adjBuffer,
                        &mtrlBuffer,0,&numMtrls,&g_pMesh);
 
    D3DXMATRIX matProj;
    D3DXMatrixPerspectiveFovLH( &matProj, D3DXToRadian( 45.0f ), 
                                640.0f / 480.0f, 0.1f, 100.0f );
    g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
 
	g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
	// Setup basic render state
 
	}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void render( void )
{
    g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
                         D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 );
 
     D3DXMATRIX matTrans;
	D3DXMATRIX matRot;
	D3DXMATRIX matWorld;
 
     D3DXMatrixRotationYawPitchRoll( &matRot,
		                            D3DXToRadian(mt),
		                            D3DXToRadian(mt),
		                            0.0f );
 
    mt=mt+20;
    D3DXMatrixTranslation( &matTrans, 0.0f, 0.0f, 45.0f );
 
    matWorld = matRot * matTrans;
    g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
    g_pd3dDevice->BeginScene();
 
    g_pd3dDevice->SetTexture( 0, g_pTexture );
 
    g_pMesh->DrawSubset(1);
 
    g_pd3dDevice->EndScene();
    g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}