mirror of https://github.com/CGAL/cgal
Merge pull request #5336 from maxGimeno/GraphicsView-Use_opengl_4_1_context-maxGImeno
Graphics_view: Upgrade glsl version in basic_viewer_shaders
This commit is contained in:
commit
c5ba414c72
|
|
@ -19,18 +19,16 @@
|
|||
#include <QApplication>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
QApplication app(argc, argv);
|
||||
app.setOrganizationDomain("inria.fr");
|
||||
app.setOrganizationName("INRIA");
|
||||
app.setApplicationName("AABB tree demo");
|
||||
//for windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
app.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
|
||||
// Import resources from libCGALQt (Qt5).
|
||||
CGAL_QT_INIT_RESOURCES;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
m_pViewer->makeCurrent();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ void Scene::compile_shaders()
|
|||
//Vertex source code
|
||||
const char vertex_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 f_matrix;\n"
|
||||
"void main(void)\n"
|
||||
|
|
@ -103,10 +103,11 @@ void Scene::compile_shaders()
|
|||
//Vertex source code
|
||||
const char fragment_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"#version 150 \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = color; \n"
|
||||
"out_color = color; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -139,26 +140,27 @@ void Scene::compile_shaders()
|
|||
//Vertex source code
|
||||
const char tex_vertex_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec2 tex_coord; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec2 tex_coord; \n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 f_matrix;\n"
|
||||
"varying highp vec2 texc;\n"
|
||||
"out highp vec2 texc;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" gl_Position = mvp_matrix * f_matrix * vertex;\n"
|
||||
" texc = tex_coord;\n"
|
||||
" texc = tex_coord;\n"
|
||||
"}"
|
||||
};
|
||||
//Vertex source code
|
||||
const char tex_fragment_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"uniform sampler2D texture;\n"
|
||||
"varying highp vec2 texc;\n"
|
||||
"#version 150 \n"
|
||||
"uniform sampler2D s_texture;\n"
|
||||
"in highp vec2 texc;\n"
|
||||
"out highp vec4 out_color; \n"
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = texture2D(texture, texc.st);\n"
|
||||
"out_color = vec4(texture(s_texture, texc));\n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -1319,12 +1321,8 @@ void Scene::deactivate_cutting_plane()
|
|||
}
|
||||
void Scene::initGL()
|
||||
{
|
||||
gl = new QOpenGLFunctions_2_1();
|
||||
if(!gl->initializeOpenGLFunctions())
|
||||
{
|
||||
qFatal("ERROR : OpenGL Functions not initialized. Check your OpenGL Verison (should be >=3.3)");
|
||||
exit(1);
|
||||
}
|
||||
gl = new QOpenGLFunctions();
|
||||
gl->initializeOpenGLFunctions();
|
||||
|
||||
gl->glGenTextures(1, &textureId);
|
||||
compile_shaders();
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
private:
|
||||
// member data
|
||||
QOpenGLFunctions_2_1 *gl;
|
||||
QOpenGLFunctions *gl;
|
||||
Bbox m_bbox;
|
||||
Polyhedron *m_pPolyhedron;
|
||||
std::list<Point> m_points;
|
||||
|
|
|
|||
|
|
@ -5,18 +5,16 @@
|
|||
|
||||
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication application(argc,argv);
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
|
||||
QApplication application(argc,argv);
|
||||
application.setOrganizationDomain("geometryfactory.com");
|
||||
application.setOrganizationName("GeometryFactory");
|
||||
application.setApplicationName("Alpha Shape Reconstruction");
|
||||
//for Windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
application.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
|
||||
// Import resources from libCGALQt (Qt5).
|
||||
// See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE
|
||||
|
|
|
|||
|
|
@ -29,14 +29,14 @@ void Viewer::compile_shaders()
|
|||
//Vertex source code
|
||||
const char vertex_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec3 normal;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec3 normal;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 mv_matrix; \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"out highp vec4 fP; \n"
|
||||
"out highp vec3 fN; \n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
|
|
@ -47,15 +47,16 @@ void Viewer::compile_shaders()
|
|||
//Fragment source code
|
||||
const char fragment_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 fP; \n"
|
||||
"in highp vec3 fN; \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"uniform highp vec4 light_pos; \n"
|
||||
"uniform highp vec4 light_diff; \n"
|
||||
"uniform highp vec4 light_spec; \n"
|
||||
"uniform highp vec4 light_amb; \n"
|
||||
"uniform float spec_power ; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
|
||||
|
|
@ -70,7 +71,7 @@ void Viewer::compile_shaders()
|
|||
" highp vec4 diffuse = abs(dot(N,L)) * light_diff * color; \n"
|
||||
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
|
||||
|
||||
"gl_FragColor = light_amb*color + diffuse + specular ; \n"
|
||||
"out_color = light_amb*color + diffuse + specular ; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -105,8 +106,8 @@ rendering_program.bind();
|
|||
//Vertex source code
|
||||
const char vertex_source_points[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp float point_size;\n"
|
||||
|
|
@ -119,11 +120,12 @@ const char vertex_source_points[] =
|
|||
//Vertex source code
|
||||
const char fragment_source_points[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"#version 150 \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = color; \n"
|
||||
"out_color = color; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public:
|
|||
Viewer(QWidget* parent);
|
||||
~Viewer()
|
||||
{
|
||||
makeCurrent();
|
||||
buffers[0].destroy();
|
||||
buffers[1].destroy();
|
||||
buffers[2].destroy();
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
#include "Viewer.h"
|
||||
#include <qapplication.h>
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Read command lines arguments.
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
QApplication application(argc,argv);
|
||||
|
||||
// Instantiate the viewer.
|
||||
Viewer viewer;
|
||||
//for Windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
application.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
viewer.setWindowTitle("Intersection points of randomly generated circles.");
|
||||
|
||||
// Make the viewer window visible on screen.
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@ Viewer::Viewer(QWidget* parent )
|
|||
{
|
||||
extension_is_found = false;
|
||||
}
|
||||
Viewer::~Viewer()
|
||||
{
|
||||
makeCurrent();
|
||||
for(int i=0; i<3; ++i)
|
||||
vao[i].destroy();
|
||||
for(int i=0; i<9; ++i)
|
||||
buffers[i].destroy();
|
||||
}
|
||||
|
||||
void Viewer::compile_shaders()
|
||||
{
|
||||
|
|
@ -32,16 +40,16 @@ void Viewer::compile_shaders()
|
|||
//Vertex source code
|
||||
const char vertex_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec3 normal;\n"
|
||||
"attribute highp vec4 center;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec3 normal;\n"
|
||||
"in highp vec4 center;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 mv_matrix; \n"
|
||||
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"out highp vec4 fP; \n"
|
||||
"out highp vec3 fN; \n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
|
|
@ -52,15 +60,16 @@ void Viewer::compile_shaders()
|
|||
//Vertex source code
|
||||
const char fragment_source[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 fP; \n"
|
||||
"in highp vec3 fN; \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"uniform highp vec4 light_pos; \n"
|
||||
"uniform highp vec4 light_diff; \n"
|
||||
"uniform highp vec4 light_spec; \n"
|
||||
"uniform highp vec4 light_amb; \n"
|
||||
"uniform float spec_power ; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
|
||||
|
|
@ -75,7 +84,7 @@ void Viewer::compile_shaders()
|
|||
" highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n"
|
||||
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
|
||||
|
||||
"gl_FragColor = light_amb*color + diffuse ; \n"
|
||||
"out_color = light_amb*color + diffuse ; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -111,8 +120,8 @@ void Viewer::compile_shaders()
|
|||
//Vertex source code
|
||||
const char vertex_source_no_ext[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
|
|
@ -123,10 +132,11 @@ void Viewer::compile_shaders()
|
|||
//Vertex source code
|
||||
const char fragment_source_no_ext[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"#version 150 \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = color; \n"
|
||||
"out_color = color; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class Viewer : public CGAL::QGLViewer
|
|||
{
|
||||
public:
|
||||
Viewer(QWidget* parent = 0);
|
||||
~Viewer();
|
||||
GLuint dl_nb;
|
||||
protected :
|
||||
virtual void draw();
|
||||
|
|
|
|||
|
|
@ -54,21 +54,20 @@
|
|||
|
||||
namespace CGAL
|
||||
{
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
const char vertex_source_color[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec3 normal;\n"
|
||||
"attribute highp vec3 color;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec3 normal;\n"
|
||||
"in highp vec3 color;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 mv_matrix; \n"
|
||||
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"varying highp vec4 fColor; \n"
|
||||
"out highp vec4 fP; \n"
|
||||
"out highp vec3 fN; \n"
|
||||
"out highp vec4 fColor; \n"
|
||||
|
||||
"uniform highp float point_size; \n"
|
||||
"void main(void)\n"
|
||||
|
|
@ -83,15 +82,16 @@ const char vertex_source_color[] =
|
|||
|
||||
const char fragment_source_color[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"varying highp vec4 fColor; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 fP; \n"
|
||||
"in highp vec3 fN; \n"
|
||||
"in highp vec4 fColor; \n"
|
||||
"uniform highp vec4 light_pos; \n"
|
||||
"uniform highp vec4 light_diff; \n"
|
||||
"uniform highp vec4 light_spec; \n"
|
||||
"uniform highp vec4 light_amb; \n"
|
||||
"uniform float spec_power ; \n"
|
||||
"out vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
" highp vec3 L = light_pos.xyz - fP.xyz; \n"
|
||||
|
|
@ -104,18 +104,18 @@ const char fragment_source_color[] =
|
|||
" highp vec3 R = reflect(-L, N); \n"
|
||||
" highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n"
|
||||
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
|
||||
" gl_FragColor = light_amb*fColor + diffuse ; \n"
|
||||
" out_color = light_amb*fColor + diffuse ; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
||||
const char vertex_source_p_l[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec3 color;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec3 color;\n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"varying highp vec4 fColor; \n"
|
||||
"out highp vec4 fColor; \n"
|
||||
"uniform highp float point_size; \n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
|
|
@ -127,10 +127,11 @@ const char vertex_source_p_l[] =
|
|||
|
||||
const char fragment_source_p_l[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"varying highp vec4 fColor; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 fColor; \n"
|
||||
"out vec4 out_color; \n"
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = fColor; \n"
|
||||
"out_color = fColor; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -358,6 +359,7 @@ public:
|
|||
|
||||
~Basic_viewer_qt()
|
||||
{
|
||||
makeCurrent();
|
||||
for (unsigned int i=0; i<NB_VBO_BUFFERS; ++i)
|
||||
buffers[i].destroy();
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) 2021 GeometryFactory Sarl (France).
|
||||
// All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org).
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
|
||||
//
|
||||
//
|
||||
// Author(s) : Maxime Gimeno
|
||||
|
||||
#ifndef CGAL_QT_CONTEXT_INITIALIZATION_H
|
||||
#define CGAL_QT_CONTEXT_INITIALIZATION_H
|
||||
|
||||
#include <CGAL/license/GraphicsView.h>
|
||||
|
||||
|
||||
#include <QSurfaceFormat>
|
||||
#include <QCoreApplication>
|
||||
namespace CGAL
|
||||
{
|
||||
namespace Qt
|
||||
{
|
||||
inline void init_ogl_context(int major, int minor) {
|
||||
QSurfaceFormat fmt;
|
||||
#ifdef Q_OS_MAC
|
||||
if(major == 4)
|
||||
{
|
||||
fmt.setVersion(4, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
fmt.setVersion(major, minor);
|
||||
}
|
||||
#else
|
||||
fmt.setVersion(major, minor);
|
||||
#endif
|
||||
fmt.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
fmt.setProfile(QSurfaceFormat::CoreProfile);
|
||||
fmt.setOption(QSurfaceFormat::DebugContext);
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
|
||||
//for windows
|
||||
QCoreApplication::setAttribute(::Qt::AA_UseDesktopOpenGL);
|
||||
|
||||
//We set the locale to avoid any trouble with VTK
|
||||
setlocale(LC_ALL, "C");
|
||||
}
|
||||
|
||||
} //end Qt
|
||||
} //end CGAL
|
||||
#endif // CGAL_QT_CONTEXT_INITIALIZATION_H
|
||||
|
|
@ -217,16 +217,6 @@ void CGAL::QGLViewer::initializeGL() {
|
|||
|| QCoreApplication::arguments().contains(QStringLiteral("--old")))
|
||||
|
||||
{
|
||||
format.setDepthBufferSize(24);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(2,0);
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
format.setSamples(0);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
|
||||
needNewContext();
|
||||
qDebug()<<"GL 4.3 context initialization failed. ";
|
||||
is_ogl_4_3 = false;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include <QApplication>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <CGAL/assertions_behaviour.h>
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
// Global random
|
||||
CGAL::Random myrandom;
|
||||
|
|
@ -23,15 +24,12 @@ int main(int argc, char** argv)
|
|||
// std::cout<<"Size of dart: "<<sizeof(LCC::Dart)<<std::endl;
|
||||
CGAL::set_error_behaviour(CGAL::ABORT);
|
||||
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
QApplication application(argc,argv);
|
||||
|
||||
application.setOrganizationDomain("cgal.org");
|
||||
application.setOrganizationName("CNRS and LIRIS' Establishments");
|
||||
application.setApplicationName("3D Linear Cell Complex");
|
||||
//for windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
application.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
|
||||
// Import resources from libCGALQt5
|
||||
// See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <CGAL/Qt/qglviewer.h>
|
||||
#include <QKeyEvent>
|
||||
#include <QOpenGLFunctions_2_1>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
|
@ -43,15 +43,15 @@ typedef Local_kernel::Vector_3 Local_vector;
|
|||
//Vertex source code
|
||||
const char vertex_source_mono[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec3 normal;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec3 normal;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 mv_matrix; \n"
|
||||
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"out highp vec4 fP; \n"
|
||||
"out highp vec3 fN; \n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
|
|
@ -62,17 +62,17 @@ const char vertex_source_mono[] =
|
|||
|
||||
const char vertex_source_color[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"attribute highp vec3 normal;\n"
|
||||
"attribute highp vec3 color;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"in highp vec3 normal;\n"
|
||||
"in highp vec3 color;\n"
|
||||
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 mv_matrix; \n"
|
||||
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"varying highp vec4 fColor; \n"
|
||||
"out highp vec4 fP; \n"
|
||||
"out highp vec3 fN; \n"
|
||||
"out highp vec4 fColor; \n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
|
|
@ -85,15 +85,16 @@ const char vertex_source_color[] =
|
|||
//Vertex source code
|
||||
const char fragment_source_mono[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 fP; \n"
|
||||
"in highp vec3 fN; \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"uniform highp vec4 light_pos; \n"
|
||||
"uniform highp vec4 light_diff; \n"
|
||||
"uniform highp vec4 light_spec; \n"
|
||||
"uniform highp vec4 light_amb; \n"
|
||||
"uniform float spec_power ; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
|
||||
|
|
@ -108,22 +109,23 @@ const char fragment_source_mono[] =
|
|||
" highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * color; \n"
|
||||
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
|
||||
|
||||
"gl_FragColor = light_amb*color + diffuse ; \n"
|
||||
"out_color = light_amb*color + diffuse ; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
||||
const char fragment_source_color[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"varying highp vec4 fColor; \n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 fP; \n"
|
||||
"in highp vec3 fN; \n"
|
||||
"in highp vec4 fColor; \n"
|
||||
"uniform highp vec4 light_pos; \n"
|
||||
"uniform highp vec4 light_diff; \n"
|
||||
"uniform highp vec4 light_spec; \n"
|
||||
"uniform highp vec4 light_amb; \n"
|
||||
"uniform float spec_power ; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
|
||||
"void main(void) { \n"
|
||||
|
||||
|
|
@ -138,7 +140,7 @@ const char fragment_source_color[] =
|
|||
" highp vec4 diffuse = max(dot(N,L), 0.0) * light_diff * fColor; \n"
|
||||
" highp vec4 specular = pow(max(dot(R,V), 0.0), spec_power) * light_spec; \n"
|
||||
|
||||
"gl_FragColor = light_amb*fColor + diffuse ; \n"
|
||||
"out_color = light_amb*fColor + diffuse ; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -146,8 +148,8 @@ const char fragment_source_color[] =
|
|||
//Vertex source code
|
||||
const char vertex_source_p_l[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"attribute highp vec4 vertex;\n"
|
||||
"#version 150 \n"
|
||||
"in highp vec4 vertex;\n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"void main(void)\n"
|
||||
"{\n"
|
||||
|
|
@ -157,10 +159,11 @@ const char vertex_source_p_l[] =
|
|||
//Vertex source code
|
||||
const char fragment_source_p_l[] =
|
||||
{
|
||||
"#version 120 \n"
|
||||
"#version 150 \n"
|
||||
"uniform highp vec4 color; \n"
|
||||
"out highp vec4 out_color; \n"
|
||||
"void main(void) { \n"
|
||||
"gl_FragColor = color; \n"
|
||||
"out_color = color; \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -194,7 +197,7 @@ typename K::Vector_3 compute_normal_of_face(const std::vector<typename K::Point_
|
|||
return (typename K::Construct_scaled_vector_3()(normal, 1.0/nb));
|
||||
}
|
||||
|
||||
class Basic_viewer : public CGAL::QGLViewer, public QOpenGLFunctions_2_1
|
||||
class Basic_viewer : public CGAL::QGLViewer, public QOpenGLFunctions
|
||||
{
|
||||
struct Vertex_info
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
#include <CGAL/Linear_cell_complex_operations.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
|
@ -405,6 +406,7 @@ void draw(const CGAL_LCC_TYPE& alcc,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"lccviewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Nef_3/SNC_iteration.h>
|
||||
#include <CGAL/circulator.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
|
@ -253,6 +254,7 @@ void draw(const CGAL_NEF3_TYPE &anef,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc = 1;
|
||||
const char *argv[2] = {"nef_polyhedron_viewer", "\0"};
|
||||
QApplication app(argc, const_cast<char **>(argv));
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
|
|
@ -260,6 +261,7 @@ void draw(const CGAL_P2T2_TYPE& ap2t2,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"p2t2_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ public:
|
|||
}
|
||||
|
||||
~Scene() {
|
||||
ui->viewer->makeCurrent();
|
||||
for(int i=0; i<24; i++)
|
||||
buffers[i].destroy();
|
||||
for(int i=0; i<12; i++)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
#include "MainWindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(2,1);
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
//w.ui->setupUi(w);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,17 @@
|
|||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication application(argc,argv);
|
||||
|
||||
CGAL::Qt::init_ogl_context(2, 1);
|
||||
|
||||
QApplication application(argc,argv);
|
||||
application.setOrganizationDomain("inria.fr");
|
||||
application.setOrganizationName("INRIA");
|
||||
application.setApplicationName("3D Periodic Lloyd");
|
||||
//for windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
application.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
|
||||
// Import resources from libCGAL (QT5).
|
||||
// See https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public:
|
|||
{}
|
||||
~Viewer()
|
||||
{
|
||||
makeCurrent();
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
buffers[i].destroy();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ void draw(const PS& aps);
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Point_set_3.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
|
|
@ -100,6 +101,7 @@ void draw(const Point_set_3<P, V>& apointset,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"point_set_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void draw(const P& ap);
|
|||
#endif
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Polygon_2.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
|
|
@ -122,6 +122,7 @@ void draw(const CGAL::Polygon_2<T, C>& ap2,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"t2_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void draw(const PH& aph);
|
|||
#endif
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Polygon_with_holes_2.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
|
|
@ -138,6 +138,7 @@ void draw(const CGAL::Polygon_with_holes_2<T, C>& ap2,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"t2_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -380,6 +380,7 @@ Viewer::Viewer(QWidget* parent,
|
|||
|
||||
Viewer::~Viewer()
|
||||
{
|
||||
makeCurrent();
|
||||
QSettings viewer_settings;
|
||||
viewer_settings.setValue("cam_pos",
|
||||
QString("%1,%2,%3")
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include <CGAL/Qt/Basic_viewer_qt.h>
|
||||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/draw_face_graph.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
|
@ -45,6 +45,7 @@ void draw(const CGAL_POLY_TYPE& apoly,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=2;
|
||||
const char* argv[2]={"polyhedron_viewer","--old"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
m_pViewer->makeCurrent();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,12 @@
|
|||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
#include <CGAL/Qt/resources.h>
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(2, 1);
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setOrganizationDomain("inria.fr");
|
||||
app.setOrganizationName("INRIA");
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ Scene::Scene()
|
|||
|
||||
Scene::~Scene()
|
||||
{
|
||||
|
||||
delete m_pPolyhedron;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ void draw(const SM& asm);
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/draw_face_graph.h>
|
||||
namespace CGAL
|
||||
|
|
@ -51,6 +52,7 @@ void draw(const Surface_mesh<K>& amesh,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"surface_mesh_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
|
@ -409,6 +410,7 @@ void draw(const Mesh& alcc,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"lccviewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Triangulation_2.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
|
|
@ -144,6 +145,7 @@ void draw(const CGAL_T2_TYPE& at2,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"t2_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -13,18 +13,17 @@
|
|||
|
||||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(2, 1);
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
app.setOrganizationDomain("inria.fr");
|
||||
app.setOrganizationName("INRIA");
|
||||
app.setApplicationName("3D Triangulation Demo");
|
||||
//for windows
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
|
||||
app.setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
#endif
|
||||
|
||||
MainWindow mw;
|
||||
mw.show();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Triangulation_3.h>
|
||||
#include <CGAL/Random.h>
|
||||
|
||||
|
|
@ -150,6 +151,7 @@ void draw(const CGAL_T3_TYPE& at3,
|
|||
|
||||
if (!cgal_test_suite)
|
||||
{
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc=1;
|
||||
const char* argv[2]={"t3_viewer","\0"};
|
||||
QApplication app(argc,const_cast<char**>(argv));
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#ifdef CGAL_USE_BASIC_VIEWER
|
||||
|
||||
#include <CGAL/Qt/init_ogl_context.h>
|
||||
#include <CGAL/Random.h>
|
||||
#include <CGAL/Triangulation_utils_2.h>
|
||||
#include <CGAL/Voronoi_diagram_2/Face.h>
|
||||
|
|
@ -316,6 +317,7 @@ void draw(const CGAL_VORONOI_TYPE &av2,
|
|||
#endif
|
||||
|
||||
if (!cgal_test_suite) {
|
||||
CGAL::Qt::init_ogl_context(4,3);
|
||||
int argc = 1;
|
||||
const char *argv[2] = {"voronoi_2_viewer", "\0"};
|
||||
QApplication app(argc, const_cast<char **>(argv));
|
||||
|
|
|
|||
Loading…
Reference in New Issue