ComputationalBiomechanicsLab / opensim-creator

A UI for building OpenSim models
https://opensimcreator.com
Apache License 2.0
142 stars 17 forks source link

Fix `GL_INVALID_OPERATION` when rendering with mesh normals enabled but also drawing non-triangular scene elements #792

Closed adamkewley closed 1 year ago

adamkewley commented 1 year ago

When debugging OpenGL on WSL2 i'm seeing this error message:

[default] [error] OpenGL Debug message:
id = 1
message = GL_INVALID_OPERATION in glDrawElementsInstanced
source = GL_DEBUG_SOURCE_API
type = GL_DEBUG_TYPE_ERROR
severity = GL_DEBUG_SEVERITY_HIGH

It appears to happen specifically when rendering with both mesh normals and one of the following options enabled:

The commonality between those options is that the ultimately cause the renderer to use GL_LINES rather than GL_TRIANGLES. That's problematic when Mesh Normals are enabled because it uses a GPU-based geometry shader, which assumes GL_TRIANGLES input, to render each mesh normal as a little red line in real-time.