80 lines
1.2 KiB
C
80 lines
1.2 KiB
C
|
|
|
||
|
|
#include "renderPass.h"
|
||
|
|
|
||
|
|
#include "../event.h"
|
||
|
|
|
||
|
|
#include "../../vector2.h"
|
||
|
|
|
||
|
|
#include "../shader.h"
|
||
|
|
|
||
|
|
#include "../program.h"
|
||
|
|
|
||
|
|
#include "../../int.h"
|
||
|
|
|
||
|
|
#include "../sampler2D.h"
|
||
|
|
|
||
|
|
#include "stdbool.h"
|
||
|
|
|
||
|
|
#include "../block.h"
|
||
|
|
|
||
|
|
|
||
|
|
class compute2 extends renderPass{
|
||
|
|
|
||
|
|
struct program * program;
|
||
|
|
|
||
|
|
int active = true;
|
||
|
|
|
||
|
|
|
||
|
|
prepare() {
|
||
|
|
|
||
|
|
printf("\n\n\n Prepare renderPass Compute 2\n\n\n\n\n");
|
||
|
|
|
||
|
|
shader * computeShader = new shader( GL_COMPUTE_SHADER );
|
||
|
|
|
||
|
|
computeShader->loadFromFile( "assets/shaders/addition2.comp" );
|
||
|
|
|
||
|
|
|
||
|
|
this->program = new program();
|
||
|
|
|
||
|
|
this->program->addShader( computeShader );
|
||
|
|
|
||
|
|
this->program->create();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
render() {
|
||
|
|
|
||
|
|
if( this->active ) {
|
||
|
|
|
||
|
|
this->program->use();
|
||
|
|
|
||
|
|
this->program->bindBlock( "outputBlock2" );
|
||
|
|
|
||
|
|
|
||
|
|
glDispatchCompute( 1, 1, 1 );
|
||
|
|
|
||
|
|
|
||
|
|
block * outputBlock = this->program->getBlock( "outputBlock2" );
|
||
|
|
|
||
|
|
vector<vector2> * output = outputBlock->getMemberArray( "array_d[0]" );
|
||
|
|
|
||
|
|
int count = output->length();
|
||
|
|
|
||
|
|
for (int i = 0; i < count; ++i)
|
||
|
|
{
|
||
|
|
|
||
|
|
vector2 currentVector = output->get( i );
|
||
|
|
|
||
|
|
printf("%i = %f %f \n", i, i, currentVector.x, currentVector.y );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
printf("length: %i\n\n", count);
|
||
|
|
|
||
|
|
this->active = false;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|