marialarsson / tsugite

This is the repository of a Tsugite. It is a research prototype of an interactive software that supports the design and fabrication of wood joints.
http://www.ma-la.com/tsugite.html
Other
423 stars 78 forks source link

Shader compile error on MacOS #10

Open greatestape opened 3 years ago

greatestape commented 3 years ago

When I try to run the app on my Mac I get a shader error.

Environment:

Steps to reproduce:

  1. python3 -m vent env
  2. source env/bin/activate
  3. pip install requirements.txt
  4. cd setup
  5. python Tsugite_app.py

Actual behaviour

qt.qpa.window: <QNSWindow: 0x7f88cf0fd560; contentView=<QNSView: 0x7f88cf178f80; QCocoaWindow(0x7f88cf178e70, window=QWidgetWindow(0x7f88cf166960, name="QGLWidgetClassWindow"))>> has active key-value observers (KVO)! These will stop working now that the window is recreated, and will result in exceptions when the observers are removed. Break in QCocoaWindow::recreateWindowIfNeeded to debug.
Traceback (most recent call last):
  File "/Users/sam/src/github.com/tsugite/setup/_GLWidget.py", line 35, in initializeGL
    self.show = Show(self,self.type)
  File "/Users/sam/src/github.com/tsugite/setup/Show.py", line 12, in __init__
    self.create_color_shaders()
  File "/Users/sam/src/github.com/tsugite/setup/Show.py", line 53, in create_color_shaders
    self.shader_col = OpenGL.GL.shaders.compileProgram(OpenGL.GL.shaders.compileShader(vertex_shader, GL_VERTEX_SHADER),
  File "/Users/sam/src/github.com/tsugite/env/lib/python3.9/site-packages/OpenGL/GL/shaders.py", line 235, in compileShader
    raise ShaderCompilationError(
OpenGL.GL.shaders.ShaderCompilationError: ('Shader compile failure (0): b"ERROR: 0:2: \'\' :  version \'330\' is not supported\\nERROR: 0:3: \'\' :  extension \'GL_ARB_explicit_attrib_location\' is not supported\\nERROR: 0:4: \'\' :  extension \'GL_ARB_explicit_uniform_location\' is not supported\\nERROR: 0:5: \'layout\' : syntax error: syntax error\\n"', [b'\n        #version 330\n        #extension GL_ARB_explicit_attrib_location : require\n        #extension GL_ARB_explicit_uniform_location : require\n        layout(location = 0) in vec3 position;\n        layout(location = 1) in vec3 color;\n        layout(location = 2) in vec2 inTexCoords;\n        layout(location = 3) uniform mat4 transform;\n        layout(location = 4) uniform mat4 translate;\n        layout(location = 5) uniform vec3 myColor;\n        out vec3 newColor;\n        out vec2 outTexCoords;\n        void main()\n        {\n            gl_Position = transform* translate* vec4(position, 1.0f);\n            newColor = myColor;\n            outTexCoords = inTexCoords;\n        }\n        '], GL_VERTEX_SHADER)
[1]    12442 abort      python Tsugite_app.py

The inner compile error is:

ERROR: 0:2: '' : version '330' is not supported ERROR: 0:3: '' : extension 'GL_ARB_explicit_attrib_location' is not supported ERROR: 0:4: '' : extension 'GL_ARB_explicit_uniform_location' is not supported ERROR: 0:5: 'layout' : syntax error: syntax error

marialarsson commented 3 years ago

@greatestape thank you for sharing the details of the error. We are working on a mac version, and I think that we can fix these... Let me get back to you soon!

marialarsson commented 3 years ago

@greatestape so... we have just pushed some updates! the shaders are downgraded (version 330 to 150). It should solve at least ERROR 0:2. Maybe the other errors too? If you give it a try, let me know how it goes.

greatestape commented 3 years ago

Thank you for replying so quickly!

I pulled the latest master and unfortunately I'm still getting errors. It seems like even 150 isn't supported...

ERROR: 0:2: '' : version '150' is not supported ERROR: 0:3: '' : extension 'GL_ARB_explicit_attrib_location' is not supported ERROR: 0:4: '' : extension 'GL_ARB_explicit_uniform_location' is not supported ERROR: 0:5: 'layout' : syntax error: syntax error

I don't know if this is anything useful, but I found some stuff online saying that MacOS does support more recent opengl versions, but you need to switch to a different "profile". I don't know what any of this stuff means. I know Python, but nothing about OpenGL or 3D graphics!

Stack Overflow explaining the profile stuff: https://stackoverflow.com/a/20932820

I'd be happy to be your tester so you can validate your Mac-compatibility PRs before you merge, if that helps.

PS- I found another SO post that seems to show how to configure the profile and version: https://stackoverflow.com/questions/44277975/pyqt5-choose-the-latest-opengl-version-available

I applied these changes:

 class GLWidget(QGLWidget):
     def __init__(self, parent=None):
+        fmt = QGLFormat()
+        fmt.setVersion(3, 3)
+        fmt.setProfile(QGLFormat.CoreProfile)
+        fmt.setSampleBuffers(True)
+
         self.parent = parent
-        QGLWidget.__init__(self, parent)
+        QGLWidget.__init__(self, fmt, parent)
         self.setMinimumSize(800, 800)

but it just caused different errors:

Traceback (most recent call last):
  File "/Users/sam/src/github.com/tsugite/setup/_GLWidget.py", line 34, in initializeGL
    self.type = Types(self,fs=[[[2,0]],[[2,1]]],sax=sax,dim=dim,ang=ang, td=[dx,dy,dz], fabtol=tol, fabdia=dia, fspe=spe, fspi=spi, fabext=ext, align_ax=aax, incremental=inc, finterp=fin)
  File "/Users/sam/src/github.com/tsugite/setup/Types.py", line 938, in __init__
    self.vertices = self.create_and_buffer_vertices(milling_path=False) # create and buffer vertices
  File "/Users/sam/src/github.com/tsugite/setup/Types.py", line 984, in create_and_buffer_vertices
    self.buff.buffer_vertices()
  File "/Users/sam/src/github.com/tsugite/setup/Buffer.py", line 39, in buffer_vertices
    glEnableVertexAttribArray(0)
  File "/Users/sam/src/github.com/tsugite/env/lib/python3.9/site-packages/OpenGL/platform/baseplatform.py", line 415, in __call__
    return self( *args, **named )
  File "/Users/sam/src/github.com/tsugite/env/lib/python3.9/site-packages/OpenGL/error.py", line 230, in glCheckError
    raise self._errorClass(
OpenGL.error.GLError: GLError(
        err = 1282,
        description = b'invalid operation',
        baseOperation = glEnableVertexAttribArray,
        cArguments = (0,)
)
marialarsson commented 3 years ago

Alright, we will look into it and get back to you. Thank you for volunteering to be our test user :)

maruf89 commented 2 years ago

Same issue here. Is anyone aware of a workaround to run on Mac using Wine for example?

OConnorStP commented 2 years ago

The Windows-download version runs on a Mac VMWare Fusion instance of Windows 10. Not quite the same as Wine, but...