关闭

旋转的茶壶

575人阅读 评论(0) 收藏 举报
分类:
这里只贴关键代码,
void RenderScene(float _time)
{
    D3DXMATRIX rx,ry;
    static float y = 0.0f,x = 0.0f;

    D3DXMatrixRotationY(&ry,y);
    y+=_time;
    if(y>=6.28f)
    {
        y =0.0f;
    }

    D3DXMatrixRotationX(&rx,x);
    x+=_time;
    if(x>=6.28f)
    {
        x = 0.0f;
    }

    D3DXMATRIX p = rx*ry;

    g_device->SetTransform(D3DTS_WORLD,&p);

    g_device->Clear(0,0,D3DCLEAR_TARGET  ,0xffffffff,1.0f,0);

    g_device->BeginScene();

    g_mesh->DrawSubset(0);

    //
    g_device->EndScene();

    g_device->Present(0,0,0,0);
}

//主函数WinMain里面
static float ftime = (float)timeGetTime();

    
    while (msg.message!=WM_QUIT)
    {
        if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
        {
             TranslateMessage (&msg);
             DispatchMessage (&msg);
        }
        //
        else
        {
            float starttime = (float)timeGetTime();
            float timedelta = (starttime - ftime)*0.001f;
            RenderScene(timedelta);
            ftime = starttime;
        }
    }


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:39408次
    • 积分:843
    • 等级:
    • 排名:千里之外
    • 原创:47篇
    • 转载:0篇
    • 译文:0篇
    • 评论:8条
    文章分类
    最新评论