游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1043|回复: 0

When does the surface UnlockRect

[复制链接]

414

主题

611

帖子

621

积分

高级会员

Rank: 4

积分
621
发表于 2008-5-14 23:18:00 | 显示全部楼层 |阅读模式
Can I timely let surface UnlockRect after LockRect.
Is the "<==position1" surface UnlockRect postion correct? Does it have any probelm about the pointer of "lrect_New.pBits"?


  1.         HRESULT hr;

  2.         LPDIRECT3DSURFACE9 pDestSurface_New;
  3.         D3DLOCKED_RECT lrect_New;
  4.         D3DSURFACE_DESC Desc;

  5.         m_QVSM_pShadowMapSurf_Common->GetDesc(&Desc);
  6.         V(m_pd3dDevice->CreateOffscreenPlainSurface(Desc.Width,Desc.Height,Desc.Format,D3DPOOL_SYSTEMMEM,&pDestSurface_New,NULL));//Must be D3DPOOL_SYSTEMMEM for MSDN
  7.         V(m_pd3dDevice->GetRenderTargetData(m_QVSM_pShadowMapSurf_Common,pDestSurface_New));

  8.         hr=pDestSurface_New->LockRect(&lrect_New,NULL,D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_READONLY);
  9.         //hr=pDestSurface_New->UnlockRect();//<==position1

  10.         for (LONG y=0;y<(LONG)Desc.Height;y++)
  11.         {
  12.                 DWORD dwOffset = y*Desc.Width;

  13.                 for (LONG x=0;x<(LONG)Desc.Width;x++)
  14.                 {
  15.                         //float dwColor_New = ((float*)lrect_New.pBits)[y*(lrect_New.Pitch/sizeof(float))+x];//Y*Width+X
  16.                         float dwColor_New = ((float*)lrect_New.pBits)[y*Desc.Width+x];//Y*Width+X
  17.                         int c=12;
  18.                 }
  19.         }

  20.         hr=pDestSurface_New->UnlockRect();//<==position2

  21.         SAFE_RELEASE(pDestSurface_New);
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-22 12:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表