can change models now
parent
f4b4295df1
commit
aed0b606c2
27
src/debug.rs
27
src/debug.rs
|
@ -7,12 +7,24 @@ const MODELS: [&str; 3]= ["resources/models/TestCarModel/CarW4.obj", "resources/
|
|||
"resources/models/TestCarModel/CarW0.obj"];
|
||||
|
||||
|
||||
|
||||
|
||||
pub enum dEvent
|
||||
{
|
||||
loadModel(i32),
|
||||
exit,
|
||||
}
|
||||
|
||||
|
||||
pub struct Debug {
|
||||
imgui: imgui::Context,
|
||||
renderer: AutoRenderer,
|
||||
platform: SdlPlatform,
|
||||
selectedModel: i32
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Debug {
|
||||
pub fn new(gl: std::sync::Arc<glow::Context>) -> Debug
|
||||
{
|
||||
|
@ -31,7 +43,8 @@ impl Debug {
|
|||
Debug {
|
||||
imgui,
|
||||
renderer,
|
||||
platform
|
||||
platform,
|
||||
selectedModel: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,11 +54,11 @@ impl Debug {
|
|||
}
|
||||
|
||||
pub fn drawImgui(&mut self, events_loop: &sdl2::EventPump, window: &sdl2::video::Window,
|
||||
tempData: &mut crate::scene::tempData, Car: &crate::model::Model)
|
||||
tempData: &mut crate::scene::tempData, Car: &crate::model::Model) -> Vec<dEvent>
|
||||
{
|
||||
self.platform.prepare_frame(&mut self.imgui, &window, &events_loop );
|
||||
let ui = self.imgui.new_frame();
|
||||
let mut hello = String::new();
|
||||
let mut ret = Vec::<dEvent>::new();
|
||||
|
||||
ui.window("POLY I WILL FUCKING")
|
||||
.size([500.0, 100.0], imgui::Condition::FirstUseEver)
|
||||
|
@ -55,10 +68,11 @@ impl Debug {
|
|||
ui.slider("The Spin Speed", 0.1, 10.0, &mut tempData.spinSpeed);
|
||||
if ui
|
||||
.button("Quit") {
|
||||
hello = String::from("cannot quit from here");
|
||||
|
||||
ret.push(dEvent::exit);
|
||||
}
|
||||
ui.text(hello);
|
||||
if ui.list_box("Select Model to Load", &mut self.selectedModel, &MODELS, 5) {
|
||||
ret.push(dEvent::loadModel(self.selectedModel));
|
||||
}
|
||||
});
|
||||
|
||||
ui.window("Stats")
|
||||
|
@ -80,6 +94,7 @@ impl Debug {
|
|||
|
||||
self.renderer.render(draw_data).unwrap();
|
||||
|
||||
ret
|
||||
}
|
||||
|
||||
}
|
||||
|
|
15
src/scene.rs
15
src/scene.rs
|
@ -95,6 +95,7 @@ impl Scene{
|
|||
self.tempData.deltaTime = self.tempData.currentFrame - self.tempData.lastFrame;
|
||||
self.tempData.lastFrame = self.tempData.currentFrame;
|
||||
self.tempData.current_rad += self.tempData.spinSpeed/15.0;
|
||||
let mut ret = SceneEnum::Resume;
|
||||
|
||||
unsafe {
|
||||
self.gl.enable(glow::DEPTH_TEST);
|
||||
|
@ -115,10 +116,20 @@ impl Scene{
|
|||
self.Car.Draw(&self.shaders[0]);
|
||||
|
||||
if self.tempData.DebugMode{
|
||||
self.debug.drawImgui(&events_loop, &window, &mut self.tempData, &self.Car);
|
||||
for command in self.debug.drawImgui(&events_loop, &window, &mut self.tempData, &self.Car)
|
||||
{
|
||||
use crate::debug::dEvent;
|
||||
match command
|
||||
{
|
||||
dEvent::exit => ret = SceneEnum::Exit,
|
||||
dEvent::loadModel(i) => {
|
||||
self.Car = Model::new(MODELS[i as usize], Arc::clone(&self.gl));
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut ret = SceneEnum::Resume;
|
||||
for event in events_loop.poll_iter() {
|
||||
if self.tempData.DebugMode {
|
||||
self.debug.handle(&event);
|
||||
|
|
Loading…
Reference in New Issue