Skip to content

GL error: GL_INVALID_OPERATION on OpenGL ES #145

@matej-mikus

Description

@matej-mikus
$ graph1_pi
This is version 1.0 of mplot::Visual<glver=3.1 ES> running on OpenGL Version OpenGL ES 3.2 Mesa 25.2.8-0ubuntu0.24.04.1
GL error: GL_INVALID_OPERATION | /home/mikusm/Code/mathplot/mplot/VisualModel.h:360
terminate called after throwing an instance of 'std::runtime_error'
  what():  GL error: GL_INVALID_OPERATION
Aborted (core dumped)

After a bit of debugging, it seems to be caused by VisualModel.h render() method which uses non ES compatible glPolygonMode().

VisualModel.h Lines 305 and 307:

// Enable/disable wireframe mode per-model on each render call
if (this->flags.test (vm_bools::wireframe)) {
    _glfn->PolygonMode (GL_FRONT_AND_BACK, GL_LINE);
} else {
    _glfn->PolygonMode (GL_FRONT_AND_BACK, GL_FILL);
}

VisualModel.h Line 363:

// Now render any VisualTextModels
_glfn->PolygonMode (GL_FRONT_AND_BACK, GL_FILL);
auto ti = this->texts.begin();
while (ti != this->texts.end()) { (*ti)->render(); ti++; }

Commenting these out fixes the error and renders the graph correctly. That works for my use case, but since it completely disables wireframes, things like hexgrid_pi don't render how they should.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions