利用IDirect3DSurface9创建一个表面,并使它显示红色

本文介绍如何利用DirectX 9.0 API中的IDirect3DSurface9接口创建并设置一个显示为红色的表面。在探索过程中,遇到了LockRect方法的使用问题,经过研究最终成功解决。博客中提及了LockRect失败的解决方案。
摘要由CSDN通过智能技术生成
		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
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值