cmu-geometry / ddg-exercises-js

MIT License
138 stars 54 forks source link

Polyscope OpenGL Error #1

Closed amiltonwong closed 3 years ago

amiltonwong commented 3 years ago

Hi, all,

I've built the project simplicial-complex-operators without error. However, when I run the main executable to display the mesh file. Error message such as Polyscope OpenGL Error! Type: Invalid enum appears. Any hints to solve this issue? THX!

root@milton-PC:/data/code14/ddg-exercises/projects/simplicial-complex-operators/build# ./bin/main ../../../input/disk.obj 
[polyscope] Backend: openGL3_glfw -- Loaded openGL version: 3.3 (Core Profile) Mesa 18.0.5
[polyscope] Polyscope OpenGL Error!  Type: Invalid enum
GLError() after shader compilation! Program text:

// tag ${ GLSL_VERSION }$
// from rule: GLSL_VERSION
#version 330 core

      in vec3 a_position;
      out vec2 tCoord;

      void main()
      {
          tCoord = (a_position.xy+vec2(1.0,1.0))/2.0;
          gl_Position = vec4(a_position,1.);
      }

terminate called after throwing an instance of 'std::runtime_error'
  what():  OpenGl error occurred. Text: Invalid enum
Aborted (core dumped)

P.S. My system is ubuntu 16.04.7. gcc/g++ already upgraded to 7.5 version.

mwmuni commented 2 years ago

@amiltonwong how did you end up resolving this issue?

EDIT: seems like this issue was resolved here

Bathsheba commented 2 years ago

I had the same issue and resolved it in the same way.

amiltonwong commented 2 years ago

@mwmuni , you're right, I resolved it by rebuilding it using cmake -DCMAKE_BUILD_TYPE=Debug ..

Bathsheba commented 2 years ago

Actually, after I updated to the latest mesa (through kisak) I didn't need the debug build anymore. (Now there's a new issue in which the project compiles clean and launches, but Polyscope doesn't get any mouse events so it's unusable, except it can zoom using the mousewheel...I really don't want to use JS because I'll need this code later, but dang it's frustrating that this doesn't quite work.)

mwmuni commented 2 years ago

Actually, after I updated to the latest mesa (through kisak) I didn't need the debug build anymore. (Now there's a new issue in which the project compiles clean and launches, but Polyscope doesn't get any mouse events so it's unusable, except it can zoom using the mousewheel...I really don't want to use JS because I'll need this code later, but dang it's frustrating that this doesn't quite work.)

It seems like some C++ optimisations are optimising out critical OpenGL code. Does anyone familiar with compilation optimisation know how to fix this without compiling in debug mode?

I had the exact same issue and fix with a separate project, so this issue is not isolated to this repo.

Bathsheba commented 2 years ago

Well thank God I'm not crazy. NB I still see the no-mouse problem after compiling in debug mode. Do we need a new issue?

mwmuni commented 2 years ago

Well thank God I'm not crazy. Do we need a new issue?

Probably not. I would say that opening this issue again would be sufficient, since the solution of compiling in debug mode is inadequte.

mwmuni commented 2 years ago

After several hours, I isolated the issue to a default optimisation in the compiler at O1 and above.

Adding -fno-defer-pop to the compilation flags resolves the issue for me.

Bathsheba commented 2 years ago

Gj! not me though. Are you in Windows 11?

mwmuni commented 2 years ago

After several hours, I isolated the issue to a default optimisation in the compiler at O1 and above.

Adding -fno-defer-pop to the compilation flags resolves the issue for me.

Gj! not me though. Are you in Windows 11?

WSL2 under Windows 11.