⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 surfacecreator.cpp

📁 java实现的简单的分形树。简单易学!是学习分形知识的很好的例子。其java语法简单
💻 CPP
字号:
// --------------------------------------------------------------------------
// Dingus project - a collection of subsystems for game/graphics applications
// --------------------------------------------------------------------------
#include "stdafx.h"

#include "SurfaceCreator.h"
#include "../utils/Errors.h"
#include "../kernel/D3DDevice.h"
#include "../console/Console.h"

using namespace dingus;

IDirect3DSurface9* CAbstractSurfaceCreator::internalCreate( int width, int height ) const
{
	HRESULT hres;
	IDirect3DSurface9* surface = NULL;

	CD3DDevice& dx = CD3DDevice::getInstance();
	D3DMULTISAMPLE_TYPE msType = mMultiSampleType;
	DWORD msQty = mMultiSampleQuality;
		
	if( mDepthStencil ) {
		if( mUseScreenMultiSample ) {
			msType = dx.getMainZStencilDesc().MultiSampleType;
			msQty = dx.getMainZStencilDesc().MultiSampleQuality;
		}
		hres = dx.getDevice().CreateDepthStencilSurface(
			width, height, mFormat, msType, msQty, FALSE, &surface, NULL );
	} else {
		if( mUseScreenMultiSample ) {
			msType = dx.getBackBufferDesc().MultiSampleType;
			msQty = dx.getBackBufferDesc().MultiSampleQuality;
		}
		hres = dx.getDevice().CreateRenderTarget(
			width, height, mFormat, msType, msQty, FALSE, &surface, NULL );
	}
	if( FAILED( hres ) ) {
		std::string msg = "failed to create surface";
		CConsole::CON_ERROR.write(msg);
		THROW_DXERROR( hres, msg );
	}
	assert( surface );
	return surface;
}

IDirect3DSurface9* CFixedSurfaceCreator::createSurface()
{
	return internalCreate( mWidth, mHeight );
};


IDirect3DSurface9* CScreenBasedSurfaceCreator::createSurface()
{
	CD3DDevice& device = CD3DDevice::getInstance();
	int width = int( device.getBackBufferWidth() * mWidthFactor );
	int height = int( device.getBackBufferHeight() * mHeightFactor );
	return internalCreate( width, height );
};


IDirect3DSurface9* CScreenBasedPow2SurfaceCreator::createSurface()
{
	CD3DDevice& device = CD3DDevice::getInstance();
	int width = int( device.getBackBufferWidth() * mWidthFactor );
	int height = int( device.getBackBufferHeight() * mHeightFactor );
	
	// lower width/height to be power-of-2
	int hibit;
	hibit = 0;
	while( width>>hibit != 0 )
		++hibit;
	width &= (1<<(hibit-1));
	hibit = 0;
	while( height>>hibit != 0 )
		++hibit;
	height &= (1<<(hibit-1));

	return internalCreate( width, height );
};

IDirect3DSurface9* CTextureLevelSurfaceCreator::createSurface()
{
	HRESULT hres;
	IDirect3DSurface9* surface = NULL;

	assert( mTexture );
	assert( mTexture->getObject() );
	hres = mTexture->getObject()->GetSurfaceLevel( mLevel, &surface );
	if( FAILED( hres ) ) {
		std::string msg = "failed to obtain texture level surface";
		CConsole::CON_ERROR.write(msg);
		THROW_DXERROR( hres, msg );
	}
	assert( surface );
	return surface;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -