当前位置: 首页>>代码示例>>C++>>正文


C++ ConstantBuffer::AddVariable方法代码示例

本文整理汇总了C++中ConstantBuffer::AddVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantBuffer::AddVariable方法的具体用法?C++ ConstantBuffer::AddVariable怎么用?C++ ConstantBuffer::AddVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConstantBuffer的用法示例。


在下文中一共展示了ConstantBuffer::AddVariable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BuildCBFPRLights

	AEResult BuildCBFPRLights(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_FPR_LightCulling
		//
		//		cbuffer _AE_CB_FPR_Lights : register(b0)
		//		{
		//			float3	_AE_CameraPos			: packoffset(c0);
		//			uint	_AE_WindowWidth			: packoffset(c0.w);
		//		};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_HalfPixel
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_FPR_LIGHTS_NAME);

		/**************************************
		*Add Var 1: _AE_CameraPos
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_CAMERA_POS_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 3;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::vec3);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::vec3);
		scv->m_ShaderVariableClass = ShaderVariableClass::Vector;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 2: _AE_WindowWidth
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_WINDOW_WIDTH_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 1;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(uint32_t);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(uint32_t);
		scv->m_ShaderVariableClass = ShaderVariableClass::Scalar;
		scv->m_ShaderVariableType = ShaderVariableType::UInt;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:101,代码来源:BuiltInMaterialsDefs.cpp

示例2: BuildCBFPRLightCulling

	AEResult BuildCBFPRLightCulling(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_FPR_LightCulling
		//
		//		cbuffer _AE_CB_FPR_LightCulling : register(b0)
		//		{
		//			matrix	_AE_View				: packoffset(c0);
		//			matrix	_AE_InvProjection		: packoffset(c4);
		//		
		//			uint	_AE_WindowHeight		: packoffset(c8.x);
		//			uint	_AE_WindowWidth			: packoffset(c8.y);
		//			uint	_AE_NumLights			: packoffset(c8.z);
		//		};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_FPR_LightCulling
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_FPR_LIGHT_CULLING_NAME);

		/**************************************
		*Add Var 1: _AE_View
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_VIEW_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 2: _AE_InvProjection
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_INV_PROJECTION_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 3: _AE_WindowHeight
		***************************************/
		scv = new ShaderCustomVariable();
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:101,代码来源:BuiltInMaterialsDefs.cpp

示例3: BuildCBWVP

	AEResult BuildCBWVP(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_World_View_Proj
		//
		//	cbuffer _AE_CB_World_View_Proj : register(b0)
		//	{
		//		matrix _AE_World		: packoffset(c0);
		//		matrix _AE_View			: packoffset(c4);
		//		matrix _AE_PROJection	: packoffset(c8);
		//	};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_World_View_Proj
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_WORLD_VIEW_PROJ_NAME);

		/**************************************
		*Add Var 1: _AE_World
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_WORLD_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 2: _AE_View
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_VIEW_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4);
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Add Var 3: _AE_PROJection
		***************************************/
		scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_PROJECTION_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:101,代码来源:BuiltInMaterialsDefs.cpp

示例4: BuildCBHalfPixel

	AEResult BuildCBHalfPixel(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_HalfPixel
		//
		//	cbuffer _AE_CB_HalfPixel : register(b0)
		//	{
		//		float2 _AE_HalfPixel	: packoffset(c0);
		//	};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_HalfPixel
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 0, AE_CB_HALF_PIXEL_NAME);

		/**************************************
		*Add Var 1: _AE_HalfPixel
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_HALF_PIXEL_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 2;
		scv->m_Rows = 1;
		scv->m_Elements = 0;
		scv->m_IsArray = false;
		scv->m_ElementSize = sizeof(glm::vec2);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::vec2);
		scv->m_ShaderVariableClass = ShaderVariableClass::Vector;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
			DeleteMem(cb);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Finish
		***************************************/
		*cb = tempCB;

		return AEResult::Ok;
	}
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:81,代码来源:BuiltInMaterialsDefs.cpp

示例5: BuildCBBones

	AEResult BuildCBBones(GraphicDevice* graphicDevice, ConstantBuffer** cb)
	{
		AEAssert(graphicDevice != nullptr);
		if (graphicDevice == nullptr)
		{
			return AEResult::GraphicDeviceNull;
		}

		AEAssert(cb != nullptr);
		if (cb == nullptr)
		{
			return AEResult::NullParameter;
		}

		AEResult ret = AEResult::Ok;
		uint32_t offset = 0;

		/////////////////////////////////////////////////////
		//Create Constant Buffer _AE_CB_Bones
		//
		//	cbuffer _AE_CB_Bones : register(b1)
		//	{
		//		matrix _AE_BoneTransforms[MAX_BONES] : packoffset(c0);
		//	};
		//

		/****************************************************************************
		*Constant Buffer: _AE_CB_Bones
		****************************************************************************/
		ConstantBuffer* tempCB = new ConstantBuffer(graphicDevice, 1, AE_CB_BONES_NAME);

		/**************************************
		*Add Var 1: _AE_World
		***************************************/
		ShaderCustomVariable* scv = new ShaderCustomVariable();
		scv->m_Name = AE_CB_BONE_TRANSFORMS_VAR_NAME;
		scv->m_StartOffset = offset;
		scv->m_Columns = 4;
		scv->m_Rows = 4;
		scv->m_Elements = AE_MAX_BONES;
		scv->m_IsArray = true;
		scv->m_ElementSize = sizeof(glm::mat4);
		scv->m_Offset = 0;
		scv->m_UserVariable = false;
		scv->m_Size = sizeof(glm::mat4) * AE_MAX_BONES;
		scv->m_ShaderVariableClass = ShaderVariableClass::Matrix;
		scv->m_ShaderVariableType = ShaderVariableType::Float;

		ret = tempCB->AddVariable(scv);

		offset = (scv->m_StartOffset + scv->m_Offset + scv->m_Size);

		if (ret != AEResult::Ok)
		{
			DeleteMem(tempCB);

			DeleteMem(scv);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Initialize
		***************************************/

		ret = tempCB->Initialize();

		if (ret != AEResult::Ok)
		{
			DeleteMem(cb);

			return AEResult::ConstantBufferInitFailed;
		}

		/**************************************
		*Constant Buffer Finish
		***************************************/
		*cb = tempCB;

		return AEResult::Ok;
	}
开发者ID:dtbinh,项目名称:Arenal-Engine,代码行数:81,代码来源:BuiltInMaterialsDefs.cpp


注:本文中的ConstantBuffer::AddVariable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。