gfx: Debian Linux: GLFW/SDL window providers do not work.

Discovered as kind of a sub-bug of https://github.com/gfx-rs/gfx/issues/1101 , but it is a different error happening in a different place so it seems wise to split it off into its own issue.

To recap:

Trying to run basic example code (triangle or cube) fails to build a window using GLFW or SDL, on Debian Stretch using NVidia drivers. It panics with “Error after executing command BindProgram(0): InvalidEnum”. Altering the OpenGL version from 3.3 to 2.1 and everything between does not appear to affect anything, nor does using different shader version profiles. apitrace does not record any OpenGL calls but does produce some warnings:

apitrace: warning: _gl_param_size: unknown GLenum 0x92F5
apitrace: warning: _gl_param_size: unknown GLenum 0x92F5

Full code:


#[macro_use]
extern crate gfx;
extern crate gfx_window_glfw;
extern crate glfw;

use gfx::traits::FactoryExt;
use gfx::Device;
use glfw::{Action, Context, Key};

pub type ColorFormat = gfx::format::Rgba8;
pub type DepthFormat = gfx::format::DepthStencil;

gfx_defines!{
    vertex Vertex {
        pos: [f32; 2] = "a_Pos",
        color: [f32; 3] = "a_Color",
    }

    pipeline pipe {
        vbuf: gfx::VertexBuffer<Vertex> = (),
        out: gfx::RenderTarget<ColorFormat> = "Target0",
    }
}

const TRIANGLE: [Vertex; 3] = [Vertex {
                                   pos: [-0.5, -0.5],
                                   color: [1.0, 0.0, 0.0],
                               },
                               Vertex {
                                   pos: [0.5, -0.5],
                                   color: [0.0, 1.0, 0.0],
                               },
                               Vertex {
                                   pos: [0.0, 0.5],
                                   color: [0.0, 0.0, 1.0],
                               }];

const CLEAR_COLOR: [f32; 4] = [0.1, 0.2, 0.3, 1.0];

pub fn main() {
    let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS)
        .ok()
        .expect("Failed to initialize GLFW");

    glfw.window_hint(glfw::WindowHint::ContextVersion(3, 2));
    glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
    glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core));

    let (mut window, events) = glfw.create_window(800, 600, "Example", glfw::WindowMode::Windowed)
        .expect("Failed to create GLFW window.");

    window.make_current();
    glfw.set_error_callback(glfw::FAIL_ON_ERRORS);
    let (mut device, mut factory, color_view, depth_view) = gfx_window_glfw::init(&mut window);

    let mut encoder: gfx::Encoder<_, _> = factory.create_command_buffer().into();
    let pso = factory.create_pipeline_simple(include_bytes!("shader/triangle_120.glslv"),
                                include_bytes!("shader/triangle_120.glslf"),
                                pipe::new())
        .unwrap();
    let (vertex_buffer, slice) = factory.create_vertex_buffer_with_slice(&TRIANGLE, ());
    let data = pipe::Data {
        vbuf: vertex_buffer,
        out: color_view,
    };

    'main: loop {
        glfw.poll_events();

        for (_, event) in glfw::flush_messages(&events) {
            println!("{:?}", event);
            match event {
                glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
                    break 'main;
                }
                _ => {}
            }
        }

        // draw a frame
        encoder.clear(&data.out, CLEAR_COLOR);
        encoder.draw(&slice, &pso, &data);
        encoder.flush(&mut device);
        window.swap_buffers();
        device.cleanup();
    }
}

Full stack trace:

> env RUST_BACKTRACE=1 cargo run
thread 'main' panicked at 'Error after executing command BindProgram(0): InvalidEnum', /home/icefox/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx_device_gl-0.12.0/src/lib.rs:337
stack backtrace:
   1:     0x55fa68e2d12a - std::sys::imp::backtrace::tracing::imp::write::h917062bce4ff48c3
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x55fa68e311af - std::panicking::default_hook::{{closure}}::h0bacac31b5ed1870
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:247
   3:     0x55fa68e2f526 - std::panicking::default_hook::h5897799da33ece67
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:263
   4:     0x55fa68e2fb77 - std::panicking::rust_panic_with_hook::h109e116a3a861224
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:451
   5:     0x55fa68e2fa04 - std::panicking::begin_panic::hbb38be1379e09df0
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:413
   6:     0x55fa68e2f929 - std::panicking::begin_panic_fmt::h26713cea9bce3ab0
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:397
   7:     0x55fa68e0884d - gfx_device_gl::Device::check::h90b1e6010be96c4c
                        at /home/icefox/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx_device_gl-0.12.0/src/lib.rs:337
   8:     0x55fa68e0a5f9 - gfx_device_gl::Device::process::h21bc7ed03a8334a6
                        at /home/icefox/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx_device_gl-0.12.0/src/lib.rs:774
   9:     0x55fa68e0942b - gfx_device_gl::Device::reset_state::h6b8dd3b836e57daf
                        at /home/icefox/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx_device_gl-0.12.0/src/lib.rs:436
  10:     0x55fa68e0cf18 - gfx_device_gl::Device::no_fence_submit::h5387d4f20deb72bd
                        at /home/icefox/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx_device_gl-0.12.0/src/lib.rs:778
  11:     0x55fa68e0de55 - <gfx_device_gl::Device as gfx_core::Device>::submit::hb57ea237c103ce28
                        at /home/icefox/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx_device_gl-0.12.0/src/lib.rs:901
  12:     0x55fa68d1351f - <gfx::encoder::Encoder<R, C>>::flush::hd37e88903533567d
                        at /home/icefox/.cargo/registry/src/github.com-1ecc6299db9ec823/gfx-0.13.0/src/encoder.rs:112
  13:     0x55fa68d33eed - gfx_particles::main::h40e2e46cf7cc27a7
                        at /home/icefox/my.src/gfx-particles/src/main.rs:97
  14:     0x55fa68e38c8a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libpanic_unwind/lib.rs:97
  15:     0x55fa68e30595 - std::rt::lang_start::hd661476ce2fc2931
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:332
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/panic.rs:351
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libstd/rt.rs:57
  16:     0x55fa68d386c2 - main
  17:     0x7f7dee4e22b0 - __libc_start_main
  18:     0x55fa68d00239 - _start
  19:                0x0 - <unknown>

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

For now I’ve just made a fork of gfx and the glfw and sdl examples in that. I’ll sync it with upstream and update the examples whenever it occurs to me, which is all I really need for now. 😼