Commit dffa84eb authored by schultezub's avatar schultezub

further step to OpenGL 3.3 core compatibility in core and modules: Got rid of...

further step to OpenGL 3.3 core compatibility in core and modules: Got rid of glPush/PopAttrib in processors, added asserts for correct OpenGL state after processor execution

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@493 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 694a519e
......@@ -147,7 +147,6 @@ namespace campvis {
// map signed integer types from [-1.0:1.0] to [0.0:1.0] in order to avoid clamping of negative values
if (isInteger && isSigned) {
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPixelTransferf(GL_RED_SCALE, 0.5f);
glPixelTransferf(GL_GREEN_SCALE, 0.5f);
glPixelTransferf(GL_BLUE_SCALE, 0.5f);
......@@ -165,7 +164,16 @@ namespace campvis {
_texture->setWrapping(tgt::Texture::CLAMP);
if (isInteger && isSigned) {
glPopAttrib();
// restore default
glPixelTransferf(GL_RED_SCALE, 1.0f);
glPixelTransferf(GL_GREEN_SCALE, 1.0f);
glPixelTransferf(GL_BLUE_SCALE, 1.0f);
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
glPixelTransferf(GL_RED_BIAS, 0.0f);
glPixelTransferf(GL_GREEN_BIAS, 0.0f);
glPixelTransferf(GL_BLUE_BIAS, 0.0f);
glPixelTransferf(GL_ALPHA_BIAS, 0.0f);
}
// revoke ownership of local pixel data from the texture
......
......@@ -125,7 +125,7 @@ namespace campvis {
processor->unlockProcessor();
#ifdef CAMPVIS_DEBUG
//LDEBUG("Executed processor " << processor->getName() << " duration: " << (endTime - startTime));
LDEBUG("Executed processor " << processor->getName() << " duration: " << (endTime - startTime));
#endif
}
}
......
......@@ -104,9 +104,6 @@ namespace campvis {
validate(INVALID_SHADER);
}
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
_shader->activate();
_shader->setIgnoreUniformLocationError(true);
......@@ -147,7 +144,6 @@ namespace campvis {
decorateRenderEpilog(_shader);
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
glPopAttrib();
LGL_ERROR;
}
else {
......
......@@ -37,6 +37,26 @@
#include "core/tools/opengljobprocessor.h"
#include "core/tools/simplejobprocessor.h"
namespace {
GLboolean getGlBool(GLenum param) {
GLboolean toReturn;
glGetBooleanv(param, &toReturn);
return toReturn;
};
GLint getGlInt(GLenum param) {
GLint toReturn;
glGetIntegerv(param, &toReturn);
return toReturn;
};
GLfloat getGlFloat(GLenum param) {
GLfloat toReturn;
glGetFloatv(param, &toReturn);
return toReturn;
}
}
namespace campvis {
const std::string VisualizationPipeline::loggerCat_ = "CAMPVis.core.datastructures.VisualizationPipeline";
......@@ -161,7 +181,7 @@ namespace campvis {
// is VisualizationProcessor
GLJobProc.enqueueJob(
_canvas,
makeJobOnHeap<VisualizationPipeline, AbstractProcessor*>(this, &VisualizationPipeline::executeProcessor, processor),
makeJobOnHeap<VisualizationPipeline, AbstractProcessor*>(this, &VisualizationPipeline::executeProcessorAndCheckOpenGLState, processor),
OpenGLJobProcessor::SerialJob);
}
else {
......@@ -178,5 +198,29 @@ namespace campvis {
_isVisProcessorMap.insert(std::make_pair(processor, (dynamic_cast<VisualizationProcessor*>(processor) != 0)));
AbstractPipeline::addProcessor(processor);
}
void VisualizationPipeline::executeProcessorAndCheckOpenGLState(AbstractProcessor* processor) {
AbstractPipeline::executeProcessor(processor);
#ifdef CAMPVIS_DEBUG
// tgtAssert(getGlBool(GL_DEPTH_TEST) == false, "Invalid OpenGL state after processor execution, GL_DEPTH_TEST != false.");
// tgtAssert(getGlBool(GL_SCISSOR_TEST) == false, "Invalid OpenGL state after processor execution, GL_SCISSOR_TEST != false.");
//
// tgtAssert(getGlInt(GL_CULL_FACE_MODE) == GL_BACK, "Invalid OpenGL state after processor execution, GL_CULL_FACE_MODE != GL_BACk.");
// tgtAssert(getGlInt(GL_DEPTH_FUNC) == GL_LESS, "Invalid OpenGL state after processor execution, GL_DEPTH_FUNC != GL_LESS.");
//
// tgtAssert(getGlFloat(GL_DEPTH_CLEAR_VALUE) == 1.f, "Invalid OpenGL state after processor execution, GL_DEPTH_CLEAR_VALUE != 1.f.");
//
// tgtAssert(getGlFloat(GL_RED_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_RED_SCALE != 1.f.");
// tgtAssert(getGlFloat(GL_GREEN_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_GREEN_SCALE != 1.f.");
// tgtAssert(getGlFloat(GL_BLUE_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_BLUE_SCALE != 1.f.");
// tgtAssert(getGlFloat(GL_ALPHA_SCALE) == 1.f, "Invalid OpenGL state after processor execution, GL_ALPHA_SCALE != 1.f.");
//
// tgtAssert(getGlFloat(GL_RED_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_RED_BIAS != 0.f.");
// tgtAssert(getGlFloat(GL_GREEN_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_GREEN_BIAS != 0.f.");
// tgtAssert(getGlFloat(GL_BLUE_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_BLUE_BIAS != 0.f.");
// tgtAssert(getGlFloat(GL_ALPHA_BIAS) == 0.f, "Invalid OpenGL state after processor execution, GL_ALPHA_BIAS != 0.f.");
#endif
}
}
......@@ -138,6 +138,14 @@ namespace campvis {
*/
void disableLowQualityMode();
/**
* Executes \a processor and afterwards checks the OpenGL state to be valid.
* \note Only call from with a valid OpenGL context
* \param processor Processor to execute
*/
void executeProcessorAndCheckOpenGLState(AbstractProcessor* processor);
/// Signal emitted when the pipeline's render target has changed
sigslot::signal0<> s_renderTargetChanged;
......
......@@ -92,9 +92,6 @@ namespace campvis {
ImageRepresentationGL* image = ImageRepresentationGL::create(&id, tex);
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
_shader->activate();
_shader->setIgnoreUniformLocationError(true);
......@@ -106,14 +103,12 @@ namespace campvis {
image->bind(_shader, texUnit, "_colorTexture");
rt.second->activate();
LGL_ERROR;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
QuadRdr.renderQuad();
rt.second->deactivate();
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
glPopAttrib();
LGL_ERROR;
data.addData(p_targetImageID.getValue(), rt.first);
......
......@@ -105,7 +105,6 @@ namespace campvis {
std::pair<ImageData*, ImageRepresentationRenderTarget*> tempTarget = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
std::pair<ImageData*, ImageRepresentationRenderTarget*> outputTarget = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
......@@ -143,7 +142,8 @@ namespace campvis {
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
glPopAttrib();
glDepthFunc(GL_LESS);
glDisable(GL_DEPTH_TEST);
LGL_ERROR;
data.addData(p_outputImage.getValue() + "temp", tempTarget.first);
......
......@@ -59,15 +59,12 @@ namespace campvis {
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
rt.second->activate();
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_DEPTH_TEST);
if (p_invertMapping.getValue())
glClearColor(0.f, 0.f, 0.f, 1.f);
else
glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
QuadRdr.renderQuad();
glPopAttrib();
LGL_ERROR;
rt.second->deactivate();
......
......@@ -111,7 +111,6 @@ namespace campvis {
MeshGeometry clipped = proxyGeometry->clipAgainstPlane(nearPlaneDistToOrigin, -p_camera.getValue().getLook(), true, 0.02f);
// start render setup
glPushAttrib(GL_ALL_ATTRIB_BITS);
_shader->activate();
// setup virtual mirror if necessary
......@@ -207,7 +206,13 @@ namespace campvis {
decorateRenderEpilog(_shader);
_shader->deactivate();
glPopAttrib();
glDepthFunc(GL_LESS);
glClearDepth(1.0f);
glCullFace(GL_BACK);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
LGL_ERROR;
data.addData(p_entryImageID.getValue(), entrypoints.first);
......
......@@ -79,8 +79,6 @@ namespace campvis {
if (proxyGeometry != 0 && _shader != 0) {
// set modelview and projection matrices
glPushAttrib(GL_ALL_ATTRIB_BITS);
_shader->activate();
_shader->setUniform("_projectionMatrix", p_camera.getValue().getProjectionMatrix());
_shader->setUniform("_viewMatrix", p_camera.getValue().getViewMatrix());
......@@ -98,7 +96,7 @@ namespace campvis {
rt.second->deactivate();
_shader->deactivate();
glPopAttrib();
glDisable(GL_DEPTH_TEST);
LGL_ERROR;
data.addData(p_renderTargetID.getValue(), rt.first);
......
......@@ -87,9 +87,6 @@ namespace campvis {
if (xRayImage != 0 && sliceImage != 0 && drrFullImage != 0 && drrClippedImage != 0) {
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
_shader->activate();
tgt::TextureUnit xRayColorUnit, xRayDepthUnit, sliceColorUnit, sliceDepthUnit, drrFullUnit, drrClippedUnit;
......@@ -109,7 +106,6 @@ namespace campvis {
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
glPopAttrib();
LGL_ERROR;
data.addData(p_targetImageId.getValue(), rt.first);
......
......@@ -95,10 +95,7 @@ namespace campvis {
if (firstImage != 0 && secondImage != 0 ) {
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
_shader->activate();
tgt::TextureUnit firstColorUnit, firstDepthUnit, secondColorUnit, secondDepthUnit;
......@@ -110,14 +107,12 @@ namespace campvis {
decorateRenderProlog(data, _shader);
rt.second->activate();
LGL_ERROR;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
QuadRdr.renderQuad();
rt.second->deactivate();
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
glPopAttrib();
LGL_ERROR;
data.addData(p_targetImageId.getValue(), rt.first);
......
......@@ -69,7 +69,6 @@ namespace campvis {
_shader->setUniform("_shadowIntensity", p_shadowIntensity.getValue());
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDepthFunc(GL_ALWAYS);
QuadRdr.renderQuad();
LGL_ERROR;
......
......@@ -70,6 +70,8 @@ namespace campvis {
void SliceRenderer3D::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/glsl/slicerenderer3d.frag", "", false);
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
}
void SliceRenderer3D::deinit() {
......@@ -101,7 +103,6 @@ namespace campvis {
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
_shader->activate();
......@@ -119,14 +120,12 @@ namespace campvis {
rt.second->activate();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
_shader->setAttributeLocation(0, "in_Position");
_shader->setAttributeLocation(1, "in_TexCoord");
slice.render();
rt.second->deactivate();
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
glPopAttrib();
glDisable(GL_DEPTH_TEST);
data.addData(p_targetImageID.getValue(), rt.first);
p_targetImageID.issueWrite();
......
......@@ -85,7 +85,6 @@ namespace campvis {
if (normalImage != 0 && mirrorImage != 0 && mirrorRendered != 0) {
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
......@@ -106,7 +105,8 @@ namespace campvis {
_shader->deactivate();
tgt::TextureUnit::setZeroUnit();
glPopAttrib();
glDepthFunc(GL_LESS);
glDisable(GL_DEPTH_TEST);
LGL_ERROR;
data.addData(p_targetImageID.getValue(), rt.first);
......
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