Commit d259aab2 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Preparation for merge. Added check to IpsviRaycaster whether OpenGL 4.4 is...

Preparation for merge. Added check to IpsviRaycaster whether OpenGL 4.4 is supported to avoid crashes if this is not the case.
parent 7a6cdeb1
...@@ -45,6 +45,7 @@ namespace campvis { ...@@ -45,6 +45,7 @@ namespace campvis {
, p_icTextureSize("IcTextureSize", "Illumination Cache Texture Size", cgt::ivec2(512), cgt::ivec2(32), cgt::ivec2(2048)) , p_icTextureSize("IcTextureSize", "Illumination Cache Texture Size", cgt::ivec2(512), cgt::ivec2(32), cgt::ivec2(2048))
, p_shadowIntensity("ShadowIntensity", "Shadow Intensity", .75f, 0.f, 1.f) , p_shadowIntensity("ShadowIntensity", "Shadow Intensity", .75f, 0.f, 1.f)
, _vhm(nullptr) , _vhm(nullptr)
, _gl44Supported(false)
{ {
_icTextures[0] = nullptr; _icTextures[0] = nullptr;
_icTextures[1] = nullptr; _icTextures[1] = nullptr;
...@@ -65,13 +66,25 @@ namespace campvis { ...@@ -65,13 +66,25 @@ namespace campvis {
} }
void IpsviRaycaster::init() { void IpsviRaycaster::init() {
RaycastingProcessor::init(); // get supported OpenGL version
// if OpenGL 4.4 is not supported, abort the initialization, since compiling the shader will fail.
_gl44Supported = (GpuCaps.getGlVersion() >= cgt::GpuCapabilities::GlVersion::CGT_GL_VERSION_4_4);
_gl44Supported &= (GpuCaps.getShaderVersion() >= cgt::GpuCapabilities::GlVersion::SHADER_VERSION_440);
if (! _gl44Supported) {
LERROR("This system does not support OpenGL 4.4, which is required for the IpsviRaycaster. Raycaster deactivated.");
return;
}
RaycastingProcessor::init();
_vhm = new VoxelHierarchyMapper(); _vhm = new VoxelHierarchyMapper();
invalidate(INVALID_BBV | INVALID_IC_TEXTURES); invalidate(INVALID_BBV | INVALID_IC_TEXTURES);
} }
void IpsviRaycaster::deinit() { void IpsviRaycaster::deinit() {
// nothing to deinitialize, if this processor has never been initialized.
if (!_gl44Supported)
return;
delete _vhm; delete _vhm;
delete _icTextures[0]; delete _icTextures[0];
delete _icTextures[1]; delete _icTextures[1];
...@@ -79,6 +92,13 @@ namespace campvis { ...@@ -79,6 +92,13 @@ namespace campvis {
RaycastingProcessor::deinit(); RaycastingProcessor::deinit();
} }
void IpsviRaycaster::updateResult(DataContainer& data) {
if (!_gl44Supported)
return;
RaycastingProcessor::updateResult(data);
}
void IpsviRaycaster::processImpl(DataContainer& data, ImageRepresentationGL::ScopedRepresentation& image) { void IpsviRaycaster::processImpl(DataContainer& data, ImageRepresentationGL::ScopedRepresentation& image) {
// (re)create Illumination Cache (IC) textures if needed // (re)create Illumination Cache (IC) textures if needed
if (getInvalidationLevel() & INVALID_IC_TEXTURES) { if (getInvalidationLevel() & INVALID_IC_TEXTURES) {
...@@ -174,7 +194,7 @@ namespace campvis { ...@@ -174,7 +194,7 @@ namespace campvis {
corners[6] = cgt::vec3(worldBounds.getURB().x, worldBounds.getURB().y, worldBounds.getLLF().z); corners[6] = cgt::vec3(worldBounds.getURB().x, worldBounds.getURB().y, worldBounds.getLLF().z);
corners[7] = cgt::vec3(worldBounds.getURB().x, worldBounds.getURB().y, worldBounds.getURB().z); corners[7] = cgt::vec3(worldBounds.getURB().x, worldBounds.getURB().y, worldBounds.getURB().z);
for (auto i = 0; i < corners.size(); ++i) { for (size_t i = 0; i < corners.size(); ++i) {
const cgt::vec3 diag = corners[i]; const cgt::vec3 diag = corners[i];
const float distance = std::abs(cgt::dot(diag, icNormal)); const float distance = std::abs(cgt::dot(diag, icNormal));
const cgt::vec3 projected = diag - (-distance * icNormal); const cgt::vec3 projected = diag - (-distance * icNormal);
......
...@@ -92,6 +92,8 @@ namespace campvis { ...@@ -92,6 +92,8 @@ namespace campvis {
FloatProperty p_shadowIntensity; ///< Intensity of the shadowing effect FloatProperty p_shadowIntensity; ///< Intensity of the shadowing effect
protected: protected:
/// \see RaycastingProcessor::updateResult()
virtual void updateResult(DataContainer& data) override;
/// \see RaycastingProcessor::processImpl() /// \see RaycastingProcessor::processImpl()
virtual void processImpl(DataContainer& data, ImageRepresentationGL::ScopedRepresentation& image); virtual void processImpl(DataContainer& data, ImageRepresentationGL::ScopedRepresentation& image);
...@@ -100,6 +102,7 @@ namespace campvis { ...@@ -100,6 +102,7 @@ namespace campvis {
VoxelHierarchyMapper* _vhm; ///< for optimizing entry/exit points VoxelHierarchyMapper* _vhm; ///< for optimizing entry/exit points
cgt::Texture* _icTextures[2]; ///< Illumination cache textures cgt::Texture* _icTextures[2]; ///< Illumination cache textures
bool _gl44Supported; ///< Flag whether OpenGL 4.4 is supported.
static const std::string loggerCat_; static const std::string loggerCat_;
}; };
......
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