|
|
请问如果不考虑三角形数量,决定帧率的因数还有什么呢?
我做的程序帧率最高都是85,就算渲染一个三角形也是如此,这怎么可能呢!Dx9SDK里的例子很都跑几百帧的!
找不到原因啊,很痛苦!请帮我看看问题在哪里好吗
我的机器配置:AMD XP 2200+ , Readon 9600 Pro , 256 M 内存
创建D3D:
HRESULT InitD3D(HWND hWnd)
{
g_pd3d=Direct3DCreate9(D3D_SDK_VERSION);
D3DDISPLAYMODE d3ddm;
g_pd3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm);
D3DPRESENT_PARAMETERS stPresentParam;
ZeroMemory(&stPresentParam,sizeof(stPresentParam));
stPresentParam.Windowed = FALSE;
stPresentParam.FullScreen_RefreshRateInHz = 0;
stPresentParam.PresentationInterval = 0;
stPresentParam.BackBufferHeight = 600;
stPresentParam.BackBufferWidth = 800;
stPresentParam.BackBufferFormat=D3DFMT_A8R8G8B8;
stPresentParam.MultiSampleType =D3DMULTISAMPLE_2_SAMPLES;
stPresentParam.MultiSampleQuality =0;
stPresentParam.SwapEffect=D3DSWAPEFFECT_DISCARD;
stPresentParam.EnableAutoDepthStencil = TRUE;
stPresentParam.AutoDepthStencilFormat = D3DFMT_D16;
stPresentParam.BackBufferCount =1;
g_pd3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&stPresentParam,&g_pd3ddevice);
g_pd3ddevice->SetRenderState (D3DRS_ZENABLE,TRUE);
g_pd3ddevice->SetRenderState (D3DRS_ZFUNC,D3DCMP_LESS);
g_pd3ddevice->SetRenderState (D3DRS_ZWRITEENABLE,TRUE);
return 0;
}
渲染调用放在 CALLBACK WndProc 里的 WM_PAINT事件处理:
case WM_PAINT:
Render();
g_pd3ddevice-> resent (NULL,NULL,NULL,NULL);
break;
渲染过程:
void Render2()
{
RefreshMatrix();
g_pd3ddevice->Clear (0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,0x0,1.0f,0L);
if(SUCCEEDED(g_pd3ddevice->BeginScene ()))
{
g_pd3ddevice->DrawPrimitive (D3DPT_TRIANGLELIST,0,1);
g_pd3ddevice->EndScene ();
}
}
主过程消息循环:
for(;;)
{
if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
{
if (msg.message ==WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
Render();
}
}
没有用灯光,只设置了背景环境光为(255,255,255)
还需要其他过程的我再发上来
多谢了! |
|