697 Commits
Author SHA1 Message Date
Rajdeep Singh e48c71296d Basic_viewer: clip-plane capping
Fills the flat cross-section where the clipping plane cuts a solid, so a
clipped closed solid reads as a slice instead of a hollow shell. For a
volumetric input (a Linear_cell_complex) each volume's cross-section is
filled in that volume's color.

The clipped solid is drawn into the stencil with an even-odd rule and a
quad on the plane is filled where the stencil is odd. Per-volume color
uses a dedicated cap buffer (POS_CAP_FACES) holding each volume's full
closed boundary (shared walls kept, unlike the de-duplicated display
buffer), so each volume is closed on its own; a surface mesh has no
groups and caps grey from the display buffer. The stencil buffer is
requested in init_ogl_context.

Draft: a K key toggles the cap, the cap buffer is built eagerly, and
only the two solid clip modes are capped.
2026-07-11 19:58:52 +05:30
Sebastien Loriot dfac790cff Basic_viewer: anti-aliased edges, filled tube joins, and no per-vertex inverse(u_Mvp) (#9528)
## Description

### Summary of Changes

Improves the edge and vertex rendering of the Basic_viewer, following
the GSoC "Shaders for Basic Viewer" project idea. It rewrites the
wide-edge geometry shader to be more robust, draws the flat edges opaque
(anti-aliased by multisampling), fills the tube-edge joins with spheres
drawn from the edges, makes the on-screen sizing scale-independent,
correct on HiDPI displays, and consistent between the flat and cylinder
modes, fixes the Shift and minus size key, and removes a now-unused
uniform.

### What this changes

**Edge geometry shader**

- Builds the wide-edge quad in clip space instead of using a per-vertex
`inverse(u_Mvp)`. Since NDC = clip.xy / clip.w, a screen-space offset
becomes offset * w in clip space, so the quad vertices are emitted
directly with the correct depth and no matrix inverse. This is
numerically more stable and a little cheaper per edge.
- Removes the dangling `g_Color[]` input.

**Flat edges (opaque, anti-aliased by multisampling)**

- The flat edges are drawn opaque, and 4x framebuffer multisampling
smooths the silhouette, so they stay fully solid at any width and a thin
edge no longer fades toward the background. The earlier version blended
an analytical coverage alpha in the fragment shader, which left a faint
one-pixel border that read as slightly transparent; multisampling does
the anti-aliasing instead and keeps the edge solid.
- The geometry shader emits the exact square-capped edge rectangle, and
the minimum one-pixel half-width clamp keeps a sub-pixel edge solid.
Square caps are kept (see the note below).

**Tube edges (Ctrl+E)**

- The cylinder-edge mode fills the joints where the open tubes meet by
drawing a small sphere at each edge endpoint, in the cylinder color, the
analogue of ParaView's `RenderLinesAsTubes` plus
`RenderPointsAsSpheres`.
- The spheres are drawn from the edges, not from the scene's point set.
Drawing from the point set could place a sphere where no cylinder is: a
2D triangulation's point set includes its infinite vertex, and some
meshes include the endpoint of a zero-length degenerate edge whose
cylinder is invisible but whose sphere still shows, which appeared as a
stray floating mark near a junction. A geometry shader now takes each
edge, skips it when its two endpoints coincide, and emits a sphere at
each endpoint, so a sphere only ever lands where a real tube ends.
- Each endpoint sphere takes that endpoint's color, so the joints match
the cylinders even when the edges are colored individually.
- Known limitation: at very large edge widths the join sphere does not
completely fill the sharp corner where three thick tubes meet, so a thin
sliver of the face can show. At normal sizes it is clean. A better
large-width join is planned on a follow-up branch.

**Sizing**

- Edge width and vertex size are constant screen-pixel sizes,
independent of the scene scale and identical in 2D and 3D, so the
initial size is correct for a mesh at any scale and the +/- step is a
consistent pixel increment. Previously they were derived from the
bounding-box diagonal, which made flat edges sub-pixel on small meshes
and oversized on large ones.
- The cylinder (tube) radius and the sphere-vertex radius follow the
same screen-pixel size as the flat edges and points, using the camera
pixel-to-world ratio (`pixelGLRatio`), so a size-N edge is about N
pixels thick in both flat and tube mode, and a vertex matches between
the point and sphere modes. When zoomed in very close the tube looks
slightly thicker, since it is real 3D geometry while the flat edge is
screen space, but at normal framing they match.

**Size keys**

- Shift and the minus key now decreases the edge and vertex size. The
handlers matched `Qt::Key_Minus`, but on most keyboard layouts Shift and
minus reports `Qt::Key_Underscore`, so decreasing was silently ignored
while Shift and plus (which reports `Key_Plus`) worked. The minus
handlers now also accept `Key_Underscore`, for both the edge size and
the Ctrl vertex size. This was pre-existing in the size-key handling,
not introduced by the shader work.

**HiDPI / thin-edge fix**

- The edge and point sizes are scaled by the device pixel ratio to match
`u_Viewport`, so edges are not drawn too thin on HiDPI displays.
- The geometry shader clamps a minimum half-width, so a very thin edge
keeps a solid one-pixel core instead of fading into the background
color.

**Cleanup**

- Removes the now-unused `u_IsOrthographic` uniform and its setters (the
orthographic special-case was dropped when the sizes became constant
pixels).

### Testing

Tested on a hexahedron (3D), a 2D Delaunay triangulation, and a dense
surface mesh, at unit scale and at about 500-unit scale, with flat edges
and with tube edges (Ctrl+E), and at a simulated 2x HiDPI display. Edges
and vertices render with the correct, consistent size and color in all
cases, including after pressing +/- and Shift and minus to change the
size. The flat edges stay solid down to the smallest size, the flat and
tube thicknesses match at the same size, and the clipping-plane and
transparent rendering path still works. The tube joins are filled with
no stray sphere on the 2D triangulation (infinite vertex) or on a mesh
with a degenerate edge, and a clean cube fills correctly. Before/after
screenshots are on the CGAL wiki.

### Note on caps (square vs round)

Flat edges use square caps. Round caps fill the corners where two edges
meet but add a slight rounded bulge at free ends, and on a dense mesh at
large width they overshoot each vertex and overlap into a fish-scale
pattern. Square caps avoid that and only leave a small corner gap that
shows at large width. After comparing both on real renders and
discussing with the mentors, square caps are kept as the default, with
round documented as the alternative. The filled-join case is the tube
mode (cylinders plus per-endpoint spheres).
2026-07-08 09:22:40 +02:00
Rajdeep Singh db827b0906 Basic_viewer: draw the flat edges opaque, anti-aliased by multisampling
The flat edges used analytical anti-aliasing in the fragment shader, which left a one-pixel blended border that read as slightly transparent, and a very thin edge could fade toward the background. Draw the edges opaque instead: the geometry shader emits the exact square-capped edge rectangle, the fragment shader outputs the solid edge colour (keeping the clipping-plane discard), and 4x multisampling is enabled on the context to smooth the silhouette. A thin edge now stays fully solid at any width. The minimum one-pixel half-width clamp is kept so a sub-pixel edge keeps a solid core.
2026-06-25 06:58:35 +05:30
albert-github 248e4a94d4 Spelling correction
Spelling correction
2026-06-12 13:28:39 +02:00
Rajdeep Singh cbcc95a47f Basic_viewer: gate modern shaders on GLSL 1.50 (OpenGL 3.2)
The modern Basic_viewer shaders are all #version 150 (OpenGL 3.2), but
shader selection was gated on isOpenGL_4_3(). On core-profile contexts
below 4.3 (e.g. macOS 4.1 core) this routed to the compatibility shaders,
which use legacy GLSL and do not compile on a core profile.

Add a separate is_ogl_3_2 / isOpenGL_3_2() capability flag and use it for
Basic_viewer's modern-vs-compatibility shader selection. isOpenGL_4_3() is
left unchanged because outside Basic_viewer it still gates the OpenGL 4.3
C++ API (QOpenGLFunctions_4_3_Core) used by the CGAL Lab demo and Three.
2026-06-04 03:32:53 +05:30
Rajdeep Singh eb343391bf Merge remote-tracking branch 'origin/main' into fix/compat-shaders-ogl-lt-4.3
# Conflicts:
#	Basic_viewer/include/CGAL/Qt/Basic_viewer.h
2026-06-03 12:51:48 +05:30
Sebastien Loriot 8ce4839980 Stop playing path on a mouse press (#9443)
## Summary of Changes

Previously, left-clicking to orbit the camera while a path was playing
would directly modify the camera transform, corrupting the ongoing
interpolation. Stopping the path playback on a mouse press assumes the
user intentionally wants to interrupt it.

## Release Management

* Affected package(s): Basic_Viewer, GraphicsView
2026-05-19 14:34:26 +02:00
aminkhalsi 9a5cbf5e13 stop instead of reset 2026-04-21 14:21:54 +01:00
aminkhalsi e7fe931616 stop path on mousePressEvent 2026-04-21 14:14:25 +01:00
Sebastien Loriot 9ec37162fe Lab: Suppress warning (#9384)
## Summary of Changes

Suppress
[warning](https://cgal.geometryfactory.com/CGAL/testsuite/CGAL-6.2-Ic-134/Lab_Demo/TestReport_lrineau_Ubuntu-latest-GCC6-CXX1z.gz)
issued by gcc.
```
include/CGAL/Three/Viewer_interface.h:42:21: warning: defining ‘CGAL::Three::Viewer_interface’, which previously failed to be complete in a SFINAE context [-Wsfinae-incomplete=]
   42 | class VIEWER_EXPORT Viewer_interface : public CGAL::QGLViewer{
      |                     ^~~~~~~~~~~~~~~~
```

## Release Management

* Affected package(s): Lab
* License and copyright ownership:  unchanged
2026-04-09 17:55:44 +02:00
Sébastien Loriot e5ff466b95 workaround new GCC warning 2026-04-03 15:41:11 +02:00
aminkhalsi c2dfb1829c stop camera before start playing path 2026-03-25 09:45:19 +01:00
Rajdeep Singh 645d96b88d Fix driver-dependent missing edges: pin attribute locations, remove dead g_Color, add OGL<4.3 edge fallback
- Add bindAttributeLocation(a_Pos, 0) and bindAttributeLocation(a_Color, 1)
  before link() for rendering_program_p_l, rendering_program_line, and
  rendering_program_cylinder to guarantee consistent attribute locations
  across all OpenGL drivers.
- Remove dead 'in mediump vec4 g_Color[]' from GEOMETRY_SOURCE_LINE_WIDTH
  geometry shader (no matching vertex shader output).
- Add proper edge rendering fallback via rendering_program_p_l for
  OpenGL < 4.3 where the geometry shader is unavailable.
- Re-add minor version check for OpenGL 4.0-4.2 in qglviewer_impl.h.
2026-03-24 18:11:09 +05:30
Rajdeep Singh 3d51a994bf Address review: fix version check regression, warn only once
- Version check: revert to majorVersion() < 4 instead of checking for
  specifically 4.3. On macOS, init_ogl_context() caps to 4.1 core
  profile; compat shaders (attribute/varying) would fail in core
  contexts. The #version 150 modern shaders work fine on any 4.x.
  This also correctly handles future OpenGL 5+.
- Warning: use static guard so the message emits only once, even if
  compile_shaders() is called multiple times.
2026-03-24 16:10:31 +05:30
Rajdeep Singh b8cfd196f4 Fix CGAL::draw() black rendering on OpenGL < 4.3 (issue #6754)
Fix compatibility shaders and OpenGL version detection that caused
CGAL::draw() to render solid black geometry on systems with OpenGL < 4.3.

Basic_shaders.h:
- VERTEX_SOURCE_COLOR_COMP: change 'varying' to 'attribute' for vertex
  inputs (a_Pos, a_Normal, a_Color) as required by GLSL 1.10/1.20
- VERTEX_SOURCE_COLOR_COMP: replace undefined 'mv_matrix' reference with
  'mat3(u_Mv) * a_Normal' matching the declared uniform
- VERTEX_SOURCE_P_L_COMP: change 'varying' to 'attribute' for vertex
  inputs (a_Pos, a_Color)

qglviewer_impl.h:
- Initialize is_ogl_4_3 to false in defaultConstructor() to avoid UB
- Fix version check: use major < 4 || (major == 4 && minor < 3) instead
  of major != 4, so OpenGL 4.0-4.2 correctly falls back and 5+ works

Basic_viewer.h:
- Add std::cerr warning when compatibility shaders are selected
2026-03-24 15:50:58 +05:30
Laurent Rineau 552c1672bc new version of the old Mesh_2 demo 2026-02-05 12:09:50 +01:00
albert-github ea9a69faf2 Removing double words
- removing double words
- correcting some texts
2026-01-13 12:18:50 +01:00
Sébastien Loriot f98d968ed0 Merge remote-tracking branch 'cgal/6.1.x-branch' into 'cgal/main' 2025-11-19 14:46:33 +01:00
Sébastien Loriot 9bd1705bf8 Merge remote-tracking branch 'cgal/6.0.x-branch' into 'cgal/6.1.x-branch' 2025-11-19 14:45:21 +01:00
Mael Rouxel-Labbé 31734df2ef Fix warning about discarding return type of function with [[nodiscard]] 2025-11-07 17:16:31 +01:00
Andreas Fabri 4b89f17b42 CGAL: An Halfedge 2025-11-03 14:37:50 +00:00
Sébastien Loriot 8e0f2d6f73 Merge remote-tracking branch 'cgal/6.0.x-branch' into 'cgal/master' 2025-07-31 15:19:07 +02:00
Sven Oesau f40a223d2a behavior of QOpenGL.h changed, with 6.9.1 it does not provide APIENTRY from windows.h anymore, but QT_APIENTRY instead 2025-07-11 16:41:40 +02:00
albert-github 12cde5b685 Spelling correction
After review: euclidean -> Euclidean
2025-06-27 13:04:28 +02:00
Mael Rouxel-Labbé e38e29f279 dont > don't 2025-03-28 20:52:22 +01:00
Andreas Fabri f65b7f744f Adress warnings and errors in the testsuite 2024-11-15 15:27:17 +00:00
Sébastien Loriot a2c16c3768 Merge pull request #8509 from afabri/T2-demo_improvements
Polygon: various clean-ups
2024-10-21 19:20:18 +02:00
Sébastien Loriot 5c04d1f563 add some override keywords 2024-10-15 20:10:27 +02:00
albert-github dd02af92a2 issue #8515 Spelling mistakes found checking en-GB to en-US
Spelling corrections, `en-GB` -> `en-US`
2024-10-05 11:28:29 +02:00
Sébastien Loriot f91765503c demo improvement and various clean-ups 2024-10-01 11:57:04 +02:00
Sébastien Loriot 41b096c91a Merge remote-tracking branch 'cgal/5.6.x-branch' 2024-09-11 17:23:50 +02:00
Sébastien Loriot 4115afa3da Merge remote-tracking branch 'cgal/5.5.x-branch' 2024-09-10 13:51:15 +02:00
Sébastien Loriot 8448129a3a fix conditional compilation 2024-09-09 17:59:24 +02:00
Laurent Rineau 93dd87c3cc simple fix to remove the segfault with Qt>=6.7 2024-09-02 17:51:06 +02:00
Nicolas Saillant 1286d8b636 Remove deprecated Qt version checks 2024-08-19 12:02:19 +02:00
Nicolas Saillant bf10f945a9 Remove deprecated Qt version checks and unused code 2024-08-07 10:00:59 +02:00
albert-github 36c8b7589d Spelling corrections
Last batch (for now) of spelling corrections in doxygen and normal comments
2024-05-31 19:05:34 +02:00
Laurent Rineau 4db6bc6d16 Merge pull request #6967 from gdamiand/gsoc2022-EBVs-Mostafa-ashraf19
GSoC'22: New CGAL's design to handle basic viewers
2024-04-10 18:04:25 +02:00
Guillaume Damiand 9a0b8eb824 Merge branch 'master' into gsoc2022-EBVs-Mostafa-ashraf19 2024-03-26 16:25:29 +01:00
Laurent Rineau 7d0f058463 remove T_2 from dependencies of GraphicsView 2024-03-26 15:52:09 +01:00
Laurent Rineau f716cc0260 fix a bug with devicePixelRatio and picking 2024-03-06 10:25:30 +01:00
Guillaume Damiand 3bc56024d3 Merge branch 'master' into gsoc2022-EBVs-Mostafa-ashraf19 2024-01-11 14:08:05 +01:00
Sébastien Loriot c99b69a0e7 add missing license headers 2024-01-04 13:50:15 +01:00
Sébastien Loriot e7c26349f2 move header in a package to GPL 2024-01-04 13:36:34 +01:00
Guillaume Damiand 0655006622 Merge with master: now viewers use Qt6 2023-11-29 14:36:38 +01:00
Laurent Rineau 51627e3505 Merge remote-tracking branch 'cgal/master' into CGAL-Qt6-GF
# Conflicts:
#	GraphicsView/demo/Bounding_volumes/CMakeLists.txt
2023-11-01 20:59:44 +01:00
Guillaume Damiand a5447a846b Remove warning 2023-10-04 07:59:01 +02:00
Guillaume Damiand 2891528073 Bug fix in drawing of interior faces when the outer boundary is pinched 2023-09-28 19:21:49 +02:00
Laurent Rineau 48f37a14dc remove occurrences of Qt5 2023-09-14 17:02:21 +02:00
Laurent Rineau 2f6d51b49b Remove a few occurrences of CGAL_Qt5
... and replace by CGAL_Qt6
2023-09-14 16:33:20 +02:00