Search code examples
computational-geometrycgal

CGAL 5.3: Example program to draw a triangulation doesn't work


I've installed the CGAL 5.3 and tried to build and run the example program from this page. That's what I did:

cd $HOME/CGAL-5.3/release/examples/Triangulation_2
cmake -DCMAKE_BUILD_TYPE=Release -DCGAL_DIR=../../lib/cmake/CGAL .
make draw_triangulation_2
./draw_triangulation_2

However, I've got a lot of error messages in the console window - mostly complaints about OpenGL shaders, please see below:

QOpenGLShader::compile(Vertex): 0:3(1): error: `in' qualifier in declaration of `vertex' only valid for function parameters in GLSL 1.10
0:4(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL 1.10
0:9(1): error: `out' qualifier in declaration of `fColor' only valid for function parameters in GLSL 1.10

*** Problematic Vertex shader source code ***
#define lowp
#define mediump
#define highp
#line 1

in highp vec4 vertex;
in highp vec3 color;

uniform highp mat4 mvp_matrix;
uniform highp float point_size;

out highp vec4 fColor;

void main(void)
{
  gl_PointSize = point_size;
  fColor = vec4(color, 1.0);
  gl_Position = mvp_matrix * vertex;
}

***
Compiling vertex source FAILED
QOpenGLShader::link: error: linking with uncompiled/unspecialized shader
linking Program FAILED
QOpenGLShader::compile(Vertex): 0:3(1): error: `in' qualifier in declaration of `vertex' only valid for function parameters in GLSL 1.10
0:4(1): error: `in' qualifier in declaration of `normal' only valid for function parameters in GLSL 1.10
0:5(1): error: `in' qualifier in declaration of `color' only valid for function parameters in GLSL 1.10
0:11(1): error: `out' qualifier in declaration of `fP' only valid for function parameters in GLSL 1.10
0:12(1): error: `out' qualifier in declaration of `fN' only valid for function parameters in GLSL 1.10
0:13(1): error: `out' qualifier in declaration of `fColor' only valid for function parameters in GLSL 1.10

*** Problematic Vertex shader source code ***
#define lowp
#define mediump
#define highp
#line 1

in highp vec4 vertex;
in highp vec3 normal;
in highp vec3 color;

uniform highp mat4 mvp_matrix;
uniform highp mat4 mv_matrix;
uniform highp float point_size;

out highp vec4 fP;
out highp vec3 fN;
out highp vec4 fColor;

void main(void)
{
  fP = mv_matrix * vertex;
  highp mat3 mv_matrix_3;
  mv_matrix_3[0] = mv_matrix[0].xyz;
  mv_matrix_3[1] = mv_matrix[1].xyz;
  mv_matrix_3[2] = mv_matrix[2].xyz;
  fN = mv_matrix_3* normal;
  fColor = vec4(color, 1.0);
  gl_PointSize = point_size;

  gl_Position = mvp_matrix * vertex;
}

***
Compiling vertex source FAILED
QOpenGLShader::link: error: linking with uncompiled/unspecialized shader
linking Program FAILED
QOpenGLShader::link: error: linking with uncompiled/unspecialized shader
QOpenGLShaderProgram::attributeLocation(vertex): shader program is not linked

and so on... The viewer window, however, appeared but was empty:

EmptyViewerWindow

The exactly same sequence of actions with CGAL 5.2.3 has given me a correct window with the triangulation and no error messages - so the OpenGL and Qt5 installations on my box look correct. The transition from the CGAL 5.2.3 to the CGAL 5.3 might be a culprit (???).

How to overcome this?

(I'm on Ubuntu 20.04.3 LTS, with standard kernel 5.11.0-27, and all the standard versions of OpenGL and Qt5)

UPDATE. I've opened an issue on the CGAL bug tracker.


Solution

  • I'm answering my own question. According to CGAL developers it's a bug in the Qt5-based visualization code, and there is no way to overcome it directly. The bug has been already fixed in the code repository, so the fix will be included in the next CGAL release.