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


C++ ShaderProgram::SetUniformVec2方法代码示例

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


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

示例1: GLuint

void gfx::BloomProgram::Render(){
	//Do brightpass
	ShaderProgram* prog = g_ShaderBank.GetProgramFromHandle(m_BrightPassShader);
	prog->Apply();
	const int WORK_GROUP_SIZE = 32;
	GLuint WorkGroupSizeX = GLuint((m_Width + WORK_GROUP_SIZE - 1) / float(WORK_GROUP_SIZE));
	GLuint WorkGroupSizeY = GLuint((m_Height + WORK_GROUP_SIZE - 1) / float(WORK_GROUP_SIZE));
	prog->SetUniformTextureHandle("g_Image", m_TargetTex, 1);
	prog->SetUniformVec2("g_ScreenSize", glm::vec2(m_Width, m_Height));
	prog->SetUniformFloat("g_Threshold", 0.4f);
	prog->SetUniformFloat("g_Smoothness", 0.8f);
	glBindImageTexture(0, m_BloomTexture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA8);
	glDispatchCompute(WorkGroupSizeX, WorkGroupSizeY, 1);
	//blur result
	m_BlurProgram->Render();
	//add to final target
	prog = g_ShaderBank.GetProgramFromHandle(m_BloomShader);
	prog->Apply();
	prog->SetUniformTextureHandle("g_BluredBloomTex", m_BlurProgram->GetBluredTexture(), 1);
	prog->SetUniformTextureHandle("g_ColorBuffer", m_TargetTex, 2);
	prog->SetUniformVec2("g_ScreenSize", glm::vec2(m_Width, m_Height));
	glBindImageTexture(0, m_BloomTexture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA8);
	glDispatchCompute(WorkGroupSizeX, WorkGroupSizeY, 1);

}
开发者ID:toimelin,项目名称:gameenginecourse2015,代码行数:25,代码来源:BloomProgram.cpp

示例2: sizeof

void gfx::GraphicsEngine::RenderLines(RenderQueue* drawQueue){
	//Fill vertex buffer
	int bufferSize = 0;
	for (auto& it : drawQueue->GetLineQueue()){
		bufferSize += it.Lines.size();
	}
	int i = 0;
	for (auto& it : drawQueue->GetLineQueue()){
		memcpy(m_LineBuffer + i * sizeof(glm::vec2), it.Lines.data(), it.Lines.size() * sizeof(glm::vec2));
		i += it.Lines.size();
	}
	glBindBuffer(GL_ARRAY_BUFFER, m_LineVBO);
	glBufferSubData(GL_ARRAY_BUFFER, 0, bufferSize * sizeof(glm::vec2), m_LineBuffer);
	glBindVertexArray(m_LineVAO);
	//set shader
	ShaderProgram* prog = g_ShaderBank.GetProgramFromHandle(m_LineProgram);
	prog->Apply();
	prog->SetUniformVec2("g_ScreenSize", glm::vec2(m_Width, m_Height));
	prog->SetUniformVec2("g_ScreenPos", glm::vec2(0, 0));
	//issue draw calls
	i = 0;
	glViewport(0, 0,m_Width,m_Height);
	for (auto& it : drawQueue->GetLineQueue()){
		prog->SetUniformVec4("g_Color", it.Color);
		glDrawArrays(GL_LINES, i, it.Lines.size());
		i += it.Lines.size();
	}
	
}
开发者ID:exnotime,项目名称:DV1508AssetTool,代码行数:29,代码来源:GraphicsEngine.cpp

示例3: gpMultiDraw

void gfx::BasicRenderProgram::Draw(DrawData* data)
{
	//draw
	int flag = data->ShaderFlags;
	g_ModelBank.ApplyBuffers( POS_NORMAL_TEX_TANGENT );
	ShaderProgram* prog = g_ShaderBank.GetProgramFromHandle(m_ProgramHandle);
	
	prog->Apply();
	m_RenderJobManager->BindBuffers(prog);
	GLint loc = -1;
	if(flag & FRAGMENT_DIFFUSEMAP)
	{
		Texture* diffuse = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Diffuse);
		loc = prog->FetchUniform("g_DiffuseTex");
		diffuse->Apply(loc, 0);
		prog->SetUniformBool("useDiffuse",true);
	}
	else
	{
		prog->SetUniformBool("useDiffuse",false);
	}
	if(flag & FRAGMENT_NORMALMAP)
	{
		Texture* normal = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Normal);
		loc = prog->FetchUniform("g_NormalTex");
		normal->Apply(loc, 1);
		prog->SetUniformBool("useNormal",true);
	}
	else
	{
		prog->SetUniformBool("useNormal",false);
	}
	if(flag & FRAGMENT_ROUGHNESSMAP)
	{
		Texture* roughness = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Roughness);
		loc = prog->FetchUniform("g_RoughnessTex");
		roughness->Apply(loc, 2);
		prog->SetUniformBool("useRoughness",true);
	}
	else
	{
		prog->SetUniformBool("useRoughness",false);
	}
	if(flag & FRAGMENT_METALMAP)
	{
		Texture* metal = g_MaterialBank.GetTextureAtlasTex(Texture_Atlas_Type::Metal);
		loc = prog->FetchUniform("g_MetalTex");
		metal->Apply(loc, 3);
		prog->SetUniformBool("useMetal",true);
	}
	else
	{
		prog->SetUniformBool("useMetal",false);
	}
	BasicData* frameData = (BasicData*)(data->ExtraData);
	prog->SetUniformInt("numPLights", frameData->PointLightCount);
	prog->SetUniformInt("numDLights", frameData->DirLightCount);
	prog->SetUniformUInt("BatchCounts",frameData->BatchOffset);
	prog->SetUniformVec2("g_WorldSize", frameData->WorldSize);
	prog->SetUniformMat4("ShadowMat",frameData->ShadowMat);
	loc = prog->FetchUniform("g_LightCubeTex");
	frameData->SkyTex->Apply(loc, 4);
	loc = prog->FetchUniform("g_IrradianceCube");
	frameData->IrradianceTex->Apply(loc, 5);

	//fog tex
	loc = prog->FetchUniform("g_FogOfWarTex");
	glUniform1i(loc,6);
	glActiveTexture(GL_TEXTURE6);
	glBindTexture(GL_TEXTURE_2D, frameData->FogTex);

	//fog tex
	loc = prog->FetchUniform("g_ShadowMap");
	glUniform1i(loc,7);
	glActiveTexture(GL_TEXTURE7);
	glBindTexture(GL_TEXTURE_2D, frameData->ShadowTex);

	
	if (m_HasDrawID)
	{
		GPU_PROFILE( AutoGPUProfiler gpMultiDraw( "BasicRenderProgramMultiDrawElementsIndirect" ); );
		glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, (GLvoid*)(sizeof(IndirectDrawCall) * (frameData->BatchOffset)), frameData->BatchCount, 0);
		GPU_PROFILE( gpMultiDraw.Stop(); );
开发者ID:Robograde,项目名称:Robograde,代码行数:83,代码来源:BasicRenderProgram.cpp


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