dune3d / dune3d

3D CAD application
https://dune3d.org
GNU General Public License v3.0
825 stars 24 forks source link

Shader Compilation Error with GLES #85

Closed Uks2 closed 2 months ago

Uks2 commented 2 months ago

When I first tried to run dune3d (on void linux x86_musl, gtk-4.14.1, mesa-24.0.2) , I got a load of shader compiling errors along the lines of

Compile failure in fragment shader: 0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

Linking failure: error: vertex shader lacks `main'

...and the program aborted with gl error 1281 in ../src/canvas/glyph_renderer.cpp:44, (I guess that's where it first tries to use an uncompiled shader).

The oft suggested MESA_GL_VERSION_OVERRIDE=3.3 had no effect.

Patching thus fixed the problem for me, but I have no idea if that might cause problems on other systems (GL is a bit of a black art to me!)

diff --git a/src/canvas/canvas.cpp b/src/canvas/canvas.cpp
index dd385a4..1083572 100644
--- a/src/canvas/canvas.cpp
+++ b/src/canvas/canvas.cpp
@@ -654,6 +654,7 @@ glm::vec3 Canvas::get_center_shift(const glm::vec2 &shift) const
 void Canvas::on_realize()
 {
     std::cout << "realize" << std::endl;
+    Gtk::GLArea::set_allowed_apis( Gdk::GLApi::GL );
     Gtk::GLArea::on_realize();
     make_current();
     m_background_renderer.realize();

(P.S. checking the result of the shader compilation would have made debugging a bit easier. It looks like create_shader does return 0 on error, but I guess that isn't being checked anywhere.)

carrotIndustries commented 2 months ago

ok, remove the Gtk::GLArea:: in front of set_allowed_api and open a PR.