Commit 2aaf8beb by Philipp Adolf

Load compute shader

parent 4eaf0e47
......@@ -107,6 +107,7 @@ void MainWidget::initializeGL(){
// Shader
subdevisionShader = initShaderProgram();
subdivision->init();
//loadNewMesh( "../Models/demon_head.3ds");
loadNewMesh( "../Models/box.obj");
}
......
......@@ -5,5 +5,6 @@
<file>subdivide.tcs</file>
<file>subdivide.tes</file>
<file>subdivide.vert</file>
<file>subdivision.compute</file>
</qresource>
</RCC>
#version 430
layout (local_size_x = 1) in;
void main() {
}
......@@ -7,6 +7,34 @@ Subdivision::Subdivision(QOpenGLFunctions_4_3_Core *f)
Subdivision::~Subdivision()
{
delete shader;
}
void Subdivision::init() {
shader = initComputeShaderProgram();
}
QOpenGLShaderProgram *Subdivision::initComputeShaderProgram(){
QString source = QLatin1String(":/subdivision.compute");
qDebug()<<"Compiling compute shader ...";
QOpenGLShader *computeShader = new QOpenGLShader(QOpenGLShader::Compute);
if(!computeShader->compileSourceFile(source)){
qCritical()<<"Compute Shader"<<source<<"failed"<<computeShader->log();
exit(5);
}
qDebug()<<"Adding compute shader ...";
QOpenGLShaderProgram *shader = new QOpenGLShaderProgram();
shader->addShader(computeShader);
qDebug()<<"Linking compute shader ...";
if(!shader->link()){
qCritical()<<"Linking compute shader failed:"<<shader->log();
exit(5);
}
qDebug()<<"Linking compute shader done";
return shader;
}
Mesh *Subdivision::subdivide(Mesh *mesh) {
......
......@@ -12,11 +12,14 @@ public:
Subdivision(QOpenGLFunctions_4_3_Core *f);
~Subdivision();
void init();
Mesh *subdivide(Mesh *mesh);
private:
QOpenGLFunctions_4_3_Core *f;
QOpenGLShaderProgram *shader;
QOpenGLShaderProgram *initComputeShaderProgram();
void precomputeTables(Mesh *mesh);
void runShader(Mesh *mesh);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment