Skip to content

Render triangulated polygons in OpenGL - #68

Open
pmeems wants to merge 5 commits into
polygon-triangulation-corefrom
polygon-triangulation-opengl
Open

pmeems wants to merge 5 commits into
polygon-triangulation-corefrom
polygon-triangulation-opengl

Conversation

@pmeems

@pmeems pmeems commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Phase 2 of the polygon triangulation plan: the OpenGL backend now consumes the Core-prepared triangle meshes instead of GL_POLYGON, so concave polygons, interior rings and multipart geometries render on the GPU.

Depends on #66 (stacked; base branch is polygon-triangulation-core).

What changed

  • Polygon fills use indexed triangle rendering through the OpenGL 1.1 client-side vertex-array API (glVertexPointer, glDrawElements, glEnableClientState); no GL_POLYGON remains.
  • Outlines are drawn from the original rings of VectorRenderScene, so exterior, hole and multipart boundaries are preserved and internal triangle edges are never outlined.
  • The convexity and single-ring restrictions are removed; scenes are accepted when every polygon has a usable mesh (complete triangles, in-range indices, finite coordinates). A polygon without a mesh — for example when Core triangulation failed — makes the whole frame report S_FALSE so the coordinator falls back to GDI, never an incorrect GL_POLYGON approximation.
  • The rendering coordinator, GDI fallback, framebuffer handling, 64 MiB staging budget and all existing safeguards are unchanged; no COM interface changes.

Tests

  • New coverage: concave/L-shaped polygons, one and multiple interior rings, multipart polygons, missing-mesh fallback, no visible internal triangle edges, and GDI/OpenGL pixel equivalence on a concave holed scene. Geometry support decisions are also tested GPU-independently through a test-access hook.
  • Debug | x64 builds with no new Level 4 warnings; MapWinGIS.Core.Tests: 311 passed (1 pre-existing network skip); MapWinGIS.ActiveX.Tests: 65 passed (2 pre-existing skips).

Memory

  • .ai/memory/architecture/activex.md: replaced the "convex single-ring only" limit with the mesh-based backend contract. No new memory files.

@pmeems
pmeems added this pull request to stack #69 November 12, 2026 18:22

@Julian-MW Julian-MW left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one rendering-order regression in the OpenGL path. See the inline comment.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Drawing all fills before outlines exposes earlier polygon boundaries over later overlapping fills, regressing the previous OpenGL and GDI rendering order.

1 open issue
What changed in this PR

This PR connects the OpenGL backend to the Core triangulation introduced in #66, enabling GPU rendering of concave polygons, holes, and multipart geometry without COM interface changes.

Changes:

  • Replaces GL_POLYGON fills with indexed triangles and draws outlines from original rings.
  • Validates meshes and falls back to GDI when any polygon lacks a usable mesh.
  • Adds geometry-support and rendering tests, including sampled GDI/OpenGL comparisons.

Builds and tests were not run during this review.

File Description
tests/​MapWinGIS.ActiveX.Tests/​VectorLayerRendererTests.cpp Adds mesh preparation, rendering checks, and fallback coverage.
tests/​MapWinGIS.ActiveX.Tests/​OpenGlVectorLayerRendererTestAccess.h Exposes scene-support checks without an OpenGL context.
src/​MapWinGIS.ActiveX/​OpenGlVectorLayerRenderer.h Documents mesh-based rendering and declares the support hook.
src/​MapWinGIS.ActiveX/​OpenGlVectorLayerRenderer.cpp Validates meshes, renders indexed fills, and outlines original rings.
.ai/​memory/​architecture/​activex.md Updates the documented OpenGL support contract.

Review effort: Balanced

pmeems added a commit that referenced this pull request Nov 13, 2026
…s unavailable

OpenGlRendersPolygonWithInteriorRing is the only OpenGL pixel test that
draws through the auto-selecting VectorLayerRenderer. On runners without
an OpenGL context it silently fell back to GDI, which leaves the host
background untouched and strokes the ring outline, so the OpenGL-specific
pixel assertions failed (PR #68 CI). Skip when the coordinator did not
select OpenGL, matching how the other OpenGL rendering tests behave.
@pmeems
pmeems force-pushed the polygon-triangulation-opengl branch 2 times, most recently from f584a11 to c061c7e Compare November 13, 2026 16:14
- Fill polygons with indexed triangle meshes via glVertexPointer and glDrawElements
- Draw outlines from the original rings instead of triangle edges
- Accept concave, holed and multipart scenes; drop the convexity checks
- Reject scenes whose polygons lack a usable fill mesh so the coordinator falls back to GDI
- Extend renderer tests with concave, holed, multipart and GDI-equivalence coverage
- Update the ActiveX architecture memory to the mesh-based rendering model
…s unavailable

OpenGlRendersPolygonWithInteriorRing is the only OpenGL pixel test that
draws through the auto-selecting VectorLayerRenderer. On runners without
an OpenGL context it silently fell back to GDI, which leaves the host
background untouched and strokes the ring outline, so the OpenGL-specific
pixel assertions failed (PR #68 CI). Skip when the coordinator did not
select OpenGL, matching how the other OpenGL rendering tests behave.
- Fill and outline each polygon before advancing to the next one so overlapping polygons in one layer match the GDI backend's painter order
- Add a GDI/OpenGL parity test for overlapping polygons in one layer
- Record that Viewport::MapToScreen flips the y axis, so renderer pixel tests must convert map coordinates to device pixels before sampling
@pmeems
pmeems force-pushed the polygon-triangulation-opengl branch from c061c7e to 03f0582 Compare November 13, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants