Commit 174373cb authored by Christopher Tenter's avatar Christopher Tenter

new post-processing chain

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20478 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d8761b03
This diff is collapsed.
......@@ -34,37 +34,99 @@
/*===========================================================================*\
* *
* $Revision: 18692 $ *
* $LastChangedBy: moeller $ *
* $Date: 2014-05-21 15:31:54 +0200 (Wed, 21 May 2014) $ *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include <ACG/GL/acg_glew.hh>
#include <ACG/GL/GLError.hh>
#include "QtBaseViewer.hh"
/**
* @file The intention of this file is to split QtBaseViewer up into two
* compile units, one including glew.h and one including Qt. This is
* necessary as glew and Qt5 conflict.
*/
#include <ACG/Math/GLMatrixT.hh>
#include <ACG/GL/FBO.hh>
#include <ACG/GL/GLState.hh>
#include <OpenFlipper/BasePlugin/PostProcessorInterface.hh>
void glViewer::readBackBuffer(ACG::GLState* _glstate)
class PostProcessing
{
GLint curFbo = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &curFbo);
public:
PostProcessing();
virtual ~PostProcessing();
/** \brief Number of post processors
*/
int numProcessors() const;
/** \brief Bind fbo for scene rendering
*
* Setup fbo and draw buffer as target for scene rendering.
* Some post processing effects require special targets and setupScene() takes this into account.
*
* @param _viewerID OpenFlipper viewer id (viewport index)
* @param _width texture width
* @param _height texture height
* @param _samples number of samples for multisampling
* @param _stereoEye eye from which to render the scene: -1 (no stereo rendering), 0 (left eye), 1 (right eye)
* @return negative (unchanged fbo ie. use current hardware fbo), 0 (fail), 1 (fbo has been changed)
*/
int setupScene(int _viewerID, int _width, int _height, int _samples = 0, int _stereoEye = -1);
/** \brief Perform all post processing
*
* Post processors might require modelview and projection matrix.
* In stereo mode, the post processor chain is executed for each eye separately.
* The resulting stereo buffers for each eye have to be resolved either by hardware OpenGL support or by manually calling resoleStereoAnaglyph() afterwards.
*
* @param _viewerID OpenFlipper viewer id (viewport index)
* @param _modelview modelview matrix of the scene
* @param _proj1 projection matrix 1 (left eye in stereo mode)
* @param _proj2 projection matrix 2 (right eye in stereo mode)
* @param _hwOpenGLStereo hardware stereo support should be used to resolve the stereo buffers (GL_BACK_LEFT, GL_BACK_RIGHT)
*/
void postProcess(int _viewerID, ACG::GLState* _glstate, const ACG::GLMatrixd& _modelview, const ACG::GLMatrixd& _proj1, const ACG::GLMatrixd& _proj2, bool _hwOpenGLStereo = false);
/** \brief Resolve stereo buffers as anaglyph
*
* Final textures are combined to an anaglyph image.
*
* @param _viewerID OpenFlipper viewer id (viewport index)
*/
void resolveStereoAnyglyph(int _viewerID);
private:
void setupFBO(ACG::FBO* _dst, int _width, int _height, GLuint _intfmt, int _samples);
void resolveMultisampling(ACG::FBO* _dst, ACG::FBO* _src);
private:
/// perform extra checks for debugging: 0 -> no checks, 1 -> fast checks, 2 -> more checks etc.
int debugLevel_;
/// FBO for scene rendering, one for each eye in stereo mode, possibly multisampled
ACG::FBO sceneFBO_[2];
/// post-processing read/write FBOs, no msaa
ACG::FBO procFBO_[2];
ACG::GLState::bindFramebuffer(GL_READ_FRAMEBUFFER, curFbo);
ACG::GLState::bindFramebuffer(GL_DRAW_FRAMEBUFFER, readBackFbo_.getFboID());
/// store post processing results for each stereo eyes, input for anaglyph processor, no msaa
ACG::FBO stereoFBO_[2];
glBlitFramebuffer(0, 0, readBackFbo_.width(), readBackFbo_.height(),
0, 0, readBackFbo_.width(), readBackFbo_.height(),
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
checkGLError();
/// backbuffer output, not owned by this class
GLuint backbufferFBO_,
backbufferTarget_;
GLint backbufferViewport_[4];
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER, curFbo);
}
/// postprocessing in stereo mode
bool stereoMode_;
};
This diff is collapsed.
......@@ -100,6 +100,8 @@ class QGraphicsScene;
class QtGLViewerLayout;
class QtShiftPopupMenu;
class CursorPainter;
class PostProcessing;
#if QT_VERSION < 0x050000
class QGLFramebufferObject;
class QGLFramebufferObjectFormat;
......@@ -1086,8 +1088,6 @@ private:
private:
ACG::FBO stereoFBO_[2];
/** \brief Compute left and right eye projection matrix for stereo rendering
*
* @param _width viewport width
......@@ -1100,14 +1100,6 @@ private:
Viewer::ViewerProperties& _properties,
ACG::GLMatrixd* _outLeft, ACG::GLMatrixd* _outRight);
/** \brief Update target fbos for stereo rendering
*
* @param _width viewport width
* @param _height viewport height
*/
void updateStereoFBOs(int _width, int _height);
/** @} */
......@@ -1118,23 +1110,9 @@ private:
private:
/// source/target fbo
ACG::FBO postProcessFBO_[2];
/// scene texture (read back from back-buffer)
ACG::FBO readBackFbo_;
/// read current color and depth texture of the back buffer for further post-processing
void readBackBuffer(ACG::GLState* _glstate);
/** \brief Adjust size of post processor FBO and attachments
*
* @param _width Buffer width
* @param _height Buffer height
*/
void updatePostProcessingBufs(int _width, int _height);
/// Post-Processing executor
PostProcessing* postproc_;
/** @} */
......
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