读书人

[ddraw] 为什么只有鼠标移动的时候才会

发布时间: 2012-02-11 09:51:35 作者: rapoo

[ddraw] 为什么只有鼠标移动的时候才会更新所渲染的图像?

C/C++ code
void CRender::Render(){    if (!m_bInit)    return;    int posX = 0;    int posY = 0;    POINT point ={ 0, 0 };    ::ClientToScreen(m_hWnd, &point);    posX+=point.x, posY+=point.y;    static int curFrame = 0;    static DWORD lastTime = GetTickCount();    if (m_SurfaceList[curFrame].m_pSurface != NULL)    {        RECT srcRect = { 0, 0, m_SurfaceList[curFrame].m_Width, m_SurfaceList[curFrame].m_Height };        RECT dstRect = { posX, posY, posX+m_SurfaceList[curFrame].m_Width, posY+m_SurfaceList[curFrame].m_Height };        m_pDDPrimarySurface->Blt(&dstRect, m_SurfaceList[curFrame].m_pSurface, &srcRect, DDBLTFAST_NOCOLORKEY|DDBLT_WAIT, NULL);    }    DWORD curTime = GetTickCount();    if (curTime-lastTime >= 60)    {        if (++curFrame >= _SURFACE_COUNT)        {            curFrame = 0;        }    }}


以上代码每隔60毫秒渲染一帧动画,但是运行的时候,鼠标动一下,他就渲染,鼠标不动就不渲染,什么原因?

[解决办法]
Render你又放在哪了?要是放在鼠标move中,他当然只有move时才被调用了呗。
[解决办法]
是不是消息循环用了 TranslateMEssage 没有用PeekMessage?

读书人网 >网络游戏

热点推荐