How do I open a vulkan window in rust using glfw? I get the error GLFW Error: GLX:…
- User
How do I open a vulkan window in rust using glfw? I get the error
GLFW Error: GLX: Failed to load GLXwhen I try with let (mut window, events) = glfw .create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed) .expect("Failed to create GLFW window."); - Assistant
- User
fn get_required_extensions(glfw: &glfw::Glfw) -> Vec<*const std::os::raw::c_char> { glfw.get_required_instance_extensions() .unwrap() .iter() .map(|ext| ext.as_ptr()) .collect::<Vec<>>() }
gives the error
74 | .collect::() | ^^^ expected at least 1 generic argument
- Assistant
- User
74 | .collect::<Vec<*const std::os::raw::c_char>>() | ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value of type
Vec<*const i8>cannot be built fromstd::iter::Iterator<Item=*const u8> - Assistant
- User
73 | .map(|ext| *ext as *const std::os::raw::c_char) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ an
asexpression can only be used to convert between primitive types or to coerce to a specific trait object - Assistant
- User
error[E0605]: non-primitive cast:
Stringas*const i8--> src/main.rs:73:20 | 73 | .map(|ext| *ext as *const std::os::raw::c_char) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ anasexpression can only be used to convert between primitive types or to coerce to a specific trait objectNO NEED TO PASTE THE WHOLE CODE FILE, JUST CHANGED PARTS
- Assistant
I see, my previous solution involved a mistaken assumption about the type returned by
get_required_instance_extensions. The method returnsVec<String>instead ofVec<*const u8>. To convert theStringvalues to*const std::os::raw::c_char, we need to convert the RustStringto a C-compatibleCStringand then acquire its pointer.Here's a corrected version of the
get_required_extensionsfunction: - User
error[E0133]: call to unsafe function
ash::Entry::loadis unsafe and requires unsafe function or block --> src/main.rs:18:17 | 18 | let entry = ash::Entry::load().unwrap(); | ^^^^^^^^^^^^^^^^^^ call to unsafe function - Assistant
- User
Is there no way to safely load the Entry?
- Assistant
- User
I got the code compiling, but I now get the error Instance creation error: ERROR_EXTENSION_NOT_PRESENT
- Assistant
- User
error[E0061]: this method takes 1 argument but 0 arguments were supplied --> src/main.rs:36:14 | 36 | .enumerate_instance_extension_properties() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- an argument of type
Option<&CStr>is missing - Assistant
- User
I have all the required extensions available
- Assistant
- User
I'm using NixOS with the following buildinputs to a flake:
buildInputs = with pkgs; [ glfw cmake xorg.libX11 xorg.libXrandr xorg.libXinerama xorg.libXcursor xorg.libXi vulkan-headers vulkan-loader ];Am I missing something that causes this?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.