[Bug Report] Resource Pack isn't loading on Mac
Current Behaviour: When attempting to draw the skybox in Amulet Map Editor on macOS with OpenGL 3.0 or higher, an OpenGL error 1282: invalid operation occurs. This error happens specifically during the call to glGenVertexArrays, indicating an issue with the creation of Vertex Array Objects (VAOs). The error prevents the skybox and potentially other graphics elements from rendering correctly.
Expected behavior: The skybox should render correctly without any OpenGL errors. VAOs should be created and used properly, allowing the application to run smoothly and display all graphics elements as intended.
Steps To Reproduce: Open Amulet Map Editor on macOS. Load a Minecraft world. Attempt to perform any operation that involves drawing the skybox (e.g., moving the camera to view the sky). Observe the OpenGL error in the terminal/console output.
Environment: OS: macOS Minecraft Platform: Java Minecraft Version: 1.20.04 Amulet Version: 0.10.30
Additional context This issue appears to be related to the use of VAOs in OpenGL 3.0 or higher. The error may be caused by an improper initialization of the OpenGL context or incorrect use of VAO-related functions. Ensuring the OpenGL context is correctly set up before making OpenGL calls is critical.
Screenshots
Was this an issue in 0.10.29? I changed the OpenGL initialisation in this version.
I can confirm the same issue on my MacBook Pro M1 running OSX Sonoma 14.5 with python version 3.11.9 and amulet version 0.10.30
In 0.10.29 this is not an issue.
This is the OpenGL change I made. https://github.com/Amulet-Team/Amulet-Map-Editor/commit/dd7146b079219948a974a0ff90c76b955ec2faf8
Previously the opengl context attributes on mac was set up like this.
context_attributes = wx.glcanvas.GLContextAttrs()
context_attributes.CoreProfile().Robust().ResetIsolation().EndList()
According to the docs Robust and ResetIsolation have no effect on macOS so I removed them.
It first of all tries OpenGL 3.3 Core and falls back to OpenGL 2.1 Compatibility.
I added PlatformDefaults and OGLVersion(3, 3)
Can you play around and see what need to change to make it work on your system.
https://docs.wxpython.org/wx.glcanvas.GLContextAttrs.html
Getting the same issue here.
MacOS: 14.3.1
Python: 3.12.4
Amulet: 0.10.33
From the terminal, this message spews non-stop:
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/OpenGL/GL/shaders.py", line 235, in compileShader
raise ShaderCompilationError(
OpenGL.GL.shaders.ShaderCompilationError: ('Shader compile failure (0): b"WARNING: 0:2: extension \'GL_ARB_explicit_attrib_location\' is not supported\\nERROR: 0:4: \'layout\' : syntax error: syntax error\\n"', [b'#version 120\r\n#extension GL_ARB_explicit_attrib_location : enable\r\n\r\nlayout(location = 0) in vec3 positions;\r\nlayout(location = 1) in vec2 vTexCoord;\r\nlayout(location = 2) in vec4 vTexOffset;\r\nlayout(location = 3) in vec3 vTint;\r\n\r\nvarying vec2 fTexCoord;\r\nvarying vec4 fTexOffset;\r\nvarying vec3 fTint;\r\n\r\nuniform mat4 transformation_matrix;\r\n\r\nvoid main(){\r\n gl_Position = transformation_matrix * vec4(positions, 1.0);\r\n fTexCoord = vTexCoord;\r\n fTexOffset = vTexOffset;\r\n fTint = vTint;\r\n}'], GL_VERTEX_SHADER)
Traceback (most recent call last):
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/programs/edit/plugins/tools/select.py", line 329, in _on_draw
self.canvas.renderer.draw_sky_box()
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/programs/edit/api/renderer.py", line 224, in draw_sky_box
self.sky_box.draw(self.canvas.camera.transformation_matrix)
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/api/opengl/mesh/sky_box.py", line 63, in draw
super().draw(
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/api/opengl/mesh/tri_mesh.py", line 161, in draw
self._setup()
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/api/opengl/mesh/tri_mesh.py", line 90, in _setup
self._shader = get_shader(self.context_identifier, self.shader_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/api/opengl/shaders/__init__.py", line 60, in get_shader
shader = compile_shader()
^^^^^^^^^^^^^^^^
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/api/opengl/shaders/__init__.py", line 49, in compile_shader
_load_shader(
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/amulet_map_editor/api/opengl/shaders/__init__.py", line 75, in _load_shader
return OpenGL.GL.shaders.compileShader(shader, shader_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/steve/Documents/Python/Amulet/lib/python3.12/site-packages/OpenGL/GL/shaders.py", line 235, in compileShader