GithubHelp home page GithubHelp logo

learn-opengl-rs's Issues

Return string from GetShaderInfoLog may contain garbage?

On https://github.com/bwasty/learn-opengl-rs/blob/master/src/shader.rs#L107 and related code, we have:

gl::GetShaderInfoLog(shader, 1024, ptr::null_mut(), infoLog.as_mut_ptr() as *mut GLchar);
println!("ERROR::SHADER_COMPILATION_ERROR of type: {}\n{}\n \
     -- --------------------------------------------------- -- ",
    type_,
    str::from_utf8(&infoLog).unwrap());
}

GetShaderInfoLog stores a null-terminated string into infoLog, which may contain garbage after the null terminator. str::from_utf8() may fail if the garbage in infoLog contains invalid unicode values.

Failed to watch for joystick connections

I love the JoeyDeVries tutorials, they've helped me understand opengl - I've worked through them in C++ and ported some of them to Vala. So I was happy to see this port.

But when I try this code using cargo run 1_1_1 I get an error from glfw::init:

thread 'main' panicked at 'GLFW Error: Linux: Failed to watch for joystick connections in /dev/input: No such file or directory', /home/darkoverlordofdata/.cargo/registry/src/github.com-1ecc6299db9ec823/glfw-0.23.0/src/lib.rs:392:5

and then my desktop is messed up - I'm unable to close or open any application windows.
They still work - I opened my text editor first and was able to cust and paste the error. But I can't close the text editor, and when I type exit in the console, the window just becomes unresponsive. The only way I can find to clear it up is to reboot,

When I try the original, here: https://github.com/JoeyDeVries/LearnOpenGL/blob/master/src/1.getting_started/1.1.hello_window/hello_window.cpp, it works as expected.

I'm running rustc 1.38.0 (625451e37 2019-09-23) on Debian Buster.

Question about c_str use

Hey, Sorry not an issue, just a question and Im not sure how else to ask.

Ive been trying to do the same thing you did here in this repo for that opengl tutorial. I was stuck with no real errors.

I was doing this gl::GetUniformLocation(shader.id, "model".as_ptr() as *const i8); and it was working until 1_6_1.

If you look at some of your code like 1_6_1 you use a macro to create a CStr.

If i did something like

gl::GetUniformLocation(shader.id, "model".as_ptr() as *const i8);
gl::GetUniformLocation(shader.id, "view".as_ptr() as *const i8);

My square wouldn't render. I copied your macro for cstr and it worked.

How did you figure out that you needed to use a CStr in that function the way you did?

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1

I get this error quite a few times when i try to build any of the lessons for example cargo run _1_1_hello_window the full error is below

WARN rustc_codegen_ssa::back::link Linker does not support -no-pie command line option. Retrying without.
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.0.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.1.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.10.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.11.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.12.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.13.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.14.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.15.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.2.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.3.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.4.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.5.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.6.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.7.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.8.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.build_script_build.253ad390-cgu.9.rcgu.o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.3xe3r320o5t2g1tt.rcgu.o" "-L" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\deps" "-L" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,--start-group" "-Wl,-Bstatic" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-9075868f02c39105.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-9428c324e8b3666b.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-4a98078f239020c3.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-6757767b31fe77e1.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-c0d2da11c6d2d6c0.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-9e7d4e8bc407ad15.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-da42fc4024365a2c.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-89ac367f33223d21.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-d506a327105b7f9b.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-59684a51af165391.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-76b6cbab8df641fe.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-1f71fd1e2c1fff1d.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-941c197b7acaf3f9.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-ed65eeea771bb49a.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-206ecc270c58e4f3.rlib" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-1063c1f162c501e3.rlib" "-Wl,--end-group" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-3f91c8bbaf203c3c.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lws2_32" "-lbcrypt" "-ladvapi32" "-luserenv" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "C:\\Users\\peter\\Desktop\\Rust_Programming\\Code\\Opengl_Lessons\\learn-opengl-rs\\target\\debug\\build\\num-complex-1d9dcc0a2e0581fe\\build_script_build-1d9dcc0a2e0581fe.exe" "-Wl,--gc-sections" "-nodefaultlibs" "C:\\Users\\peter\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = 
note: C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/5.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh
          collect2.exe: error: ld returned 1 exit status

I have updated my c++ 2019 redistributable and installed CMake and restarted my PC which solved several other errors but not this one. I am running windows 10 and I have added C:\TDM-GCC-64\bin to the path. Thanks

[1_3_3] Why subtract 1 from the length of the infoLog vector?

I was writing a shader class and ran into an issue with calling the gl::GetShaderInfoLog and getting it to populate a Vec with the contents of the log. After running through the code a few times, I noticed that my length variable was being altered by the function call, but for some reason the vector would remain empty.

When I looked at the examples in this repo, I noticed that the infoLog parameter is first called with Vec::with_capacity(1024), and then resized straight after with set_len(1024 - 1). When I added this, everything worked fine.

See below:

        let vertex_shader = gl::CreateShader(gl::VERTEX_SHADER);
        let fragment_shader = gl::CreateShader(gl::FRAGMENT_SHADER);

        let mut compile_success = 0;
        let mut log = Vec::<u8>::with_capacity(1024);
        // If I comment the below line, my log variable is empty after GetShaderInfoLog
        log.set_len(1024-1);
        let mut log_length = 0;

        // Vertex shader
        gl::ShaderSource(vertex_shader, 1, &vertex_source_c.as_ptr(), ptr::null());
        gl::CompileShader(vertex_shader);
        gl::GetShaderiv(vertex_shader, gl::COMPILE_STATUS, &mut compile_success);
        if compile_success == 0 {
            gl::GetShaderInfoLog(vertex_shader, 1024, &mut log_length, log.as_mut_ptr() as *mut i8);
            log.truncate(log_length as usize);
            panic!("Vertex Shader Compile Failed:\n{}", std::str::from_utf8(&log).unwrap());
        }

What is the reasoning for setting the length to 1 - original_length and why does OpenGL not do anything without this?

Can't run any tut after hello triangle

    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `/home/xavier/Code/rust_gl/learn-opengl-rs/target/debug/learn-opengl-rs 2_1`
thread 'main' panicked at 'Failed to open src/_2_lighting/shaders/1.colors.vs', src/shader.rs:26:33
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

I am getting this on every tut when running, but the failing files are there ... any ideas ?

Cant run any example after 1_4_1

thread '<unnamed>' panicked at 'attempted to leave type `nodrop::NoDrop<(epoch::Epoch, garbage::Bag)>` uninitialized, which is invalid', /home/nick/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:671:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Segmentation fault

os : linux debian 10
version: rustc 1.51.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.