Permalink
Browse files

Merge pull request #16 from tobiasrau/release_fix

Release fix
  • Loading branch information...
tobiasrau committed Oct 6, 2017
2 parents 9ade0d1 + 3486a3e commit 15b17e200b8e7d4f9da0b7143e08327936233b97
View
@@ -16,18 +16,6 @@ environment:
CMAKE_GENERATOR: "Visual Studio 14 2015 Win64"
CMAKE_CONFIG: Debug
VSVER: vs140
- platform: x64
configuration: Release
os: Visual Studio 2013
CMAKE_GENERATOR: "Visual Studio 12 2013 Win64"
CMAKE_CONFIG: Release
VSVER: vs120
- platform: x64
configuration: Debug
os: Visual Studio 2013
CMAKE_GENERATOR: "Visual Studio 12 2013 Win64"
CMAKE_CONFIG: Debug
VSVER: vs120
matrix:
fast_finish: true
@@ -18,6 +18,7 @@ namespace megamol {
namespace ospray {
enum structureTypeEnum {
UNINITIALIZED,
GEOMETRY,
VOLUME
};
@@ -95,7 +95,6 @@ void AbstractOSPRayRenderer::renderTexture2D(vislib::graphics::gl::GLSLShader &s
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, fb);
glUniform1i(shader.ParameterLocation("tex"), 0);
glBindVertexArray(this->vaScreen);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
@@ -498,21 +497,23 @@ void AbstractOSPRayRenderer::writePPM(const char *fileName, const osp::vec2i &si
void AbstractOSPRayRenderer::fillWorld() {
bool AbstractOSPRayRenderer::fillWorld() {
if (this->geo.size() != 0) {
for (auto element : this->geo) {
ospRemoveGeometry(this->world, element);
}
this->geo.clear();
}
if (this->vol.size() != 0) {
for (auto element : this->vol) {
ospRemoveVolume(this->world, element);
}
this->vol.clear();
}
//ospRelease(this->world);
bool returnValue = true;
if (this->geo.size() != 0) {
for (auto element : this->geo) {
ospRemoveGeometry(this->world, element);
}
this->geo.clear();
}
if (this->vol.size() != 0) {
for (auto element : this->vol) {
ospRemoveVolume(this->world, element);
}
this->vol.clear();
}
//ospRelease(this->world);
for (auto entry : this->structureMap) {
@@ -596,15 +597,21 @@ void AbstractOSPRayRenderer::fillWorld() {
OSPData voxels = NULL;
OSPData isovalues = NULL;
OSPData planes = NULL;
//OSPPlane pln = NULL; //TEMPORARILY DISABLED
//OSPPlane pln = NULL; //TEMPORARILY DISABLED
switch (element.type) {
case structureTypeEnum::UNINITIALIZED:
break;
case structureTypeEnum::GEOMETRY:
switch (element.geometryType) {
case geometryTypeEnum::SPHERES:
if (element.vertexData == NULL) {
returnValue = false;
break;
}
geo.push_back(ospNewGeometry("spheres"));
vertexData = ospNewData(element.partCount * element.vertexLength, OSP_FLOAT, element.vertexData->data());
vertexData = ospNewData(element.partCount * element.vertexLength, OSP_FLOAT, element.vertexData->data(), OSP_DATA_SHARED_BUFFER);
ospSet1i(geo.back(), "bytes_per_sphere", element.vertexLength * sizeof(float));
if (element.vertexLength > 3) {
@@ -619,10 +626,10 @@ void AbstractOSPRayRenderer::fillWorld() {
ospSetData(geo.back(), "spheres", vertexData);
if (element.colorLength == 4) {
colorData = ospNewData(element.partCount * element.colorLength, OSP_FLOAT, element.colorData->data());
colorData = ospNewData(element.partCount * element.colorLength, OSP_FLOAT, element.colorData->data(), OSP_DATA_SHARED_BUFFER);
ospCommit(colorData);
ospSetData(geo.back(), "color", colorData);
}
}
// clipPlane setup
/* TEMPORARILY DISABLED
@@ -640,20 +647,25 @@ void AbstractOSPRayRenderer::fillWorld() {
break;
case geometryTypeEnum::NHSPHERES:
if (element.vertexData == NULL) {
returnValue = false;
break;
}
geo.push_back(ospNewGeometry("spheres"));
if (element.vertexLength > 3*sizeof(float)) {
vertexData = ospNewData(element.partCount, OSP_FLOAT4, *element.raw);
if (element.vertexLength > 3 * sizeof(float)) {
vertexData = ospNewData(element.partCount, OSP_FLOAT4, *element.raw, OSP_DATA_SHARED_BUFFER);
ospSet1i(geo.back(), "bytes_per_sphere", element.vertexLength + element.colorLength);
ospSet1f(geo.back(), "offset_radius", 3 * sizeof(float));
} else {
vertexData = ospNewData(element.partCount*4, OSP_FLOAT, *element.raw, OSP_DATA_SHARED_BUFFER);
vertexData = ospNewData(element.partCount * 4, OSP_FLOAT, *element.raw, OSP_DATA_SHARED_BUFFER);
ospSet1i(geo.back(), "bytes_per_sphere", element.vertexLength + element.colorLength);
ospSet1f(geo.back(), "radius", element.globalRadius);
//colorData = ospNewData(element.partCount * 4, OSP_FLOAT, *element.raw, OSP_DATA_SHARED_BUFFER);
//ospSet1i(geo, "color_offset", element.vertexLength + element.colorLength);
//ospSet1i(geo, "color_stride", element.vertexLength + element.colorLength);
}
ospCommit(vertexData);
//ospCommit(colorData);
@@ -662,7 +674,10 @@ void AbstractOSPRayRenderer::fillWorld() {
break;
case geometryTypeEnum::TRIANGLES:
if (element.vertexData == NULL) {
returnValue = false;
break;
}
geo.push_back(ospNewGeometry("triangles"));
@@ -703,14 +718,18 @@ void AbstractOSPRayRenderer::fillWorld() {
break;
case geometryTypeEnum::STREAMLINES:
if (element.vertexData == NULL) {
returnValue = false;
break;
}
geo.push_back(ospNewGeometry("streamlines"));
osp::vec3fa* data;
data = new osp::vec3fa[element.vertexData->size()/3];
data = new osp::vec3fa[element.vertexData->size() / 3];
// fill aligned array with vertex data
for (unsigned int i = 0; i < element.vertexData->size()/3; i++) {
for (unsigned int i = 0; i < element.vertexData->size() / 3; i++) {
data[i].x = element.vertexData->data()[3 * i + 0];
data[i].y = element.vertexData->data()[3 * i + 1];
data[i].z = element.vertexData->data()[3 * i + 2];
@@ -719,7 +738,7 @@ void AbstractOSPRayRenderer::fillWorld() {
data[i].u = 16;
}
vertexData = ospNewData(element.vertexData->size()/3, OSP_FLOAT3A, data);
vertexData = ospNewData(element.vertexData->size() / 3, OSP_FLOAT3A, data);
ospCommit(vertexData);
ospSetData(geo.back(), "vertex", vertexData);
@@ -743,6 +762,7 @@ void AbstractOSPRayRenderer::fillWorld() {
if (material != NULL) {
ospSetMaterial(geo.back(), material);
}
ospCommit(geo.back());
ospAddGeometry(world, geo.back());
@@ -757,8 +777,12 @@ void AbstractOSPRayRenderer::fillWorld() {
break;
case structureTypeEnum::VOLUME:
vol.push_back(ospNewVolume("shared_structured_volume"));
if (element.voxels == NULL) {
returnValue = false;
break;
}
vol.push_back(ospNewVolume("shared_structured_volume"));
ospSetString(vol.back(), "voxelType", "float");
// scaling properties of the volume
@@ -802,36 +826,36 @@ void AbstractOSPRayRenderer::fillWorld() {
case volumeRepresentationType::ISOSURFACE:
// isosurface
geo.push_back(ospNewGeometry("isosurfaces"));
isovalues = ospNewData(1, OSP_FLOAT, element.isoValue->data());
ospCommit(isovalues);
ospSetData(geo.back(), "isovalues", isovalues);
ospSetObject(geo.back(), "volume", vol.back());
if (material != NULL) {
ospSetMaterial(geo.back(), material);
}
geo.push_back(ospNewGeometry("isosurfaces"));
isovalues = ospNewData(1, OSP_FLOAT, element.isoValue->data());
ospCommit(isovalues);
ospSetData(geo.back(), "isovalues", isovalues);
ospSetObject(geo.back(), "volume", vol.back());
if (material != NULL) {
ospSetMaterial(geo.back(), material);
}
ospCommit(geo.back());
ospCommit(geo.back());
ospAddGeometry(world, geo.back()); // Show isosurface
ospAddGeometry(world, geo.back()); // Show isosurface
break;
case volumeRepresentationType::SLICE:
geo.push_back(ospNewGeometry("slices"));
planes = ospNewData(1, OSP_FLOAT4, element.sliceData->data());
ospCommit(planes);
ospSetData(geo.back(), "planes", planes);
ospSetObject(geo.back(), "volume", vol.back());
if (material != NULL) {
ospSetMaterial(geo.back(), material);
}
geo.push_back(ospNewGeometry("slices"));
planes = ospNewData(1, OSP_FLOAT4, element.sliceData->data());
ospCommit(planes);
ospSetData(geo.back(), "planes", planes);
ospSetObject(geo.back(), "volume", vol.back());
if (material != NULL) {
ospSetMaterial(geo.back(), material);
}
ospCommit(geo.back());
ospCommit(geo.back());
ospAddGeometry(world, geo.back()); // Show slice
ospAddGeometry(world, geo.back()); // Show slice
break;
}
@@ -840,6 +864,8 @@ void AbstractOSPRayRenderer::fillWorld() {
} // for element loop
return returnValue;
}
void AbstractOSPRayRenderer::releaseOSPRayStuff() {
@@ -43,7 +43,7 @@ class AbstractOSPRayRenderer : public core::view::Renderer3DModule {
* @param image/window width
* @param image/window heigth
*/
void renderTexture2D(vislib::graphics::gl::GLSLShader &shader, const uint32_t * fb, int &width, int &height);
void renderTexture2D(vislib::graphics::gl::GLSLShader &shader, const uint32_t* fb, int &width, int &height);
/**
* helper function for setting up the OSPRay screen
@@ -101,7 +101,7 @@ class AbstractOSPRayRenderer : public core::view::Renderer3DModule {
* create geometries and volumes.
*
*/
void fillWorld();
bool fillWorld();
/**
* Releases the created geometries and volumes.
@@ -27,8 +27,7 @@ AbstractOSPRayStructure::AbstractOSPRayStructure(void) :
this->MakeSlotAvailable(&this->getMaterialSlot);
this->structureContainer.isValid = true;
this->time = 0.0f;
this->time = -1.0f;
}
AbstractOSPRayStructure::~AbstractOSPRayStructure(void) {
@@ -13,7 +13,24 @@ using namespace megamol::ospray;
OSPRayStructureContainer::OSPRayStructureContainer() :
isValid(false) { }
isValid(false),
vertexData(NULL),
colorData(NULL),
normalData(NULL),
texData(NULL),
indexData(NULL),
voxels(NULL),
gridOrigin(NULL),
gridSpacing(NULL),
dimensions(NULL),
clippingBoxLower(NULL),
clippingBoxUpper(NULL),
isoValue(NULL),
sliceData(NULL),
clipPlaneData(NULL),
clipPlaneColor(NULL),
raw(NULL),
type(structureTypeEnum::UNINITIALIZED) { }
OSPRayStructureContainer::~OSPRayStructureContainer() {
//
@@ -135,8 +135,7 @@ bool OSPRayRenderer::Render(megamol::core::Call& call) {
ospSetCurrentDevice(device);
}
core::view::CallRender3D *cr = dynamic_cast<core::view::CallRender3D*>(&call);
if (cr == NULL)
return false;
if (cr == NULL) return false;
@@ -195,7 +194,7 @@ bool OSPRayRenderer::Render(megamol::core::Call& call) {
//imgSize.y = cr->GetCameraParameters()->VirtualViewSize().GetHeight();
imgSize.x = cr->GetCameraParameters()->TileRect().Width();
imgSize.y = cr->GetCameraParameters()->TileRect().Height();
framebuffer = newFrameBuffer(imgSize, OSP_FB_RGBA8, OSP_FB_COLOR | /*OSP_FB_DEPTH |*/ OSP_FB_ACCUM);
framebuffer = newFrameBuffer(imgSize, OSP_FB_RGBA8, OSP_FB_COLOR | OSP_FB_DEPTH | OSP_FB_ACCUM);
ospCommit(framebuffer);
}
@@ -230,7 +229,7 @@ bool OSPRayRenderer::Render(megamol::core::Call& call) {
if (data_has_changed ||
time != cr->Time() ||
this->InterfaceIsDirty()) {
this->fillWorld();
if (!this->fillWorld()) return false;
ospCommit(world);
}
this->InterfaceResetDirty();
@@ -254,8 +253,8 @@ bool OSPRayRenderer::Render(megamol::core::Call& call) {
// setup framebuffer
ospFrameBufferClear(framebuffer, OSP_FB_COLOR | OSP_FB_ACCUM);
ospRenderFrame(framebuffer, renderer, OSP_FB_COLOR | OSP_FB_ACCUM);
ospFrameBufferClear(framebuffer, OSP_FB_COLOR | OSP_FB_DEPTH | OSP_FB_ACCUM);
ospRenderFrame(framebuffer, renderer, OSP_FB_COLOR | OSP_FB_DEPTH | OSP_FB_ACCUM);
// get the texture from the framebuffer
@@ -283,7 +282,7 @@ bool OSPRayRenderer::Render(megamol::core::Call& call) {
} else {
ospRenderFrame(framebuffer, renderer, OSP_FB_COLOR | OSP_FB_ACCUM);
ospRenderFrame(framebuffer, renderer, OSP_FB_COLOR | OSP_FB_DEPTH | OSP_FB_ACCUM);
fb = (uint32_t*)ospMapFrameBuffer(framebuffer, OSP_FB_COLOR);
this->renderTexture2D(osprayShader, fb, imgSize.x, imgSize.y);
ospUnmapFrameBuffer(fb, framebuffer);

0 comments on commit 15b17e2

Please sign in to comment.