设置世界变化矩阵
D3DXMATRIX mat_world;
D3DXMatrixIdentity(&mat_world); g_pd3dDevice->SetTransform(D3DTS_WORLD,&mat_world);设置观察矩阵
D3DXVECTOR3 eye(0.0f,0.0f,-10.0f); D3DXVECTOR3 lookat(0.0f,0.0f,0.0f); D3DXVECTOR3 up(0.0f,1.0f,0.0f); D3DXMATRIX mat_view; D3DXMatrixLookAtLH(&mat_view,&eye,&lookat,&up); g_pd3dDevice->SetTransform(D3DTS_VIEW,&mat_view); 设置投影变换矩阵 D3DXMATRIX mat_proj; D3DXMatrixPerspectiveFovLH(&mat_proj,D3DX_PI/2,1.0f,1.0f,100.0f);g_pd3dDevice->SetTransform(D3DTS_PROJECTION,&mat_proj);
创建非多级渐进纹理:
D3DXCreateTextureFromFileEx( g_pd3dDevice,
L"texture.jpg", 0, 0, //纹理宽度和高度, "0"表示以图形文件的宽度和高度作为纹理的宽度和高度1, //渐进纹理序列级数 0, //纹理使用方式, 一般为0D3DFMT_X8R8G8B8, //纹理图形格式D3DPOOL_MANAGED, //纹理资源的内存类型D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000,0,0, &g_pTexture )创建多级渐进纹理:
D3DXCreateTextureFromFileEx( g_pd3dDevice,
L"texture.jpg",0, 0, //纹理宽度和高度, "0"表示以图形文件的宽度和高度作为纹理的宽度和高度 0, //渐进纹理序列级数0, //纹理使用方式, 一般为0D3DFMT_X8R8G8B8, //纹理图形格式D3DPOOL_MANAGED, //纹理资源的内存类型D3DX_DEFAULT, D3DX_DEFAULT, 0xFF000000,0,0, &g_pMipTex )纹理过滤:
最近点采样
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);线性过滤
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);版权声明:本文为博主原创文章,未经博主允许不得转载。