diff --git a/Apps/SandBox/wallPaper.cpp b/Apps/SandBox/wallPaper.cpp index b16ed79851790ba30c73a731065903cf98899b9a..59f23ed60ee72daa710a33fca9ab8d37cb6f396c 100644 --- a/Apps/SandBox/wallPaper.cpp +++ b/Apps/SandBox/wallPaper.cpp @@ -77,6 +77,8 @@ void MyQT::cb_initGL() glEnable(GL_TEXTURE_2D); + std::cout << Utils::GLSLShader::MAJOR_OGL_CORE << " / "<< Utils::GLSLShader::MINOR_OGL_CORE << std::endl; + std::cout << glGetString(GL_VERSION)<< std::endl; } void MyQT::cb_redraw() diff --git a/CGoGN/include/Utils/Qt/qthistodraw.h b/CGoGN/include/Algo/Histogram/qthistodraw.h similarity index 100% rename from CGoGN/include/Utils/Qt/qthistodraw.h rename to CGoGN/include/Algo/Histogram/qthistodraw.h diff --git a/CGoGN/include/Utils/Qt/qtQGLV_glw.h b/CGoGN/include/Utils/Qt/qtQGLV_glw.h index 5e5403d2c84e6da8d3c7a52dda8cec177d1e4d93..9bae3b46d43f699ce5c7a8a75bb12ade986c36f1 100644 --- a/CGoGN/include/Utils/Qt/qtQGLV_glw.h +++ b/CGoGN/include/Utils/Qt/qtQGLV_glw.h @@ -74,7 +74,7 @@ protected: int m_current_button; public: - QGLView(SimpleQGLV* ptr, QGLFormat& format, QWidget *parent = 0); + QGLView(SimpleQGLV* ptr, QWidget *parent = 0); ~QGLView(); void setObjectBB(float* bbmin, float* bbmax); diff --git a/CGoGN/include/Utils/Shaders/shaderCustomTex.frag b/CGoGN/include/Utils/Shaders/shaderCustomTex.frag index 145e8c6dac5125968c49228d7a704e922aef75e1..7924b6ed05de771cc5c5de49f9c3b77db484d06b 100644 --- a/CGoGN/include/Utils/Shaders/shaderCustomTex.frag +++ b/CGoGN/include/Utils/Shaders/shaderCustomTex.frag @@ -8,6 +8,6 @@ uniform vec4 ambient; FRAG_OUT_DEF; void main() { - gl_FragData[0] = ambient*texture2D(textureUnit,fragTexCoord); + gl_FragData[0] = ambient*TEXTURE2D(textureUnit,fragTexCoord); gl_FragData[1] = vec4( 0.5*normalize(N)+vec3(0.5), 1.0 ); -} \ No newline at end of file +} diff --git a/CGoGN/include/Utils/Shaders/shaderPhongTexture.frag b/CGoGN/include/Utils/Shaders/shaderPhongTexture.frag index dbdbc1850a11ca281439b37356325304c16a36fc..b9eb547395385d4bbd731ed7a595986fc0196081 100644 --- a/CGoGN/include/Utils/Shaders/shaderPhongTexture.frag +++ b/CGoGN/include/Utils/Shaders/shaderPhongTexture.frag @@ -18,7 +18,7 @@ void main() vec3 L = normalize (LightDir); float lambertTerm = dot(N,L); - vec4 finalColor = ambientCoef * texture2D(textureUnit,texCoord); + vec4 finalColor = ambientCoef * TEXTURE2D(textureUnit,texCoord); #ifdef DOUBLE_SIDED if (lambertTerm < 0.0) @@ -32,7 +32,7 @@ void main() vec3 E = normalize(EyeVector); vec3 R = reflect(-L, N); float specular = pow( max(dot(R, E), 0.0), shininess ); - vec3 diffuse = (1.0 - ambientCoef) * texture2D(textureUnit,texCoord).rgb; + vec3 diffuse = (1.0 - ambientCoef) * TEXTURE2D(textureUnit,texCoord).rgb; finalColor += vec4(diffuse*lambertTerm,0.0) + materialSpecular*specular; } FRAG_OUT=finalColor; diff --git a/CGoGN/include/Utils/Shaders/shaderSimpleTexture.frag b/CGoGN/include/Utils/Shaders/shaderSimpleTexture.frag index a595a9002dd97eccb3c90f4382775a37ba235771..e5cdc04c779d71e1cc26ab25702df995f3fc98f8 100644 --- a/CGoGN/include/Utils/Shaders/shaderSimpleTexture.frag +++ b/CGoGN/include/Utils/Shaders/shaderSimpleTexture.frag @@ -6,5 +6,5 @@ uniform sampler2D textureUnit; FRAG_OUT_DEF; void main() { - FRAG_OUT=texture2D(textureUnit,texCoord); -} \ No newline at end of file + FRAG_OUT=TEXTURE2D(textureUnit,texCoord); +} diff --git a/CGoGN/include/Utils/Shaders/shaderTextureDepth.frag b/CGoGN/include/Utils/Shaders/shaderTextureDepth.frag index 23ef74aedc2ef7d117a05741e43d776f02f3cc61..b7c61436adf955d8028723b4103dbd0d24ec4bdf 100644 --- a/CGoGN/include/Utils/Shaders/shaderTextureDepth.frag +++ b/CGoGN/include/Utils/Shaders/shaderTextureDepth.frag @@ -7,6 +7,6 @@ uniform sampler2D textureDepthUnit; FRAG_OUT_DEF; void main() { - gl_FragDepth = texture2D(textureDepthUnit,texCoord).r; - FRAG_OUT = texture2D(textureUnit,texCoord); -} \ No newline at end of file + gl_FragDepth = TEXTURE2D(textureDepthUnit,texCoord).r; + FRAG_OUT = TEXTURE2D(textureUnit,texCoord); +} diff --git a/CGoGN/include/Utils/Shaders/shaderTextureMask.frag b/CGoGN/include/Utils/Shaders/shaderTextureMask.frag index d9ecb8c3586dd1a1a02e5561c06cf777666f486d..e4a7191b1eb116f6fdc4575ebd40c74ca93f229d 100644 --- a/CGoGN/include/Utils/Shaders/shaderTextureMask.frag +++ b/CGoGN/include/Utils/Shaders/shaderTextureMask.frag @@ -7,8 +7,8 @@ uniform sampler2D textureUnitMask; FRAG_OUT_DEF; void main() { - float m = texture2D(textureUnitMask,texCoord).r; + float m = TEXTURE2D(textureUnitMask,texCoord).r; if (m < 0.5) discard; - FRAG_OUT=texture2D(textureUnit,texCoord)*m; + FRAG_OUT=TEXTURE2D(textureUnit,texCoord)*m; } diff --git a/CGoGN/include/Utils/Shaders/shaderWallPaper.frag b/CGoGN/include/Utils/Shaders/shaderWallPaper.frag index 649e6b07c56b466163cf12260e5b4f40417e572d..042daa6103c313c8e5f4ad4e16087e58069209c4 100644 --- a/CGoGN/include/Utils/Shaders/shaderWallPaper.frag +++ b/CGoGN/include/Utils/Shaders/shaderWallPaper.frag @@ -6,5 +6,5 @@ uniform sampler2D textureUnit; FRAG_OUT_DEF; void main() { - FRAG_OUT=texture2D(textureUnit,texCoord); + FRAG_OUT=TEXTURE2D(textureUnit,texCoord); } diff --git a/CGoGN/include/Utils/text3d.frag b/CGoGN/include/Utils/text3d.frag index 88b4fa26093a68fb27c65b6659f8c79c2dd6e632..72e86309bd2876462876e35e00ec2cb23ceeb40a 100644 --- a/CGoGN/include/Utils/text3d.frag +++ b/CGoGN/include/Utils/text3d.frag @@ -6,5 +6,5 @@ uniform vec4 color; FRAG_OUT_DEF; void main (void) { - float lum = texture2D(FontTexture, tex_coord).s;; + float lum = TEXTURE2D(FontTexture, tex_coord).s;; // no } because it is added in the shader class code (with other things) diff --git a/CGoGN/src/Utils/Qt/qthistodraw.cpp b/CGoGN/src/Algo/Histogram/qthistodraw.cpp similarity index 100% rename from CGoGN/src/Utils/Qt/qthistodraw.cpp rename to CGoGN/src/Algo/Histogram/qthistodraw.cpp diff --git a/CGoGN/src/Utils/GLSLShader.cpp b/CGoGN/src/Utils/GLSLShader.cpp index 4c975adcd82e4f9858cb2f536151614de0d85431..43c8bfdd255fc8e74c4e0f56f8cc4c0ac845b63b 100644 --- a/CGoGN/src/Utils/GLSLShader.cpp +++ b/CGoGN/src/Utils/GLSLShader.cpp @@ -59,7 +59,9 @@ std::string GLSLShader::DEFINES_GL2=\ "#define VARYING_FRAG varying\n" "#define FRAG_OUT_DEF float pipo_FRAGDEF\n" "#define FRAG_OUT gl_FragColor\n" -"#define INVARIANT_POS float pipo_INVARIANT\n"; +"#define INVARIANT_POS float pipo_INVARIANT\n" +"#define TEXTURE2D texture2D\n" +; std::string GLSLShader::DEFINES_GL3=\ @@ -70,7 +72,8 @@ std::string GLSLShader::DEFINES_GL3=\ "#define VARYING_FRAG in\n" "#define FRAG_OUT_DEF out vec4 outFragColor\n" "#define FRAG_OUT outFragColor\n" -"#define INVARIANT_POS invariant gl_Position\n"; +"#define INVARIANT_POS invariant gl_Position\n" +"#define TEXTURE2D texture\n"; std::string* GLSLShader::DEFINES_GL = NULL; @@ -98,7 +101,7 @@ GLSLShader::GLSLShader() : *m_uniMat_Normal = -1; if (DEFINES_GL == NULL) - DEFINES_GL = &DEFINES_GL2; + setCurrentOGLVersion(MAJOR_OGL_CORE,MINOR_OGL_CORE); m_nbMaxVertices = 16; diff --git a/CGoGN/src/Utils/Qt/qtQGLV.cpp b/CGoGN/src/Utils/Qt/qtQGLV.cpp index a798f90815336664a08be32385b40e6d4e39f175..a038843a39a2ea25aea66dd17f02f0eff86c1851 100644 --- a/CGoGN/src/Utils/Qt/qtQGLV.cpp +++ b/CGoGN/src/Utils/Qt/qtQGLV.cpp @@ -56,16 +56,14 @@ SimpleQGLV::SimpleQGLV() : QGLFormat format; if (GLSLShader::CURRENT_OGL_VERSION >= 3) { - format.setProfile(QGLFormat::CoreProfile); - format.setVersion(GLSLShader::MAJOR_OGL_CORE, GLSLShader::MINOR_OGL_CORE); - format.setDepth(true); - format.setDepthBufferSize(24); - format.setDoubleBuffer(true); + QGLFormat glFormat; + glFormat.setVersion( Utils::GLSLShader::MAJOR_OGL_CORE, Utils::GLSLShader::MINOR_OGL_CORE); + glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0 + glFormat.setSampleBuffers( true ); + QGLFormat::setDefaultFormat(glFormat); } - else - format = QGLFormat::defaultFormat(); - m_qglWidget = new QGLView(this,format); + m_qglWidget = new QGLView(this); setCentralWidget(m_qglWidget); setWindowTitle(tr("CGoGN")); @@ -143,7 +141,7 @@ SimpleQGLV::SimpleQGLV(const SimpleQGLV& sqt): m_transfo_matrix(m_mat.m_matrices[2]) { QGLFormat format = sqt.m_qglWidget->format(); - m_qglWidget = new QGLView(this,format); + m_qglWidget = new QGLView(this); setCentralWidget(m_qglWidget); @@ -172,8 +170,7 @@ SimpleQGLV::~SimpleQGLV() void SimpleQGLV::operator=(const SimpleQGLV& sqt) { - QGLFormat format = sqt.m_qglWidget->format(); - m_qglWidget = new QGLView(this,format); + m_qglWidget = new QGLView(this); setCentralWidget(m_qglWidget) ; diff --git a/CGoGN/src/Utils/Qt/qtQGLV_glw.cpp b/CGoGN/src/Utils/Qt/qtQGLV_glw.cpp index e4f62962655c43dc9f85b8cd91834746350f4b5c..2b895c4a564f3976c533fbf2285b29c2d875765d 100644 --- a/CGoGN/src/Utils/Qt/qtQGLV_glw.cpp +++ b/CGoGN/src/Utils/Qt/qtQGLV_glw.cpp @@ -44,8 +44,8 @@ namespace QT { -QGLView::QGLView(SimpleQGLV* ptr, QGLFormat& format, QWidget *parent): - QGLViewer(format,parent), +QGLView::QGLView(SimpleQGLV* ptr, QWidget *parent): + QGLViewer(parent), m_sqgl(ptr),m_state_modifier(0) { } diff --git a/CGoGN/src/Utils/Qt/qtSimple.cpp b/CGoGN/src/Utils/Qt/qtSimple.cpp index 730c305dfcd5988e47042f86c119df73d176edd1..c8027cff00772692d8a12c3a900ff01eb36d68ae 100644 --- a/CGoGN/src/Utils/Qt/qtSimple.cpp +++ b/CGoGN/src/Utils/Qt/qtSimple.cpp @@ -56,17 +56,13 @@ SimpleQT::SimpleQT() : { if (GLSLShader::CURRENT_OGL_VERSION >= 3) { - QGLFormat format; - format.setProfile(QGLFormat::CoreProfile); - format.setVersion(GLSLShader::MAJOR_OGL_CORE, GLSLShader::MINOR_OGL_CORE); - format.setDepth(true); -// format.setDepthBufferSize(24); - format.setDoubleBuffer(true); - - m_glWidget = new GLWidget(this,format); + QGLFormat glFormat; + glFormat.setVersion( Utils::GLSLShader::MAJOR_OGL_CORE, Utils::GLSLShader::MINOR_OGL_CORE); + glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0 + glFormat.setSampleBuffers( true ); + QGLFormat::setDefaultFormat(glFormat); } - else - m_glWidget = new GLWidget(this); + m_glWidget = new GLWidget(this); setCentralWidget(m_glWidget); diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fb1f3dfb3a644184cc0cfaf89f1e69923354a6a..72770df3cc8cfa315265a246e35ecbc7270766b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,7 @@ LIST(APPEND CGoGN_DEFS -DGLM_FORCE_RADIANS) LIST(APPEND CGoGN_DEFS -DCGOGN_ASSERT_BOOL=${CGoGN_ASSERT_ACTIVED}) IF(CGoGN_USE_OGL_CORE_PROFILE) - LIST(APPEND CGoGN_DEFS -DCGoGN_USE_OGL_CORE_PROFILE=1) + LIST(APPEND CGoGN_DEFS -DCGOGN_USE_OGL_CORE_PROFILE=1) ENDIF() LIST(APPEND CGoGN_DEFS -DSHADERPATH=\"${CGoGN_ROOT_DIR}/lib/Shaders/\") diff --git a/SCHNApps/include/view.h b/SCHNApps/include/view.h index 350b98f0f984bea37fdf538656ff7daf148e731d..704f1d27e2349c86a44ba1868042e756e06b0ee0 100644 --- a/SCHNApps/include/view.h +++ b/SCHNApps/include/view.h @@ -40,8 +40,8 @@ class SCHNAPPS_API View : public QGLViewer public: static unsigned int viewCount; - View(const QString& name, SCHNApps* s, QGLFormat& format); - View(const QString& name, SCHNApps* s, QGLFormat& format, const QGLWidget* shareWidget); + View(const QString& name, SCHNApps* s); + View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget); ~View(); const QString& getName() const { return m_name; } diff --git a/SCHNApps/src/schnapps.cpp b/SCHNApps/src/schnapps.cpp index 57559498ee91939cc8ba5771e9180d5a38c4ee88..23231169830152641dc53838f1d3ed71d84899fa 100644 --- a/SCHNApps/src/schnapps.cpp +++ b/SCHNApps/src/schnapps.cpp @@ -44,12 +44,6 @@ SCHNApps::SCHNApps(const QString& appPath, PythonQtObjectPtr& pythonContext, Pyt { GenericMap::initAllStatics(&m_sp); -#ifdef CGoGN_USE_OGL_CORE_PROFILE - CGoGN::Utils::GLSLShader::setCurrentOGLVersion(3); -#else - CGoGN::Utils::GLSLShader::setCurrentOGLVersion(2); -#endif - this->setupUi(this); // create & setup control dock @@ -116,6 +110,15 @@ SCHNApps::SCHNApps(const QString& appPath, PythonQtObjectPtr& pythonContext, Pyt b_rootSplitterInitialized = false; m_centralLayout->addWidget(m_rootSplitter); + if (Utils::GLSLShader::CURRENT_OGL_VERSION >= 3) + { + QGLFormat glFormat; + glFormat.setVersion( Utils::GLSLShader::MAJOR_OGL_CORE, Utils::GLSLShader::MINOR_OGL_CORE); + glFormat.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0 + glFormat.setSampleBuffers( true ); + QGLFormat::setDefaultFormat(glFormat); + } + m_firstView = addView(); setSelectedView(m_firstView); m_rootSplitter->addWidget(m_firstView); @@ -196,27 +199,7 @@ View* SCHNApps::addView(const QString& name) if (m_views.contains(name)) return NULL; - QGLFormat format; - if (Utils::GLSLShader::CURRENT_OGL_VERSION >= 3) - { - format.setProfile(QGLFormat::CoreProfile); - format.setVersion(Utils::GLSLShader::MAJOR_OGL_CORE, Utils::GLSLShader::MINOR_OGL_CORE); - format.setDepth(true); - format.setDoubleBuffer(true); - format.setBlueBufferSize(8); - std::cout << "CORE_PROFILE GL"<< std::endl; - } - else - { - format = QGLFormat::defaultFormat(); - std::cout << "DEFAULT GL"<< std::endl; - } - - View* view = NULL; - if(m_firstView == NULL) - view = new View(name, this, format); - else - view = new View(name, this, format, m_firstView); + View* view = new View(name, this, m_firstView); m_views.insert(name, view); diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp index b220126f3812a4a5561eb2fae8a206c775f83fcc..1af88fbfcea271d4c7a647c028c1e6fa7f40a713 100644 --- a/SCHNApps/src/view.cpp +++ b/SCHNApps/src/view.cpp @@ -21,9 +21,8 @@ namespace SCHNApps { unsigned int View::viewCount = 0; - -View::View(const QString& name, SCHNApps* s, QGLFormat& format) : - QGLViewer(format, NULL, NULL), +View::View(const QString& name, SCHNApps* s) : + QGLViewer(), b_updatingUI(false), m_name(name), m_schnapps(s), @@ -83,8 +82,8 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) : connect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(closeDialogs())); } -View::View(const QString& name, SCHNApps* s, QGLFormat& format, const QGLWidget* shareWidget) : - QGLViewer(format, NULL, shareWidget), +View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) : + QGLViewer( NULL, shareWidget), b_updatingUI(false), m_name(name), m_schnapps(s), @@ -354,11 +353,8 @@ void View::init() glewExperimental = GL_TRUE; // needed for GL Core Profile 3.3 glewInit(); -// int major = 0; -// int minor = 0; -// glGetIntegerv(GL_MAJOR_VERSION, &major); -// glGetIntegerv(GL_MINOR_VERSION, &minor); -// std::cout << this->getName().toStdString() << "is using GL "<< major <<"."<< minor << std::endl; + std::cout << "using " << glGetString(GL_VERSION) << std::endl; + qglviewer::Camera* c = this->camera(); this->setCamera(m_currentCamera); diff --git a/ThirdParty/PythonQt/CMakeLists.txt b/ThirdParty/PythonQt/CMakeLists.txt index e6b30fef6ccf6f0e3eaed56e88ad6949326bfd07..ade4f5711a861c5acad6d794a342eb17fc43dbe9 100644 --- a/ThirdParty/PythonQt/CMakeLists.txt +++ b/ThirdParty/PythonQt/CMakeLists.txt @@ -16,7 +16,7 @@ project(PythonQt) find_package(PythonLibs 2.7 REQUIRED) include_directories("${PYTHON_INCLUDE_DIR}") add_definitions("-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK") -FILE(WRITE ${CGoGN_ROOT_DIR}/include/python_version.h ${PYTHONLIBS_VERSION_STRING}) + #----------------------------------------------------------------------------- # Build options diff --git a/ThirdParty/libQGLViewer/QGLViewer/qglviewer.cpp b/ThirdParty/libQGLViewer/QGLViewer/qglviewer.cpp index 7e38de8d231c6a96905fcce85923ae22fa0433aa..fe5d2b817a2ab065660c1074daf351e6be6fd292 100644 --- a/ThirdParty/libQGLViewer/QGLViewer/qglviewer.cpp +++ b/ThirdParty/libQGLViewer/QGLViewer/qglviewer.cpp @@ -363,8 +363,8 @@ void QGLViewer::postDraw() glEnable(GL_RESCALE_NORMAL); #endif - glDisable(GL_COLOR_MATERIAL); - qglColor(foregroundColor()); +// glDisable(GL_COLOR_MATERIAL); +// qglColor(foregroundColor()); if (cameraIsEdited()) camera()->drawAllPaths();