nodevalue: begin abstracting qvariant

This commit is contained in:
itsmattkc
2022-05-09 13:07:34 -07:00
parent 839f63d78f
commit 58c4600d04
36 changed files with 235 additions and 229 deletions
+11 -11
View File
@@ -449,48 +449,48 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video
case NodeValue::kInt:
// kInt technically specifies a LongLong, but OpenGL doesn't support those. This may lead to
// over/underflows if the number is large enough, but the likelihood of that is quite low.
functions_->glUniform1i(variable_location, value.data().toInt());
functions_->glUniform1i(variable_location, value.toInt());
break;
case NodeValue::kFloat:
// kFloat technically specifies a double but as above, OpenGL doesn't support those.
functions_->glUniform1f(variable_location, value.data().toFloat());
functions_->glUniform1f(variable_location, value.toDouble());
break;
case NodeValue::kVec2:
{
QVector2D v = value.data().value<QVector2D>();
QVector2D v = value.toVec2();
functions_->glUniform2fv(variable_location, 1, reinterpret_cast<const GLfloat*>(&v));
break;
}
case NodeValue::kVec3:
{
QVector3D v = value.data().value<QVector3D>();
QVector3D v = value.toVec3();
functions_->glUniform3fv(variable_location, 1, reinterpret_cast<const GLfloat*>(&v));
break;
}
case NodeValue::kVec4:
{
QVector4D v = value.data().value<QVector4D>();
QVector4D v = value.toVec4();
functions_->glUniform4fv(variable_location, 1, reinterpret_cast<const GLfloat*>(&v));
break;
}
case NodeValue::kMatrix:
functions_->glUniformMatrix4fv(variable_location, 1, false, value.data().value<QMatrix4x4>().constData());
functions_->glUniformMatrix4fv(variable_location, 1, false, value.toMatrix().constData());
break;
case NodeValue::kCombo:
functions_->glUniform1i(variable_location, value.data().value<int>());
functions_->glUniform1i(variable_location, value.toInt());
break;
case NodeValue::kColor:
{
Color color = value.data().value<Color>();
Color color = value.toColor();
functions_->glUniform4f(variable_location, color.red(), color.green(), color.blue(), color.alpha());
break;
}
case NodeValue::kBoolean:
functions_->glUniform1i(variable_location, value.data().toBool());
functions_->glUniform1i(variable_location, value.toBool());
break;
case NodeValue::kTexture:
{
TexturePtr texture = value.data().value<TexturePtr>();
TexturePtr texture = value.toTexture();
// Set value to bound texture
functions_->glUniform1i(variable_location, textures_to_bind.size());
@@ -552,7 +552,7 @@ void OpenGLRenderer::Blit(QVariant s, ShaderJob job, Texture *destination, Video
// Ensure matrix is set, at least to identity
GLint mvpmat_location = functions_->glGetUniformLocation(shader, "ove_mvpmat");
if (mvpmat_location > -1) {
functions_->glUniformMatrix4fv(mvpmat_location, 1, false, job.GetValue(QStringLiteral("ove_mvpmat")).data().value<QMatrix4x4>().constData());
functions_->glUniformMatrix4fv(mvpmat_location, 1, false, job.GetValue(QStringLiteral("ove_mvpmat")).toMatrix().constData());
}
// Set the viewport to the "physical" resolution of the destination