本文整理汇总了C++中Program::GetUniformLocation方法的典型用法代码示例。如果您正苦于以下问题:C++ Program::GetUniformLocation方法的具体用法?C++ Program::GetUniformLocation怎么用?C++ Program::GetUniformLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Program
的用法示例。
在下文中一共展示了Program::GetUniformLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BindTexture
void RenderMaterial::BindTexture( Program& program, ResourceId id, Texture* texture, unsigned int textureUnit, Program::UniformType samplerIndex ) const
{
DALI_ASSERT_DEBUG( NULL != mTextureCache );
if( texture != NULL )
{
mTextureCache->BindTexture( texture, id, GL_TEXTURE_2D, GL_TEXTURE0 + textureUnit );
// Set sampler uniforms for textures
GLint samplerLoc = program.GetUniformLocation( samplerIndex );
if( -1 != samplerLoc )
{
program.SetUniform1i( samplerLoc, textureUnit );
}
GLint location = program.GetUniformLocation(Program::UNIFORM_CUSTOM_TEXTURE_COORDS);
if( Program::UNIFORM_UNKNOWN != location )
{
UvRect uvs;
texture->GetTextureCoordinates(uvs);
// Account for UV mapping on non power of 2 textures
program.SetUniform4f(location, uvs.u0, uvs.v0, uvs.u2-uvs.u0, uvs.v2-uvs.v0);
}
}
}
示例2: GetUniformLocation
const int CustomUniform::GetUniformLocation( Program& program, const char* name )
{
if( 0 == mCacheIndex )
{
Initialize( program, name );
}
return program.GetUniformLocation( mCacheIndex );
}
示例3: Render
void Renderer::Render( Context& context,
SceneGraph::TextureCache& textureCache,
BufferIndex bufferIndex,
const SceneGraph::NodeDataProvider& node,
SceneGraph::Shader& defaultShader,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
const Matrix& projectionMatrix,
bool cull,
bool blend )
{
NewRenderer* renderer = GetNewRenderer(); // avoid a dynamic cast per item per frame
if( renderer )
{
// Get the shader from the material:
mShader = &renderer->mRenderDataProvider->GetShader();
}
// if mShader is NULL it means we're set to default
if( !mShader )
{
mShader = &defaultShader;
}
if( !CheckResources() )
{
// CheckResources() is overriden in derived classes.
// Prevents modify the GL state if resources are not ready and nothing is to be rendered.
return;
}
// Get the program to use:
Program* program = mShader->GetProgram();
if( !program )
{
// if program is NULL it means this is a custom shader with non matching geometry type so we need to use default shaders program
program = defaultShader.GetProgram();
DALI_ASSERT_DEBUG( program && "Default shader should always have a program available." );
if( !program )
{
DALI_LOG_ERROR( "Failed to get program for shader at address %p.", (void*) &*mShader );
return;
}
}
// Take the program into use so we can send uniforms to it
program->Use();
DoSetCullFaceMode( context, bufferIndex );
DoSetBlending( context, bufferIndex, blend );
// Ignore missing uniforms - custom shaders and flat color shaders don't have SAMPLER
// set projection and view matrix if program has not yet received them yet this frame
const Matrix& modelMatrix = node.GetModelMatrix( bufferIndex );
SetMatrices( *program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix );
// set color uniform
GLint loc = program->GetUniformLocation( Program::UNIFORM_COLOR );
if( Program::UNIFORM_UNKNOWN != loc )
{
const Vector4& color = node.GetRenderColor( bufferIndex );
program->SetUniform4f( loc, color.r, color.g, color.b, color.a );
}
//@todo MESH_REWORK Remove after removing ImageRenderer
DoSetUniforms(context, bufferIndex, mShader, program );
// subclass rendering and actual draw call
DoRender( context, textureCache, node, bufferIndex, *program, modelViewMatrix, viewMatrix );
}