Skip to content

Instantly share code, notes, and snippets.

@SlashScreen
Last active February 10, 2020 20:03
Show Gist options
  • Save SlashScreen/306da140be09ef33b566ecffd201059a to your computer and use it in GitHub Desktop.
Save SlashScreen/306da140be09ef33b566ecffd201059a to your computer and use it in GitHub Desktop.
for the problem with dependencies
[package]
name = "raytrace2020"
version = "0.1.0"
authors = ["My real name and email"]
edition = "2018"
[dependencies]
minifb = "0.15.3"
//raytraces an image
//Include
extern crate minifb;
use minifb::{Key, Window, WindowOptions};
//Const
const WIDTH: usize = 640;
const HEIGHT: usize = 360;
//STRUCTS
//Triangle
struct Triangle
{
//Points
v1:Vec<f32>,
v2:Vec<f32>,
v3:Vec<f32>
}
//Mesh
struct Mesh
{
tris:Vec<Triangle> //Array full of Triangle objects
}
//Ray
struct Ray
{
origin:Vec<f32>,
direction:Vec<f32>
}
//FUNCTIONS
//LOOPS
//Main loop
fn main() {
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let mut window = Window::new(
"Test - ESC to exit",
WIDTH,
HEIGHT,
WindowOptions::default(),
)
.unwrap_or_else(|e| {
panic!("{}", e);
});
// Limit to max ~60 fps update rate
window.limit_update_rate(Some(std::time::Duration::from_micros(16600)));
while window.is_open() && !window.is_key_down(Key::Escape) {
for i in buffer.iter_mut() {
*i = 0; // write something more funny here!
}
// We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
window
.update_with_buffer(&buffer, WIDTH, HEIGHT)
.unwrap();
}
}
ERROR:
error[E0463]: can't find crate for `minifb`
--> main.rs:4:1
|
4 | extern crate minifb;
| ^^^^^^^^^^^^^^^^^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
[Done] exited with code=1 in 0.072 seconds
DIRECTORY:
raytrace2020
>Cargo.toml
>Cargo.lock
>src
>>main.rs
>target
>>A bunch of stuff, dont know how important it is
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment