Fixed some cl stuff in ghoul used in renderablevolumeexpert

This commit is contained in:
Hans-Christian Helltegen
2014-04-22 14:24:34 -04:00
parent 199bb52d5d
commit ea8f7748ac
2 changed files with 20 additions and 6 deletions

View File

@@ -206,7 +206,7 @@ bool RenderableVolumeExpert::initialize() {
for (int i = 0; i < _volumePaths.size(); ++i) {
ghoul::RawVolumeReader rawReader(_volumeHints.at(i));
ghoul::opengl::Texture* volume = rawReader.read(_volumePaths.at(i));
volume->uploadTexture();
// volume->uploadTexture();
cl_mem volumeTexture = _context.createTextureFromGLTexture(CL_MEM_READ_ONLY, *volume);
_volumes.push_back(volume);
@@ -293,7 +293,6 @@ bool RenderableVolumeExpert::deinitialize() {
}
void RenderableVolumeExpert::render(const Camera *camera, const psc &thisPosition) {
if( ! _kernel.isValidKernel())
return;
@@ -304,16 +303,30 @@ void RenderableVolumeExpert::render(const Camera *camera, const psc &thisPositio
double factor = pow(10.0,thisPosition[3]);
transform = glm::translate(transform, glm::vec3(thisPosition[0]*factor, thisPosition[1]*factor, thisPosition[2]*factor));
transform = glm::rotate(transform, time*speed, glm::vec3(0.0f, 1.0f, 0.0f));
_colorBoxRenderer->render(transform);
_textureLock->lock();
_kernelLock->lock();
glFinish();
// Aquire GL objects
_commands.enqueueAcquireGLObjects(_clBackTexture);
_commands.enqueueAcquireGLObjects(_clFrontTexture);
_commands.enqueueAcquireGLObjects(_clOutput);
_commands.enqueueAcquireGLObjects(_clVolumes);
_commands.enqueueAcquireGLObjects(_clTransferFunctions);
_commands.enqueueKernelBlocking(_kernel, *_ws);
_commands.finish();
// Release GL objects
_commands.enqueueReleaseGLObjects(_clBackTexture);
_commands.enqueueReleaseGLObjects(_clFrontTexture);
_commands.enqueueReleaseGLObjects(_clOutput);
_commands.enqueueReleaseGLObjects(_clVolumes);
_commands.enqueueReleaseGLObjects(_clTransferFunctions);
_quadProgram->activate();
glActiveTexture(GL_TEXTURE0);
_output->bind();
@@ -322,6 +335,7 @@ void RenderableVolumeExpert::render(const Camera *camera, const psc &thisPositio
glBindVertexArray(_screenQuad);
glDrawArrays(GL_TRIANGLES, 0, 6);
glBindVertexArray(0);
_kernelLock->unlock();
_textureLock->unlock();
@@ -449,4 +463,4 @@ void RenderableVolumeExpert::safeUpdateTexture(const ghoul::filesystem::File& fi
}
}
} // namespace openspace
} // namespace openspace