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


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

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


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

示例1: brushSize

void gfx::GraphicsEngine::RenderToTexture(RenderQueue* drawQueue){
	TextureHandle target = drawQueue->GetTargetTexture();
	m_FrameBuffer.SetTexture(target);
	m_FrameBuffer.Apply();

	ShaderProgram* spriteProg = g_ShaderBank.GetProgramFromHandle(m_SpriteShader);
	spriteProg->Apply();
	glBindVertexArray(0);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	static bool additive = false; 
	ImGui::Checkbox("Additive", &additive);
	if (additive){
		glBlendFunc(GL_SRC_ALPHA, GL_ONE);
	}
	else {
		glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	}
	//static glm::vec4 color = glm::vec4(1);
	//ImGui::ColorEdit4("BrushColor", &color[0], true);

	for (auto& brush : drawQueue->GetBrushQueue()){
		Texture* brushTex = g_MaterialBank.GetTexture(brush.Texture);
		glm::vec2 brushSize(brush.Size / (m_Width * 0.5f), brush.Size / m_Height);

		spriteProg->SetUniformVec4("g_Pos", glm::vec4(glm::vec2(brush.Position.x - brushSize.x * 0.5f, 1.0f - brush.Position.y + brushSize.y * 0.5f), 0, 0));
		spriteProg->SetUniformVec4("g_Size", glm::vec4(brushSize.x, brushSize.y, 1, 1));
		spriteProg->SetUniformVec4("g_Color", ColorPicker::m_color);
		brushTex->Apply(spriteProg->FetchUniform("g_Texture"), 0);
		spriteProg->SetUniformBool("g_GreyScale", false);
		glDrawArrays(GL_POINTS, 0, 1);
	}
	glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
开发者ID:exnotime,项目名称:DV1508AssetTool,代码行数:34,代码来源:GraphicsEngine.cpp

示例2:

void gfx::GraphicsEngine::RenderSprites(RenderQueue* drawQueue){
	glViewport(0, 0, m_Width, m_Height);
	//Render Sprites
	ShaderProgram* spriteProg = g_ShaderBank.GetProgramFromHandle(m_SpriteShader);
	spriteProg->Apply();
	glBindVertexArray(0);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	for (int layer = 0; layer < 3; layer++){
		for (auto& spr : drawQueue->GetSpriteQueue()[layer]){
			spriteProg->SetUniformVec4("g_Pos", spr.GetPosFlt());
			spriteProg->SetUniformVec4("g_Size", spr.GetSizeFlt());
			spriteProg->SetUniformVec4("g_Color", spr.GetColor());
			g_MaterialBank.GetTexture(spr.GetTexture())->Apply(spriteProg->FetchUniform("g_Texture"), 0);
			if (g_MaterialBank.GetTexture(spr.GetTexture())->GetChannels() == 1){
				spriteProg->SetUniformBool("g_GreyScale", true);
			}
			else{
				spriteProg->SetUniformBool("g_GreyScale", false);
			}
			glDrawArrays(GL_POINTS, 0, 1);
		}
	}
}
开发者ID:exnotime,项目名称:DV1508AssetTool,代码行数:25,代码来源:GraphicsEngine.cpp

示例3:

void gfx::LineRenderProgram::Draw()
{
	glDisable( GL_DEPTH_TEST );
	glLineWidth(4.0f);
	glEnable(GL_BLEND);
	ShaderProgram* prog = g_ShaderBank.GetProgramFromHandle(m_ProgramHandle);
	prog->Apply();
	glm::mat4 vp = m_RenderJobManager->GetProj() * m_RenderJobManager->GetView();
	prog->SetUniformMat4("vp", vp);
	
	rVector<Line>& lines = m_RenderJobManager->GetLines();
	for(int i = 0; i < lines.size(); i++)
	{
		prog->SetUniformVec4("Color", lines[i].Color);
		prog->SetUniformVec3("pos1", lines[i].Origin);
		prog->SetUniformVec3("pos2", lines[i].Destination);
		prog->SetUniformFloat("animation", lines[i].AnimationProgres);
		if(lines[i].Dashed)
		{
			prog->SetUniformTextureHandle("Tex", m_DashedTexture, 0);
		}
		else
		{
			prog->SetUniformTextureHandle("Tex", m_Texture, 0);
		}
		glBindVertexArray( 0 );
		glDrawArrays(GL_POINTS, 0, 1);
	}
	glUseProgram( 0 );
	glEnable( GL_DEPTH_TEST );
	glLineWidth(1.0f);
	glDisable(GL_BLEND);
}
开发者ID:Robograde,项目名称:Robograde,代码行数:33,代码来源:LineRenderProgram.cpp

示例4: 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

示例5: Render

void TerrainDeformationProgram::Render(RenderQueue* rq){
	ShaderProgram* prog = g_ShaderBank.GetProgramFromHandle(m_DrawProgram);
	prog->Apply();
	
	glBindVertexArray(0);
	glEnable(GL_BLEND);
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
	//glBlendFunc(GL_SRC_ALPHA, GL_ONE); //additive
	for (auto& td : rq->GetDeformations()){
		Terrain* terrain = g_TerrainManager.GetTerrainFromHandle(td.Terrain);
		glm::vec2 textureSize = terrain->GetHeightHighResSize();

		m_FrameBuffer->SetTexture(terrain->GetHeightMap(), textureSize.x, textureSize.y);
		m_FrameBuffer->Apply();
		glViewport(0, 0, textureSize.x, textureSize.y);
		//prog->SetUniformTextureHandle("g_Texture", m_BrushTexture, 0);
		m_BrushTex->Apply(prog->FetchUniform("g_Texture"), 0);
		prog->SetUniformVec4("g_Pos", glm::vec4(td.Position.x , 1.0f - td.Position.y, 0, 0));
		prog->SetUniformVec4("g_Size", glm::vec4(td.Size, 1, 1));
		glm::vec3 dir = td.Up ? glm::vec3(1) : glm::vec3(0);
		prog->SetUniformVec4("g_Color", glm::vec4(dir, td.Strength));
		prog->SetUniformBool("g_GreyScale", false);
		glDrawArrays(GL_POINTS, 0, 1);
		//filter area
		glm::vec4 pixelArea = glm::vec4((td.Position * textureSize) - glm::vec2(-2), (td.Size * textureSize) + glm::vec2(4));
		const int WORK_GROUP_SIZE = 32;
		GLuint WorkGroupSizeX = GLuint((pixelArea.z + WORK_GROUP_SIZE - 1) / float(WORK_GROUP_SIZE));
		GLuint WorkGroupSizeY = GLuint((pixelArea.w + WORK_GROUP_SIZE - 1) / float(WORK_GROUP_SIZE));

		ShaderProgram* prog = g_ShaderBank.GetProgramFromHandle(m_FilterProgram);
		prog->Apply();
		prog->SetUniformVec4("g_PixelArea", pixelArea);
		glBindImageTexture(0, terrain->GetHeightMap(), 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_R32F);
		glDispatchCompute(WorkGroupSizeX, WorkGroupSizeY, 1);
	}
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDisable(GL_BLEND);
}
开发者ID:toimelin,项目名称:gameenginecourse2015,代码行数:39,代码来源:TerrainDeformationProgram.cpp


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