added basic slider for modifying speed

ObjectDef
Milk.H 2023-03-15 16:18:38 +01:00
parent 82bdbdd758
commit f2bb21e569
No known key found for this signature in database
GPG Key ID: 3D9DAE46AAC37BD8
1 changed files with 6 additions and 18 deletions

View File

@ -33,20 +33,6 @@ mod model;
mod camera;
fn main() {
//let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
// glfw.window_hint(glfw::WindowHint::ContextVersion(3, 3));
// glfw.window_hint(glfw::WindowHint::OpenGlProfile(glfw::OpenGlProfileHint::Core));
// glfw.window_hint(glfw::WindowHint::OpenGlForwardCompat(true));
// glfw.window_hint(glfw::WindowHint::Resizable(false));
// glfw.window_hint(glfw::WindowHint::TransparentFramebuffer(false));
// glfw.window_hint(glfw::WindowHint::Decorated(true));
// let (mut window, events) = glfw.create_window(SCR_WIDTH, SCR_HEIGHT, TITLE, glfw::WindowMode::Windowed).unwrap();
//let (screen_width, screen_height) = window.get_framebuffer_size();
let (gl, shader_version, window, mut events_loop, _context) = {
let sdl = match sdl2::init()
{
@ -128,7 +114,8 @@ fn main() {
let time = std::time::Instant::now();
let mut spinSpeed = 1.0;
let mut current_rad = 1.0;
let projection: Matrix4<f32> = perspective(Deg(45.0), SCR_WIDTH as f32/ SCR_HEIGHT as f32, 0.1, 100.0);
println!("entering main loop");
// NOTE main loop here
@ -136,7 +123,7 @@ fn main() {
let currentFrame = time.elapsed().as_secs_f32();
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
current_rad += spinSpeed/15.0;
unsafe{
gl.enable(glow::DEPTH_TEST);
@ -150,8 +137,9 @@ fn main() {
ourshader.setMat4("view", &view);
let mut model: Matrix4<f32> = Matrix4::from_axis_angle(vec3(0.0, -1.0, 0.0).normalize(),
cgmath::Rad(time.elapsed().as_secs_f32()));
cgmath::Rad(current_rad));
model = model * Matrix4::from_scale(0.2);
ourshader.setMat4("model", &model);
@ -169,7 +157,7 @@ fn main() {
.build(|| {
ui.text("you serve no purpose in life");
ui.text("Your Purpose in life is to suck my dick");
ui.slider("The Spin Speed", 0.1, 10.0, &mut spinSpeed);
});
let draw_data = imgui.render();