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


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

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


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

示例1: OnGetShaderConstants

//----------------------------------------------------------------------------
void UpdateAccumulationScreenQuad::OnGetShaderConstants()
{
	ShaderProgram* program = mMaterial->GetProgram(0, 0);
    program->GetUniformLocation(&mWorldRayBundleDirectionLoc, 
        "worldRayBundleDirection");
    program->GetUniformLocation(&mVoxelGridCenterLoc, 
        "voxelGridCenter");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:9,代码来源:UpdateAccumulationScreenQuad.cpp

示例2: OnGetShaderConstants

//----------------------------------------------------------------------------
void VPLSampleRSM::OnGetShaderConstants()
{
    ComputePass* p = (ComputePass*)GetPass(0);
    ShaderProgram* program = p->GetShaderProgram();

    program->GetUniformLocation(&mRSMPositionLoc, "RSMPosition");
    program->GetUniformLocation(&mRSMNormalLoc, "RSMNormal");
    program->GetUniformLocation(&mRSMFluxLoc, "RSMFlux");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:10,代码来源:VPLSampleRSM.cpp

示例3: OnGetShaderConstants

//----------------------------------------------------------------------------
void VPLIndirectLightingScreenQuad::OnGetShaderConstants()
{
	ShaderProgram* program = mMaterial->GetProgram(0, 0);

    program->GetUniformLocation(&mVPLCountLoc, "VPLCount");
    program->GetUniformLocation(&mBounceSingularityLoc, "BounceSingularity");
    program->GetUniformLocation(&mGBufferPositionSamplerLoc, "GBufferPositionSampler");
    program->GetUniformLocation(&mGBufferNormalSamplerLoc, "GBufferNormalSampler");
    program->GetUniformLocation(&mGBufferAlbedoSamplerLoc, "GBufferAlbedoSampler");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:11,代码来源:VPLIndirectLightingScreenQuad.cpp

示例4: OnGetShaderConstants

//----------------------------------------------------------------------------
void SSDOTriMesh::OnGetShaderConstants()
{
	TriangleMesh::OnGetShaderConstants();

	ShaderProgram* program = mMaterial->GetProgram(0, 0);
    program->GetUniformLocation(&mMaterialColorLoc, "materialColor");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:8,代码来源:SSDOTriMesh.cpp

示例5: Bind

	void Texture::Bind(const std::string& name)
	{
		ShaderProgram* prog = ShaderProgram::CurrentProgram();

		UINT texUnit = GetTextureUnit();

		int loc = prog->GetUniformLocation(name);
		if (loc >= 0)
			glUniform1i(loc, texUnit);
	}
开发者ID:dritchie,项目名称:GraphicsEngine,代码行数:10,代码来源:Texture.cpp

示例6: OnGetShaderConstants

//----------------------------------------------------------------------------
void RSMDeferredLightingQuad::OnGetShaderConstants()
{
	ShaderProgram* program = mMaterial->GetProgram(0, 0);
    program->GetUniformLocation(&mLightPositionLoc, "lightPosition");
    program->GetUniformLocation(&mLightColorLoc, "lightColor");
    program->GetUniformLocation(&mPositionSamplerLoc, "positionSampler");
    program->GetUniformLocation(&mNormalSamplerLoc, "normalSampler");
    program->GetUniformLocation(&mReflectanceSamplerLoc, "reflectanceSampler");
    program->GetUniformLocation(&mIndirectLightingSamplerLoc, 
        "indirectLightingSampler");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:12,代码来源:RSMDeferredLightingQuad.cpp

示例7: BindData


//.........这里部分代码省略.........

				// 设置顶点的坐标属性
				if(vertex_fomat_ & FVF_XYZW)
				{
					GLuint location = shader->GetAttributeLocation(Attribute_Position4);
					glEnableVertexAttribArray(location);
					glVertexAttribPointer(
						location,				
						4,
						GL_FLOAT,
						GL_FALSE,
						vertex_size_,
						BUFFER_OFFSET(offset)
						);
					offset += sizeof(vec4);
				}
				else if (vertex_fomat_ & FVF_XYZ)
				{
					GLuint location = shader->GetAttributeLocation(Attribute_Position3);
					glEnableVertexAttribArray(location);
					glVertexAttribPointer(
						location,				
						3,
						GL_FLOAT,
						GL_FALSE,
						vertex_size_,
						BUFFER_OFFSET(offset)
						);
					offset += sizeof(vec3);
				}

				// 设置顶点的法线属性
				if(vertex_fomat_ & FVF_NORMAL)
				{
					GLuint location = shader->GetAttributeLocation(Attribute_Normal);
					glEnableVertexAttribArray(location);
					glVertexAttribPointer(
						location,
						3,
						GL_FLOAT,
						GL_FALSE,
						vertex_size_,
						BUFFER_OFFSET(offset)
						);
					offset += sizeof(vec3);
				}

				// 设置顶点的颜色属性
				if(vertex_fomat_ & FVF_RGBA)
				{
					GLuint location = shader->GetAttributeLocation(Attribute_Color4);
					glEnableVertexAttribArray(location);
					glVertexAttribPointer(
						location,
						4,
						GL_FLOAT,
						GL_FALSE,
						vertex_size_,
						BUFFER_OFFSET(offset)
						);
					offset += sizeof(Color4f);
				}

				if (vertex_fomat_ & FVF_TEX)
				{
					GLuint location = shader->GetAttributeLocation(Attribute_TexCoord2);
					glEnableVertexAttribArray(location);
					glVertexAttribPointer(
						location,
						2,
						GL_FLOAT,
						GL_FALSE,
						vertex_size_,
						BUFFER_OFFSET(offset)
						);
					offset += sizeof(vec2);
				}
				shader_ = shader;
			}

		}

		
		// 设置材质属性
		GLState::GetInstance()->SetMaterial(material_);

		// 绑定纹理
		if (texture_ != NULL)
		{
			// 绑定纹理
			GLuint tex_location = shader->GetUniformLocation(Uniform_Tex);
			glUniform1i(tex_location, 0);
			glBindTexture(GL_TEXTURE_2D, texture_->GetTexHandle());
		}

		// 更新光照,材质变换矩阵等Uniform变量
		GLState::GetInstance()->UpdateUniform();

 		return AT_OK;
	}
开发者ID:JunC74,项目名称:PYX,代码行数:101,代码来源:model.cpp

示例8: OnGetShaderConstants

//----------------------------------------------------------------------------
void RSMTriMesh::OnGetShaderConstants()
{
	TriangleMesh::OnGetShaderConstants();

    // Get pass 1 uniform locations.
	ShaderProgram* program = mMaterial->GetProgram(0, 0);
    program->GetUniformLocation(&mMaterialColorLoc, "materialColor");
    
    // Get pass 2 uniform locations.
    program = mMaterial->GetProgram(0, 1);
    program->GetUniformLocation(&mWorldLoc2, "World");
    program->GetUniformLocation(&mViewLoc2, "View");
    program->GetUniformLocation(&mProjLoc2, "Proj");
    program->GetUniformLocation(&mMaterialColorLoc2, "materialColor");
    program->GetUniformLocation(&mLightProjectorViewLoc, "lightProjectorView");
    program->GetUniformLocation(&mLightProjectorProjLoc, "lightProjectorProj");
    program->GetUniformLocation(&mSampleRadiusLoc, "sampleRadius");
    program->GetUniformLocation(&mSampleCountLoc, "sampleCount");
    program->GetUniformLocation(&mPositionSamplerLoc, "positionSampler");
    program->GetUniformLocation(&mNormalSamplerLoc, "normalSampler");
    program->GetUniformLocation(&mFluxSamplerLoc, "fluxSampler");
    program->GetUniformLocation(&mSamplingPatternSamplerLoc, "samplingPatternSampler");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:24,代码来源:RSMTriMesh.cpp

示例9: OnGetShaderConstants

//----------------------------------------------------------------------------
void SSSviaPSMTriMesh::OnGetShaderConstants()
{
	TriangleMesh::OnGetShaderConstants();

	// Get pass 1 uniform locations.
    ShaderProgram* program = mMaterial->GetProgram(0, 0);
    program->GetUniformLocation(&mLightProjectorNearFarLoc, "LightProjectorNearFar");

    // Get pass 2 uniform locations.
    program = mMaterial->GetProgram(0, 1);
    program->GetUniformLocation(&mWorldLoc2, "World");
    program->GetUniformLocation(&mViewLoc2, "View");
    program->GetUniformLocation(&mProjLoc2, "Proj");
    program->GetUniformLocation(&mLightProjectorViewLoc, "LightProjectorView");
    program->GetUniformLocation(&mShadowMapSamplerLoc, "shadowMapSampler");
    program->GetUniformLocation(&mLightPositionWorldLoc, "LightPositionWorld");
    program->GetUniformLocation(&mCameraPositionWorldLoc, "CameraPositionWorld");
    program->GetUniformLocation(&mLightColorLoc, "LightColor");
    program->GetUniformLocation(&mMaterialColorLoc, "MaterialColor");
    program->GetUniformLocation(&mLightProjectorNearFarLoc2, "LightProjectorNearFar");
    program->GetUniformLocation(&mIsSSSLoc, "IsSSS");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:23,代码来源:SSSviaPSMTriMesh.cpp

示例10: SORA_test_draw2

void SORA_test_draw2(int w, int h) {
  static bool init = false;
  static ShaderProgram shader;
  static TextureManager tex_mgr;
  
  if(init == false) {
    init = true;
    //create shader
    //2d shader
    std::string app_vert_path = sora::Filesystem::GetAppPath("shader/simple.vs");
    std::string app_frag_path = sora::Filesystem::GetAppPath("shader/simple.fs");
    sora::MemoryFile vert_file(app_vert_path);
    sora::MemoryFile frag_file(app_frag_path);
    vert_file.Open();
    frag_file.Open();
    const char *vert_src = (const char*)(vert_file.start);
    const char *frag_src = (const char*)(frag_file.start);
    bool prog_result = shader.Init(vert_src, frag_src);
    if(prog_result == false) {
      LOGE("Could not create program.");
    }

    {
      std::string tex_path = sora::Filesystem::GetAppPath("texture/sora.png");
      sora::MemoryFile tex_file(tex_path);
      tex_file.Open();
      Texture tex("sora");
      tex.SetData(sora::Texture::kFilePNG, tex_file.start, tex_file.end);
      tex_mgr.Add(tex);
    }

  }
  static float a = 0;
  a += 0.1f;

  glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
  glClear(GL_COLOR_BUFFER_BIT);
  glViewport(0, 0, w, h);

  SR_CHECK_ERROR("Render 2d start");
  //draw 2d something
  glm::mat4 world_mat(1.0f);

  int pos_loc = shader.GetAttribLocation("a_position");
  int tex_loc = shader.GetAttribLocation("a_texcoord");
  glEnableVertexAttribArray(pos_loc);
  glEnableVertexAttribArray(tex_loc);
  
  int mvp_loc = shader.GetUniformLocation("u_worldViewProjection");

  float vertex[] = {
    -0.5, -0.5, 0,
    0.5, -0.5, 0,
    0, 0.5, 0,
  };
  float texcoord[] = {
    0, 0,
    1, 0,
    0.5, 1,
  };


  glUseProgram(shader.prog);

  Texture *tex = tex_mgr.Get_ptr(string("sora"));
  glBindTexture(GL_TEXTURE_2D, tex->handle());

  glUniformMatrix4fv(mvp_loc, 1, GL_FALSE, glm::value_ptr(world_mat));
  glVertexAttribPointer(pos_loc, 3, GL_FLOAT, GL_FALSE, 0, vertex);
  glVertexAttribPointer(tex_loc, 2, GL_FLOAT, GL_FALSE, 0, texcoord);
  glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
  SR_CHECK_ERROR("glDrawArrays");
}
开发者ID:,项目名称:,代码行数:73,代码来源:

示例11: OnGetShaderConstants

//----------------------------------------------------------------------------
void ISMTempScreenQuad::OnGetShaderConstants()
{
	ShaderProgram* program = mMaterial->GetProgram(0, 0);
    program->GetUniformLocation(&mTempSamplerLoc, "tempSampler");
}
开发者ID:jazzboysc,项目名称:RTGI,代码行数:6,代码来源:ISMTempScreenQuad.cpp


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