Fix demos

This commit is contained in:
Maxime Gimeno 2021-01-08 11:40:09 +01:00
parent 2a212bb2a8
commit 17e83d573d
13 changed files with 163 additions and 99 deletions

View File

@ -23,14 +23,24 @@
int main(int argc, char **argv)
{
QSurfaceFormat fmt;
#ifdef Q_OS_MAC
fmt.setVersion(4, 1);
#else
fmt.setVersion(4, 3);
#endif
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
//for windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
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;

View File

@ -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"
"#version 150 \n"
"uniform sampler2D texture;\n"
"varying highp vec2 texc;\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 = texture2D(texture, texc.st);\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();

View File

@ -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;

View File

@ -8,15 +8,27 @@
int main(int argc, char** argv)
{
QApplication application(argc,argv);
QSurfaceFormat fmt;
#ifdef Q_OS_MAC
fmt.setVersion(4, 1);
#else
fmt.setVersion(4, 3);
#endif
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
//for Windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
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

View File

@ -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"
};

View File

@ -3,15 +3,25 @@
int main(int argc, char** argv)
{
QSurfaceFormat fmt;
#ifdef Q_OS_MAC
fmt.setVersion(4, 1);
#else
fmt.setVersion(4, 3);
#endif
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
// Read command lines arguments.
//for Windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
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.

View File

@ -32,16 +32,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 +52,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 +76,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 +112,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 +124,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"
};

View File

@ -23,15 +23,15 @@ int main(int argc, char** argv)
// std::cout<<"Size of dart: "<<sizeof(LCC::Dart)<<std::endl;
CGAL::set_error_behaviour(CGAL::ABORT);
//for windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
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

View File

@ -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
{

View File

@ -4,6 +4,12 @@
int main(int argc, char *argv[])
{
QSurfaceFormat fmt;
fmt.setVersion(2, 1);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
QApplication a(argc, argv);
MainWindow w;
//w.ui->setupUi(w);

View File

@ -4,15 +4,20 @@
int main(int argc, char** argv)
{
QSurfaceFormat fmt;
fmt.setVersion(2, 1);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
//for windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
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

View File

@ -21,6 +21,16 @@
int main(int argc, char **argv)
{
QSurfaceFormat fmt;
fmt.setVersion(2, 1);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
QApplication app(argc, argv);
app.setOrganizationDomain("inria.fr");
app.setOrganizationName("INRIA");

View File

@ -16,15 +16,21 @@
int main(int argc, char** argv)
{
QSurfaceFormat fmt;
fmt.setVersion(2, 1);
fmt.setRenderableType(QSurfaceFormat::OpenGL);
fmt.setProfile(QSurfaceFormat::CoreProfile);
fmt.setOption(QSurfaceFormat::DebugContext);
QSurfaceFormat::setDefaultFormat(fmt);
//for windows
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
#endif
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();