Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conrod with glutin/glium backend does not work with OpenGL ES #884

Closed
TimBednarzyk opened this issue Nov 25, 2016 · 4 comments
Closed

conrod with glutin/glium backend does not work with OpenGL ES #884

TimBednarzyk opened this issue Nov 25, 2016 · 4 comments

Comments

@TimBednarzyk
Copy link

There seems to be at least 2 issues causing this. The first is that the shader code for the glium backend does not have a valid version for OpenGL ES (Should be #version 330 for OpenGL ES 3.0, or with some other changes to the shader code #version 100 for OpenGL ES 2.0). I made a local copy and changed the shader code accordingly. However, I still get another error:

thread 'main' panicked at 'assertion failed: ctxt.version >= &Version(Api::Gl, 3, 2) ||
    ctxt.extensions.gl_arb_sampler_objects', /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/sampler_object.rs:22
stack backtrace:
   1:     0x564a7220cdb9 - std::sys::backtrace::tracing::imp::write::hd4b54a4a2078cb15
   2:     0x564a722108dc - std::panicking::default_hook::_{{closure}}::h51a5ee7ba6a9fcef
   3:     0x564a7220fb89 - std::panicking::default_hook::hf823fce261e27590
   4:     0x564a72210218 - std::panicking::rust_panic_with_hook::h8d486474663979b9
   5:     0x564a71f9e933 - std::panicking::begin_panic::h94e6fb50d7864116
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:384
   6:     0x564a7206bb73 - glium::sampler_object::SamplerObject::new::h7657da2b8588ab98
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/sampler_object.rs:3
   7:     0x564a7206c026 - glium::sampler_object::get_sampler::hc16e650b4458f717
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/sampler_object.rs:105
   8:     0x564a71db527f - glium::uniforms::bind::bind_texture_uniform::h3040645f16479981
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/uniforms/bind.rs:588
   9:     0x564a71db3b55 - glium::uniforms::bind::bind_uniform::h08b759a7b6720359
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/uniforms/bind.rs:420
  10:     0x564a71e1feeb - glium::uniforms::bind::_<impl glium..UniformsExt for U>::bind_uniforms::_{{closure}}::h665680bbfbbb757b
  11:     0x564a71d1f8c8 - _<glium..uniforms..uniforms..UniformsStorage<'n, T, R> as glium..uniforms..Uniforms>::visit_values::h253a0e1a59d97b1f
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/uniforms/uniforms.rs:52
  12:     0x564a71db7294 - glium::uniforms::bind::_<impl glium..UniformsExt for U>::bind_uniforms::h8f634f9f23ec8491
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/uniforms/bind.rs:49
  13:     0x564a71da154e - glium::ops::draw::draw::h8dfc95a2a0b4a72a
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/ops/draw.rs:167
  14:     0x564a71d757d8 - _<glium..Frame as glium..Surface>::draw::h4c6bc4e3004e012d
                        at /home/kuro-kun/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/glium-0.15.0/src/lib.rs:1168
  15:     0x564a71ddcd5c - conrod::backend::glium::Renderer::draw::hcd2e5009fee2b316
                        at /home/kuro-kun/proj/conrod/./src/backend/glium.rs:718
  16:     0x564a71e1ea56 - conrod_test::main::h8e018177daba07e8
                        at /home/kuro-kun/proj/conrod_test/src/main.rs:94
  17:     0x564a722183c6 - __rust_maybe_catch_panic
  18:     0x564a7220f302 - std::rt::lang_start::hca48e539ce72a288
  19:     0x564a71e2f353 - main
  20:     0x7f6784a74290 - __libc_start_main
  21:     0x564a71d148c9 - _start
  22:                0x0 - <unknown>
error: Process didn't exit successfully: `target/debug/conrod_test` (exit code: 101)

The actual code is just the text_edit example rewritten for glutin/glium, and running the same code with OpenGL (and the original shader code) works just fine. Not being able to run with OpenGL ES means not being able to run on Android.

@mitchmindtree
Copy link
Contributor

Thanks a lot for the issue @TimBednarzyk, i'm definitely keen to address this. I don't have time to look into this just yet, but I imagine there should be some info at the glium repo on how to remain compatible with GL ES whether in the guide, docs or issues. Will look into this next I get some time.

@TimBednarzyk
Copy link
Author

The second issue ended up being an issue with glium itself, and should be fixed with this pull request. I tested a slightly modified version of the glutin_glium example, and it works with OpenGL ES 3.0 on desktop now. However, there's still an issue on Android:

Debug message with high or medium severity:
'unable to generate a triangle primitive because there are less than 3 vertices'.

I'll keep looking into this error and see if I can get the example to work on Android.

@TimBednarzyk
Copy link
Author

I've been doing some debugging, and I've found out why that error is caused, but not how to fix it yet. The issue is caused here due to slice.len() being 0, and therefore creating a VertexBuffer with 0 vertices. Running on desktop gave me a slice.len() of 2,862.

I've also found out 3 things:

  1. Tapping the screen causes conrod to redraw the screen, and this time around no errors occur and conrod draws everything fine.
  2. Touch events don't seem to do anything - i.e. tapping a button will not click it or anything.
  3. Everything is small on Android - I can see almost the entire example (from the very top to almost the middle of the PlotPath). Screenshot here.

@mitchmindtree
Copy link
Contributor

I'm going to close this as it sounds like the OpenGL ES compatibility has been fixed.

I've been doing some debugging, and I've found out why that error is caused, but not how to fix it yet. The issue is caused here due to slice.len() being 0, and therefore creating a VertexBuffer with 0 vertices. Running on desktop gave me a slice.len() of 2,862.

If this is still occurring, would you mind opening a separate issue for it? It does sound quite strange. Perhaps we just have to do a check here that only pushes the last command if there are any vertices in the current state in order to avoid creating an empty VertexBuffer.

Re 2.: I think we can open up another issue for supporting Touch events properly. At the moment, none of the widgets are "listening" for Touch events in their Widget::update methods so it's not surprising that nothing is happening. I think this handling will have to be added per-widget.

Re 3.: I'm not sure what we can do in conrod to adjust for this, as conrod is already designed to work agnostically of DPI. It might be that winit produces an incorrect value from its Window::hidpi_factor method? I'm fine with opening a new issue for this if you want to keep tracking it, though it could be worth checking the hidpi_factor that is being returned on your Android first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants