Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • basic-simulator basic-simulator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • monticore
  • EmbeddedMontiArcEmbeddedMontiArc
  • simulators
  • basic-simulatorbasic-simulator
  • Issues
  • #5
Closed (moved) (moved)
Open
Issue created Oct 19, 2021 by Jean Meurice@jean.meuriceMaintainer

OpenGL visualization

Problem

  • Right now, the 2D visualization of the maps and vehicles uses the Graphics2D java class inside the Swing components.
  • This is not a very efficient rendering method, especially for large scale cities.
  • It is also not precise: the polygon geometry can only be passed with integer pixel positions.

Solution

Use OpenGL rendering.

  • As OpenGL library (for example): JOGL
    • JOGL in Swing (Still up-to-date ?)
    • OpenGL 4 JOGL sample
  • TODOs:
    • Test a simple 2D triangle with a basic shader.
    • Make it build and run using the JOGL maven artifacts.
    • Make a colored triangle shader with an orthogonal view matrix, test binding it to the map controls (position, zoom). Render a simple triangle (or 2)
    • Make a colored line shader, same view matrix, test a simple outline.
    • Generate the building geometry in one VBO/VAO/EBO set.
      • Use the already split convex parts
      • The convex polygon parts can be rendered using the GL_TRIANGLE_FAN drawing mode
      • In combination with the Primitive Restart
        • Use an Element-Buffer
        • Use the PRIMITIVE_RESTART index to separate triangle fans for different polygons
        • Since we only want to draw contiguous vertices, the glMultiDrawElements() method can be useful
    • Generate the road geometry (or visualization lines)
    • Generate the vehicle geometry (one VBO/EBO/VAO set)
      • Same triangle shader, but give it a view+model matrix (pre-multiplied)
    • All the debug lines/elements (AABB, building outlines, ...) can be in their own VBO/EBO/VAO.
  • Check the thread interaction between Swing and OpenGL. The OpenGL calls are not thread-safe for a given context. Be sure that the OpenGL calls happen in the correct thread.
    • Swing Threads

Note: The existing visualization already "pre-generates" the geometry in some way to save computation. Changing to save this geometry in OpenGL buffer would not be a big change.

Edited Oct 19, 2021 by Jean Meurice
Assignee
Assign to
Time tracking