Commit a2d0c5da authored by Jan Möbius's avatar Jan Möbius

Resolved Conflict

parents 0d0c5423 60f7b034
......@@ -541,9 +541,10 @@ int main(int argc, char **argv)
format.setOption(QSurfaceFormat::DeprecatedFunctions);
}
format.setSamples(OpenFlipper::Options::samples());
if (OpenFlipper::Options::debug())
format.setOption(format.options() | QSurfaceFormat::DebugContext);
format.setOption(format.options() | QSurfaceFormat::DebugContext);
format.setSamples(OpenFlipper::Options::samples());
QSurfaceFormat::setDefaultFormat(format);
......
......@@ -320,13 +320,16 @@ Texture2D::Texture2D(GLenum unit)
bool Texture2D::autogenerateMipMaps()
{
if(openGLVersion(3,0))
{
// From OpenGL 3.0, glGenerateMipmap is supported and we should use that
// but glGenerateMipmap must be called AFTER the data was uploaded.
return false;
}
#ifdef GL_SGIS_generate_mipmap
if (supportsGenerateMipmap())
{
//parameter based mipmap generation was removed in 3.1
if( openGLVersion(3,1))
glGenerateMipmap(GL_TEXTURE_2D);
else
parameter(GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
return true;
}
......@@ -349,13 +352,14 @@ void Texture2D::disableAutogenerateMipMaps()
//-----------------------------------------------------------------------------
void Texture2D::setData(GLint _level,
GLint _internalFormat,
GLsizei _width,
GLsizei _height,
void Texture2D::setData(GLint _level,
GLint _internalFormat,
GLsizei _width,
GLsizei _height,
GLenum _format,
GLenum _type,
const GLvoid* _data) {
const GLvoid* _data,
bool _mipmaps) {
if (getUnit() == GL_NONE)
setUnit(GL_TEXTURE0);
......@@ -367,6 +371,10 @@ void Texture2D::setData(GLint _level,
else
glTexImage2D(GL_TEXTURE_2D, _level, _internalFormat, _width, _height, 0, _format, _type, _data);
// If mip maps should not be built on cpu and the OpenGL version is high enough, we go the default way
if(_mipmaps && !buildMipsCPU_ && openGLVersion(3,0))
glGenerateMipmap(GL_TEXTURE_2D);
width_ = _width;
height_ = _height;
internalFormat_ = _internalFormat;
......@@ -642,7 +650,7 @@ bool Texture2D::loadFromFile( const std::string& _filename, GLenum _minFilter, G
QImage gltex = ACG::Util::convertToGLFormat(qtex);
setData(0, GL_RGBA, gltex.width(), gltex.height(), GL_RGBA, GL_UNSIGNED_BYTE, gltex.bits());
setData(0, GL_RGBA, gltex.width(), gltex.height(), GL_RGBA, GL_UNSIGNED_BYTE, gltex.bits(), mipmaps);
}
}
......
......@@ -412,7 +412,7 @@ public:
void disableAutogenerateMipMaps();
// initialize and set texture data via glTexImage2D
void setData(GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLenum _format, GLenum _type, const GLvoid* _data);
void setData(GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLenum _format, GLenum _type, const GLvoid* _data, bool _mipmaps = false);
// specify storage of texture (OpenGL 4.2)
// use setData with a nullptr instead if 4.2 is not available
......
......@@ -224,8 +224,9 @@ void TextureNode::setTextureDataGL ( GLuint _textureId,
applyTextureParameters(_textureId);
bool mipmaps = mipmapping_globally_active_ && mipmapping_;
// Load the image
if ( mipmapping_globally_active_ && mipmapping_ )
if ( mipmaps )
tex->autogenerateMipMaps();
tex->setData( 0, // level
......@@ -234,7 +235,8 @@ void TextureNode::setTextureDataGL ( GLuint _textureId,
_height, // height (2^m)
_format, // format
_type, // type
_data ); // pointer to pixels
_data, // pointer to pixels
mipmaps); // mipmaps or not
// Unbind until we use it
ACG::GLState::bindTexture(GL_TEXTURE_2D,0);
......
......@@ -207,73 +207,12 @@ CoreWidget( QVector<ViewMode*>& _viewModes,
splitter_ = new QSplitter(Qt::Vertical,toolSplitter_);
stackedWidget_ = new QStackedWidget(splitter_);
OFGLFormat format = OFGLFormat::defaultFormat();
#ifdef ARCH_DARWIN
format.setStereo(false);
#else
format.setStereo(OpenFlipper::Options::stereo());
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
format.setAlphaBufferSize(8);
format.setStencilBufferSize(8);
format.setSamples(OpenFlipper::Options::samples());
#else
format.setAlpha(true);
format.setStencil(true);
format.setSampleBuffers(true);
#endif
// Construct GL context & widget
baseLayout_ = new QtMultiViewLayout;
baseLayout_->setContentsMargins(0,0,0,0);
// ===============================================================================
// Test context capabilities ...
// If we get stereo buffers, we use them .. which might disable multisampling
// If we don't have stereo, we disable it to not interfere with multisampling
// ===============================================================================
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
OFGLWidget* test = new OFGLWidget();
test->setFormat(format);
#else
OFGLWidget* test = new OFGLWidget(format);
#endif
if ( ! test->format().stereo() ) {
// std::cerr << "No stereo ... disabling stereo for real context!" << std::endl;
format.setStereo(false);
}/* else {
std::cerr << "Stereo found ok" << std::endl;
}*/
delete test;
if (OpenFlipper::Options::coreProfile()) {
#if QT_VERSION >= 0x050000
// request the highest OpenGL version
// QT 5 should gracefully provide the next highest available version
QPair<int, int> version = OpenFlipper::Options::glVersion();
format.setVersion(version.first, version.second);
format.setProfile(OFGLFormat::CoreProfile);
#else
format.setProfile(OFGLFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DeprecatedFunctions);
#endif
}
else {
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DeprecatedFunctions);
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 4))
if (OpenFlipper::Options::debug())
format.setOption(format.options() | QSurfaceFormat::DebugContext);
glWidget_ = new OFGLWidget();
glWidget_->setFormat(format);
glWidget_->makeCurrent();
#else
glWidget_ = new OFGLWidget(format, 0);
......
......@@ -100,17 +100,6 @@ void glViewer::startGLDebugLogger()
if (OpenFlipper::Options::debug())
{
delete glDebugLogger_;
//workaround for windows, because the DebugContext flag is discarded by QMainWindow show in core.cc
#ifdef WIN32
QOpenGLContext* ctx = QOpenGLContext::currentContext();
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
ctx->setFormat(format);
ctx->create();
QOffscreenSurface* surface = new QOffscreenSurface();
surface->create();
ctx->makeCurrent(surface);
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
glDebugLogger_ = new QOpenGLDebugLogger(this);
if (glDebugLogger_->initialize())
{
......
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