I'm using the SLD2 crate in order to create a simple physics simulation/engine. I want to use the "gfx"
feature for getting the framerate and drawing primitives. I understand that I need to include the "SDL2_gfx.lib"
file in C:\Users\{Your Username}\.rustup\toolchains\{current toolchain}\lib\rustlib\{current toolchain}\lib
exactly like the "SLD2.lib"
installation. The problem is that I can't find the required "SDL2_gfx.lib"
file. The repository directs me to this gfx download source. However, I can't seem to find any ".lib"
file in that folder whatsoever. I tried building the "SLD2_gfx"
solution (found in said folder) with Visual Studio Code in order to get a ".lib"
file but that failed because of missing header files. I'm unfamiliar with C/C++ or Visual Studio Code, so I can't fix the solution either. How can I get the "SDL2_gfx.lib"
file and/or associated ".dll"
files?
This is the code I've got so far:
use sdl2::{pixels::Color, event::Event, keyboard::Keycode, rect::{Rect, Point}};
use sdl2::gfx::*;
const WIDTH: u32 = 1000;
const HEIGHT: u32 = 700;
const RECT_SIZE: u32 = 30;
pub fn main() {
let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let window = video_subsystem.window("Physics Sim", WIDTH, HEIGHT)
.position_centered()
.build()
.unwrap();
let width = window.size().0;
let height = window.size().1;
let mut canvas = window.into_canvas().build().unwrap();
canvas.set_draw_color(Color::RGB(0, 0, 0));
canvas.clear();
canvas.present();
let mut event_pump = sdl_context.event_pump().unwrap();
let mut i = 0;
let mut rect = Rect::from_center(Point::new(width as i32 / 4, height as i32 / 4), RECT_SIZE, RECT_SIZE);
let rect_border_width = 1;
'running: loop {
i = (i + 1) % 255;
canvas.set_draw_color(Color::RGB(0, 0, 0));
canvas.clear();
// Inside of rect
canvas.set_draw_color(Color::RGB(i, 64, 255 - i));
canvas.fill_rect(rect).unwrap();
// Border of rect
canvas.set_draw_color(Color::RGB(255, 255, 255));
canvas.draw_rect(rect).unwrap();
for event in event_pump.poll_iter() {
match event {
Event::Quit {..} |
Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
break 'running
},
_ => {}
}
}
// game loop
let rect_y = rect.y();
if rect_y + rect_border_width + RECT_SIZE as i32 <= height as i32 {
rect.set_y(rect_y);
}
canvas.present();
::std::thread::sleep(std::time::Duration::new(0, 1_000_000_000u32 / 60));
} }
The Cargo.toml
:
[dependencies]
sdl2 = {version = "0.35.2", default-features = false, features = ["gfx"]}
And the error I'm getting:
note: LINK : fatal error LNK1181: cannot open input file 'SDL2_gfx.lib'