made it rotate

pull/1/head
Milk.H 2023-03-02 10:59:09 +01:00
parent c2b85150ed
commit 074c58231a
No known key found for this signature in database
GPG Key ID: 3D9DAE46AAC37BD8
2 changed files with 13 additions and 19 deletions

View File

@ -22,7 +22,7 @@ use self::Camera_Movement::*;
// Default camera values
const YAW: f32 = -90.0;
const PITCH: f32 = 0.0;
const PITCH: f32 = -20.0;
const SPEED: f32 = 2.5;
const SENSITIVTY: f32 = 0.1;
const ZOOM: f32 = 45.0;

View File

@ -41,7 +41,7 @@ fn main() {
let mut camera = camera::Camera {
Position: Point3::new(0.0, 0.25, 1.0),
Position: Point3::new(0.0, 0.40, 1.0),
Pitch: -20.0,
..camera::Camera::default()
};
@ -56,14 +56,6 @@ fn main() {
gl::load_with(|ptr| window.get_proc_address(ptr) as *const _);
unsafe{
gl::Enable(gl::DEPTH_TEST);
gl::DepthFunc(gl::LESS);
gl::Enable(gl::STENCIL_TEST);
gl::StencilFunc(gl::NOTEQUAL, 1, 0xFF);
gl::StencilOp(gl::KEEP, gl::KEEP, gl::REPLACE);
};
let (ourshader, ourModel) = unsafe {
gl::Enable(gl::DEPTH_TEST);
@ -78,19 +70,21 @@ fn main() {
let projection: Matrix4<f32> = perspective(Deg(45.0), SCR_WIDTH as f32/ SCR_HEIGHT as f32, 0.1, 100.0);
println!("entering main loop");
unsafe {gl::StencilOp(gl::KEEP, gl::KEEP, gl::REPLACE);}
while !window.should_close() {
let currentFrame = glfw.get_time() as f32;
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
process_events(&events, &mut firstMouse, &mut lastX, &mut lastY, &mut camera);
processInput(&mut window, deltaTime, &mut camera);
unsafe {
gl::Enable(gl::DEPTH_TEST);
gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT | gl::STENCIL_BUFFER_BIT);
gl::ClearColor(1.0, 1.0, 1.0, 1.0);
gl::ClearColor(0.0, 0.0, 0.0, 0.0);
// outline
ourshader.Use();
let Projection: Matrix4<f32> = perspective(Deg(camera.Zoom), SCR_WIDTH as f32 / SCR_HEIGHT as f32, 0.1, 100.0);
@ -99,14 +93,13 @@ fn main() {
ourshader.setMat4(&CString::new("view").unwrap(), &view);
let mut model = Matrix4::<f32>::from_translation(vec3(0.0, -0.3, 0.0));
//let mut model = Matrix4::<f32>::from_translation(vec3(0.0, -0.3, 0.0));
let mut model: Matrix4<f32> = Matrix4::from_axis_angle(vec3(0.0, -1.0, 0.0).normalize(),
cgmath::Rad(glfw.get_time() as f32));
model = model * Matrix4::from_scale(0.2);
ourshader.setMat4(&CString::new("model").unwrap(), &model);
gl::StencilFunc(gl::NOTEQUAL, 1, 0xFF);
gl::StencilMask(0x00);
//gl::Disable(gl::DEPTH_TEST);
ourModel.Draw(&ourshader);
gl::Enable(gl::DEPTH_TEST);
}
@ -123,7 +116,7 @@ fn main() {
if window.get_key(Key::Escape) == Action::Press {
window.set_should_close(true)
}
/*
if window.get_key(Key::W) == Action::Press {
camera.ProcessKeyboard(camera::Camera_Movement::FORWARD, deltaTime);
}
@ -136,6 +129,7 @@ fn main() {
if window.get_key(Key::D) == Action::Press {
camera.ProcessKeyboard(camera::Camera_Movement::RIGHT, deltaTime);
}
*/
}
fn process_events(events: &Receiver<(f64, glfw::WindowEvent)>,