|
|
@ -5,6 +5,9 @@ |
|
|
|
#include <omp.h> |
|
|
|
#include <omp.h> |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
#include "FPS.h" |
|
|
|
#include "FPS.h" |
|
|
|
|
|
|
|
#include <QOpenGLContext> |
|
|
|
|
|
|
|
#include <QOpenGLShaderProgram> |
|
|
|
|
|
|
|
#include <QOffscreenSurface> |
|
|
|
|
|
|
|
|
|
|
|
Simulation::Simulation() { |
|
|
|
Simulation::Simulation() { |
|
|
|
ups = new FPS; |
|
|
|
ups = new FPS; |
|
|
@ -16,6 +19,36 @@ Simulation::Simulation() { |
|
|
|
timer->start(); |
|
|
|
timer->start(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Simulation::initialize() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// OpenGL Offscreen functions
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto context = new QOpenGLContext(this); |
|
|
|
|
|
|
|
context->setFormat(QSurfaceFormat::defaultFormat()); |
|
|
|
|
|
|
|
context->create(); |
|
|
|
|
|
|
|
auto surface = new QOffscreenSurface(nullptr, this); |
|
|
|
|
|
|
|
surface->setFormat(context->format()); |
|
|
|
|
|
|
|
surface->create(); |
|
|
|
|
|
|
|
context->makeCurrent(surface); |
|
|
|
|
|
|
|
initializeOpenGLFunctions(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int maxWorkGroupCount[3]; |
|
|
|
|
|
|
|
int maxWorkGroupSize[3]; |
|
|
|
|
|
|
|
int maxWorkGroupInvocations; |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++){ |
|
|
|
|
|
|
|
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, i, maxWorkGroupCount + i); |
|
|
|
|
|
|
|
glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, i, maxWorkGroupSize + i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
glGetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &maxWorkGroupInvocations); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("Max work group count: (%d, %d, %d)\n", maxWorkGroupCount[0], maxWorkGroupCount[1], maxWorkGroupCount[2]); |
|
|
|
|
|
|
|
printf("Max work group size: (%d, %d, %d)\n", maxWorkGroupSize[0], maxWorkGroupSize[1], maxWorkGroupSize[2]); |
|
|
|
|
|
|
|
printf("Max work group invocations (x * y * z): %d\n", maxWorkGroupInvocations); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Simulation::update() { |
|
|
|
void Simulation::update() { |
|
|
|
if (!isPlaying) |
|
|
|
if (!isPlaying) |
|
|
|
return; |
|
|
|
return; |
|
|
|