本文整理汇总了C++中ShaderProgram::extractActive方法的典型用法代码示例。如果您正苦于以下问题:C++ ShaderProgram::extractActive方法的具体用法?C++ ShaderProgram::extractActive怎么用?C++ ShaderProgram::extractActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram::extractActive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canExtractEmptyUniformDeclarationWhenNoUniform
void canExtractEmptyUniformDeclarationWhenNoUniform()
{
ShaderProgram shaderProgram;
addShader(shaderProgram, Shader::FRAGMENT_SHADER, VALID_FRAGMENT_SHADER_SOURCE);
QVERIFY(shaderProgram.link());
UniformDeclarationVector uniformDeclarationVector;
shaderProgram.extractActive(uniformDeclarationVector);
QVERIFY(uniformDeclarationVector.empty());
}
示例2: canExtractArrayUniformDeclaration
void canExtractArrayUniformDeclaration()
{
ShaderProgram shaderProgram;
const char* source = \
"uniform vec4 position[];"\
"void main() {"\
" gl_Position = position[0] + position[1] + position[3];"\
"}";
addShader(shaderProgram, Shader::VERTEX_SHADER, source);
QVERIFY(shaderProgram.link());
UniformDeclarationVector uniformDeclarationVector;
shaderProgram.extractActive(uniformDeclarationVector);
QCOMPARE(uniformDeclarationVector.size(), static_cast<size_t>(1));
QCOMPARE(uniformDeclarationVector[0], UniformDeclaration(0, 4, GL_FLOAT_VEC4, "position[0]"));
}
示例3: canExtractMultipleUniformDeclaration
void canExtractMultipleUniformDeclaration()
{
ShaderProgram shaderProgram;
const char* source = \
"uniform vec4 position;"\
"uniform mat4 mvp;"
"void main() {"\
" gl_Position = mvp * position;"\
"}";
addShader(shaderProgram, Shader::VERTEX_SHADER, source);
QVERIFY(shaderProgram.link());
UniformDeclarationVector uniformDeclarationVector;
shaderProgram.extractActive(uniformDeclarationVector);
QCOMPARE(uniformDeclarationVector.size(), static_cast<size_t>(2));
for (unsigned int i = 0; i < uniformDeclarationVector.size(); ++i)
{
UniformDeclaration& uniformDeclaration = uniformDeclarationVector[i];
QCOMPARE(uniformDeclaration.getIndex(), static_cast<GLuint>(i));
if (uniformDeclaration.getName() == "position")
{
QCOMPARE(uniformDeclaration.getSize(), 1);
QCOMPARE(uniformDeclaration.getType(), static_cast<GLenum>(GL_FLOAT_VEC4));
}
else if (uniformDeclaration.getName() == "mvp")
{
QCOMPARE(uniformDeclaration.getSize(), 1);
QCOMPARE(uniformDeclaration.getType(), static_cast<GLenum>(GL_FLOAT_MAT4));
}
else
{
QFAIL("unexpected uniform");
}
}
}
示例4: canExtractStructArrayUniformDeclaration
void canExtractStructArrayUniformDeclaration()
{
ShaderProgram shaderProgram;
const char* source = \
"struct MyStruct {"\
" vec4 position1[2];"\
" vec3 position2;"\
"};"\
"uniform MyStruct ms[2];"\
"void main() {"\
" gl_Position = ms[1].position1[1] + vec4(ms[1].position2, 0);"\
"}";
addShader(shaderProgram, Shader::VERTEX_SHADER, source);
QVERIFY(shaderProgram.link());
UniformDeclarationVector uniformDeclarationVector;
shaderProgram.extractActive(uniformDeclarationVector);
QCOMPARE(uniformDeclarationVector.size(), static_cast<size_t>(2));
QCOMPARE(uniformDeclarationVector[0], UniformDeclaration(0, 2, GL_FLOAT_VEC4, "ms[1].position1[0]"));
QCOMPARE(uniformDeclarationVector[1], UniformDeclaration(1, 1, GL_FLOAT_VEC3, "ms[1].position2"));
}