本文整理汇总了C++中Mesh::BindBuffers方法的典型用法代码示例。如果您正苦于以下问题:C++ Mesh::BindBuffers方法的具体用法?C++ Mesh::BindBuffers怎么用?C++ Mesh::BindBuffers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh::BindBuffers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoRender
void MeshRenderer::DoRender( BufferIndex bufferIndex, const Matrix& modelViewMatrix, const Matrix& modelMatrix, const Matrix& viewMatrix, const Matrix& projectionMatrix, const Vector4& color )
{
MeshInfo& meshInfo = mMeshInfo[bufferIndex];
Mesh* mesh = meshInfo.mesh;
RenderMaterial& material = *(meshInfo.material);
BoneTransforms& boneTransforms = meshInfo.boneTransforms;
if( ! meshInfo.boneTransforms.transforms.empty() )
{
ApplyViewToBoneTransforms( meshInfo.boneTransforms, viewMatrix );
}
const int stride = sizeof(Dali::MeshData::Vertex);
Dali::MeshData::Vertex *v = 0;
mesh->UploadVertexData( *mContext, bufferIndex );
mesh->BindBuffers( *mContext );
GeometryType geometryType = GEOMETRY_TYPE_TEXTURED_MESH;
if( ! material.HasTexture() )
{
geometryType = GEOMETRY_TYPE_MESH;
}
GLsizei numBoneMatrices = (GLsizei)mesh->GetMeshData(Mesh::RENDER_THREAD).GetBoneCount();
// Select program type
ShaderSubTypes shaderType = SHADER_DEFAULT;
if( mShader->AreSubtypesRequired( geometryType ) )
{
if( numBoneMatrices )
{
if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasColor() )
{
shaderType = SHADER_RIGGED_AND_VERTEX_COLOR;
}
else if( mAffectedByLighting )
{
shaderType = SHADER_RIGGED_AND_LIT;
}
else
{
shaderType = SHADER_RIGGED_AND_EVENLY_LIT;
}
}
else
{
if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasColor() )
{
shaderType = SHADER_VERTEX_COLOR;
}
else if( ! mAffectedByLighting )
{
shaderType = SHADER_EVENLY_LIT;
} // else default
}
}
if( geometryType != mGeometryType || shaderType != mShaderType )
{
mGeometryType = geometryType;
mShaderType = shaderType;
ResetCustomUniforms();
}
Program& program = mShader->Apply( *mContext, bufferIndex, geometryType, modelMatrix, viewMatrix, modelViewMatrix, projectionMatrix, color, mShaderType );
GLint location = Program::UNIFORM_UNKNOWN;
GLint positionLoc = program.GetAttribLocation(Program::ATTRIB_POSITION);
GLint texCoordLoc = Program::ATTRIB_UNKNOWN;
GLint boneWeightsLoc = Program::ATTRIB_UNKNOWN;
GLint boneIndicesLoc = Program::ATTRIB_UNKNOWN;
GLint normalLoc = Program::ATTRIB_UNKNOWN;
GLint colorLoc = Program::ATTRIB_UNKNOWN;
mContext->VertexAttribPointer( positionLoc, 3, GL_FLOAT, GL_FALSE, stride, &v->x );
mContext->EnableVertexAttributeArray( positionLoc );
if( numBoneMatrices > 0 )
{
location = mCustomUniform[ shaderType ][ 0 ].GetUniformLocation( program, "uBoneCount" );
if( Program::UNIFORM_UNKNOWN != location )
{
program.SetUniform1i(location, numBoneMatrices);
}
location = mCustomUniform[ shaderType ][ 1 ].GetUniformLocation( program, "uBoneMatrices" );
if( Program::UNIFORM_UNKNOWN != location )
{
program.SetUniformMatrix4fv(location, numBoneMatrices, boneTransforms.viewTransforms[0].AsFloat());
}
if( mesh->GetMeshData(Mesh::RENDER_THREAD).HasNormals() )
{
location = mCustomUniform[ shaderType ][ 2 ].GetUniformLocation( program, "uBoneMatricesIT" );
if( Program::UNIFORM_UNKNOWN != location )
{
program.SetUniformMatrix3fv( location, numBoneMatrices, boneTransforms.inverseTransforms[0].AsFloat() );
}
}
//.........这里部分代码省略.........