Commit 3ab6db71 authored by Martin Schultz's avatar Martin Schultz

Merge branch 'featureGlewSeparation' into unstable

parents 71a9d8f9 f3920676
......@@ -65,11 +65,11 @@
#ifndef PLUGINFUNCTIONS_HH
#define PLUGINFUNCTIONS_HH
#include <OpenFlipper/common/Types.hh>
#include <QPair>
#include <QFileDialog>
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/common/OFGLWidget.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
......
......@@ -54,8 +54,9 @@
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 4))
#include <QOpenGLWidget>
#include <QSurfaceFormat>
//only forward declaration
class QOpenGLWidget;
class QSurfaceFormat;
typedef QOpenGLWidget OFGLWidget;
typedef QSurfaceFormat OFGLFormat;
......
......@@ -62,6 +62,10 @@
#include <cstdlib>
#include <sstream>
//avoid inclusion clashes. Bad inclusion order or mixing
//QtOpenGL and plain opengl functions in a single cc will cause an error
#define QT_NO_OPENGL
//#pragma message("defined no opengl")
#if defined(ARCH_DARWIN)
......
......@@ -51,6 +51,7 @@
#include <ACG/GL/globjects.hh>
#include <ACG/GL/GLFormatInfo.hh>
#include <ACG/ShaderUtils/GLSLShader.hh>
#include <ACG/Utils/ImageConversion.hh>
#include <QImage>
#include <QGLWidget>
......@@ -640,7 +641,7 @@ bool Texture2D::loadFromFile( const std::string& _filename, GLenum _minFilter, G
if (mipmaps)
autogenerateMipMaps();
QImage gltex = QGLWidget::convertToGLFormat ( qtex );
QImage gltex = ACG::Util::convertToGLFormat(gltex);
setData(0, GL_RGBA, gltex.width(), gltex.height(), GL_RGBA, GL_UNSIGNED_BYTE, gltex.bits());
}
......
This diff is collapsed.
......@@ -61,9 +61,11 @@
//== INCLUDES =================================================================
#include "../GL/GLState.hh"
#include "../Scenegraph/SceneGraph.hh"
#include "../Scenegraph/DrawModes.hh"
#include "../Config/ACGDefines.hh"
#include "../Math/VectorT.hh"
#include "../Math/GLMatrixT.hh"
#include "../Scenegraph/PickTarget.hh"
#include <QGLFormat>
#include <QBoxLayout>
......@@ -98,12 +100,16 @@ class QImage;
class QSocketNotifier;
class QGraphicsWidget;
class QGraphicsGridLayout;
class QGLFormat;
class QGLWidget;
//== NAMESPACES ===============================================================
namespace ACG {
class GLState;
namespace SceneGraph {
class BaseNode;
}
namespace QtWidgets {
......@@ -116,7 +122,6 @@ class QtGLGraphicsView;
class QtSceneGraphDialog;
class QtShiftPopupMenu;
//== CLASS DEFINITION =========================================================
......@@ -246,11 +251,9 @@ public:
/** Set background color.
Sets the OpenGL clear color to (_c.red(), _c.green(), _c.blue(), 0).
*/
void backgroundColor(const Vec4f& _color) {
glstate_->set_clear_color(_color); updateGL();
}
void backgroundColor(const Vec4f& _color);
/// get background color
Vec4f backgroundColor() { return glstate_->clear_color(); }
Vec4f backgroundColor();
/** Lock update of display.
......@@ -764,6 +767,8 @@ private:
// helper called by drawScene() when stereo viewing is active.
void drawScene_stereo();
// helper to check openGL support
bool hasOpenGL();
// updates popup menu with the available draw modes
void updatePopupMenu();
......
......@@ -62,6 +62,9 @@
#include "QtGLGraphicsScene.hh"
#include "QtGLGraphicsView.hh"
#include "../GL/GLState.hh"
#include "../Scenegraph/SceneGraph.hh"
//== NAMESPACES ===============================================================
namespace ACG {
......
......@@ -62,6 +62,8 @@
#include <QStatusBar>
#include <QToolButton>
#include "../GL/GLState.hh"
#include "mono.xpm"
#include "stereo.xpm"
......
......@@ -63,6 +63,8 @@
#include "QtGLGraphicsView.hh"
#include <QHostInfo>
#include "../GL/GLState.hh"
//== NAMESPACES ===============================================================
namespace ACG {
......
This diff is collapsed.
......@@ -65,6 +65,8 @@
#include <QInputDialog>
#include <QStatusBar>
#include "../GL/GLState.hh"
#ifdef max
# undef max
#endif
......
......@@ -66,6 +66,7 @@
#include "../Math/VectorT.hh"
#include "../GL/GLState.hh"
#include "../Config/ACGDefines.hh"
#include "PickTarget.hh"
// Qt
//#include <qgl.h>
......@@ -95,30 +96,6 @@ class Material;
//== CLASS DEFINITION =========================================================
/// What target to use for picking
enum PickTarget
{
/// picks faces (may not be implemented for all nodes)
PICK_CELL,
/// picks faces (should be implemented for all nodes)
PICK_FACE,
/// picks edges (may not be implemented for all nodes)
PICK_EDGE,
/// picks verices (may not be implemented for all nodes)
PICK_VERTEX,
/// pick any of the prior targets (should be implemented for all nodes)
PICK_ANYTHING,
/// picks only visible front edges (may not be implemented for all nodes)
PICK_FRONT_EDGE,
/// picks only visible front verices (may not be implemented for all nodes)
PICK_FRONT_VERTEX,
/// Pick spline curve or surface (picks u or u,v coords respectively)
PICK_SPLINE
};
/// Convenience macro that sets up the BaseNode::className() function
#define ACG_CLASSNAME(_className) \
virtual const std::string& className() const { \
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Author$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// CLASS BaseNode
//
//=============================================================================
#pragma once
//== INCLUDES =================================================================
//== NAMESPACES ===============================================================
namespace ACG {
namespace SceneGraph {
//== CLASS DEFINITION =========================================================
/// What target to use for picking
enum PickTarget
{
/// picks faces (may not be implemented for all nodes)
PICK_CELL,
/// picks faces (should be implemented for all nodes)
PICK_FACE,
/// picks edges (may not be implemented for all nodes)
PICK_EDGE,
/// picks verices (may not be implemented for all nodes)
PICK_VERTEX,
/// pick any of the prior targets (should be implemented for all nodes)
PICK_ANYTHING,
/// picks only visible front edges (may not be implemented for all nodes)
PICK_FRONT_EDGE,
/// picks only visible front verices (may not be implemented for all nodes)
PICK_FRONT_VERTEX,
/// Pick spline curve or surface (picks u or u,v coords respectively)
PICK_SPLINE
};
}
}
......@@ -63,6 +63,7 @@
#include <ACG/GL/acg_glew.hh>
#include "TextNode.hh"
#include "../Utils/ImageConversion.hh"
//== NAMESPACES ===============================================================
......@@ -405,7 +406,7 @@ updateFont() {
painter.end();
// convert finalImage to an OpenGL friendly format
finalImage = QGLWidget::convertToGLFormat(finalImage);
finalImage = ACG::Util::convertToGLFormat(finalImage);
// generate a new texture from finalImage
if (!texture_)
......
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
#include "ImageConversion.hh"
#include <QImage>
#include <QGLWidget>
QImage ACG::Util::convertToGLFormat(QImage _img)
{
return QGLWidget::convertToGLFormat ( _img );
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
#pragma once
#include <ACG/Config/ACGDefines.hh>
class QImage;
namespace ACG
{
class ACGDLLEXPORT Util
{
public :
static QImage convertToGLFormat(QImage);
};
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
#include "Profile.hh"
#include <QGLContext>
bool ACG::Profile::isCoreProfile()
{
return QGLContext::currentContext()->format().profile() != QGLFormat::CoreProfile;
}
bool ACG::Profile::isCompatibilityProfile()
{
return QGLContext::currentContext()->format().profile() != QGLFormat::CompatibilityProfile;
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
#pragma once
#include "../Config/ACGDefines.hh"
namespace ACG
{
class ACGDLLEXPORT Profile
{
public:
static bool isCoreProfile();
static bool isCompatibilityProfile();
};
}
......@@ -236,7 +236,7 @@ void glViewer::makeCurrent() {
#endif
// calling makeCurrent binds the default FBO when QOpenGLWidget is used
glWidget_->makeCurrent();
makeWidgetCurrent();
#if (QT_VERSION >= QT_VERSION_CHECK(5,4,4))
//restore the previously bound FBO, if it was not 0 as Qt Documentation says we shall not bind 0
......@@ -521,27 +521,6 @@ void glViewer::normalsMode(NormalsMode _mode)
//-----------------------------------------------------------------------------
void
glViewer::copyToImage( QImage& _image,
unsigned int _l, unsigned int _t,
unsigned int _w, unsigned int _h,
GLenum /* _buffer */ )
{
// makeCurrent();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 4))
_image = glWidget_->grabFramebuffer()
#else
_image = glWidget_->grabFrameBuffer(true)
#endif
.copy(_l, _t, _w, _h).convertToFormat(QImage::Format_RGB32);
}
//-----------------------------------------------------------------------------
void glViewer::updateGL()
{
if (!properties_.updateLocked() && isVisible() )
......@@ -2240,23 +2219,14 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
aspect = (double)w / (double)h;
}
QFramebufferObjectFormat format;
format.setInternalTextureFormat(GL_RGBA);
format.setTextureTarget(GL_TEXTURE_2D);
// set the attachments as in the standard rendering
format.setAttachment(QFramebufferObject::CombinedDepthStencil);
// format.setAttachment(QFramebufferObject::CombinedDepthStencil);
// 16 samples per pixel as we want a nice snapshot. If this is not supported
// it will fall back to the maximal supported number of samples
format.setSamples(samples);
QFramebufferObject* fb = nullptr;
GLuint hnd;
QFramebufferObject fb(w,h,format);
if ( fb.isValid() ){
if ( createQFBO(fb,&hnd,w,h,&samples) ){
const GLuint prevFbo = ACG::GLState::getFramebufferDraw();
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, fb.handle());
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, hnd);
// Turn alpha on if demanded
ACG::Vec4f backColorBak;
......@@ -2275,7 +2245,7 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
emit statusMessage(QString(tr("Could not find coordsys node, thus it will appear in the snapshot anyway.")));
}
}
backColorBak = properties()->backgroundColor();
newBack = ACG::Vec4f(backColorBak[0], backColorBak[1], backColorBak[2], (_alpha ? 0.0f : 1.0f));
......@@ -2298,18 +2268,18 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
glDisable(GL_MULTISAMPLE);
//Qt FrameBuffer "toImage" function returns QImage::Format_ARGB32_Premultiplied. not desired
QFramebufferObjectFormat tempFormat;
tempFormat.setInternalTextureFormat(GL_RGBA);
tempFormat.setTextureTarget(GL_TEXTURE_2D);
QFramebufferObject temp(w,h, tempFormat);
if (format.samples() != 0)
QFramebufferObject* temp = nullptr;
GLuint tempHnd;
int testSamples = -1;
createQFBO(temp, &tempHnd, w, h, &testSamples);
if (samples != 0)
{
//cannot directly read from a multisampled framebuffer.
//create new one without sampling and read from it
QRect rect(QPoint(0, 0), QSize(w,h));
QFramebufferObject::blitFramebuffer(&temp, rect, &fb, rect);
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, temp.handle());
blitQFBO(temp, rect, fb, rect);
ACG::GLState::bindFramebuffer(GL_FRAMEBUFFER_EXT, tempHnd);
}
//get the framebuffer data
......@@ -2334,9 +2304,12 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
}
}
deleteQFBO(temp);
}
deleteQFBO(fb);
if(_width != 0 || _height != 0) {