Device->BeginScene();
// assume _surface is a pointer to an idirect3dsurface9 interface.
// assumes a 32-bit pixel format for each pixel.
// get the surface description.描述表面
D3DSURFACE_DESC surfacedesc;
Device->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO,&_surface);
_surface->GetDesc(&surfacedesc);//注意已经假定了_surface是指向idirect3dsurface9借//口的指针
// get a pointer to the surface pixel data.取得指向该内存区的指针
D3DLOCKED_RECT lockedrect;
_surface->LockRect(
&lockedrect,// pointer to receive locked data指向申请到的内存区域
0, // lock entire surface
0); // no lock flags specified
// iterate through each pixel in the surface and set it to red.设置指定的表面为红色
DWORD * imagedata = (DWORD *)lockedrect.pBits;
for(int i = 0; i < surfacedesc.Height; i++)
{
for(int j = 0; j < surfacedesc.Width; j++)
{
// index into texture, note we use the pitch and divide by
// fou
利用IDirect3DSurface9创建一个表面,并使它显示红色
最新推荐文章于 2022-09-02 20:05:23 发布
本文介绍如何利用DirectX 9.0 API中的IDirect3DSurface9接口创建并设置一个显示为红色的表面。在探索过程中,遇到了LockRect方法的使用问题,经过研究最终成功解决。博客中提及了LockRect失败的解决方案。
摘要由CSDN通过智能技术生成