Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vojd committed Aug 22, 2023
1 parent c530b9a commit 4c8df27
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 93 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ cargo watch -x "run --release"

```

### Setup

On Linux it might be required to run to get the UI to render

```bash
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
```

### Run

`cargo run --release shader.glsl`
Expand Down
88 changes: 1 addition & 87 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,90 +118,6 @@ impl App {
app_state.timer.stop();
}
}

// pub fn run(&mut self, config: Config) {
// let App {
// event_loop,
// app_window,
// app_state,
// gl,
// } = self;
//
// let mut ui = Ui::new(event_loop, gl.clone());
//
// let mut actions: Vec<Action> = vec![];
//
// let shader_files = config.files.unwrap();
// log::debug!("Shader files: {:?}", shader_files);
// let mut shader_service = ShaderService::new(gl.clone(), shader_files);
// shader_service.watch();
// let _ = shader_service.run(gl);
//
// let vertex_array = unsafe {
// gl.create_vertex_array()
// .expect("Cannot create vertex array")
// };
//
// while app_state.is_running {
// let _ = shader_service.run(gl);
// app_state.shader_error = shader_service.last_error.clone();
//
// // force UI open if we have a shader error
// if app_state.shader_error.is_some() {
// app_state.ui_visible = true;
// }
//
// if matches!(app_state.play_mode, PlayMode::Playing) {
// app_state.timer.start();
// // TODO(mathias): Remove this. Only use `app_state.timer.delta_time`
// app_state.delta_time = app_state.timer.delta_time;
// }
//
// event_loop.run_return(|event, _, control_flow| {
// *control_flow = ControlFlow::Wait;
//
// // TODO: No unwrap on the window object
// let _repaint_after = ui.run(&app_window.window.unwrap(), |egui_ctx| {
// egui::TopBottomPanel::top("view_top").show(egui_ctx, |ui| {
// top_bar(ui, app_state, &mut actions, &shader_service);
// });
//
// if let Some(error) = &app_state.shader_error {
// let mut error = format!("{}", error);
// egui::TopBottomPanel::bottom("view_bottom").show(egui_ctx, |ui| {
// ui.horizontal(|ui| {
// ui.add(
// egui::TextEdit::multiline(&mut error)
// .font(egui::TextStyle::Monospace)
// .code_editor()
// .desired_rows(4)
// .desired_width(f32::INFINITY)
// .lock_focus(true),
// )
// });
// });
// }
// });
//
// handle_events(&event, control_flow, &mut ui, app_state, &mut actions);
//
// handle_actions(&mut actions, app_state, &mut shader_service, control_flow);
// });
//
// if let Ok(gl) = gl {
// render(
// gl.clone(),
// vertex_array,
// &mut ui,
// app_window,
// app_state,
// &shader_service,
// );
// }
//
// app_state.timer.stop();
// }
// }
}

fn render(
Expand Down Expand Up @@ -283,8 +199,6 @@ fn render(
}
}
}
// TODO: Swap buffers
// app_window.window_context.swap_buffers().unwrap();
// surface.swap_buffers(gl);

app_window.swap_buffers();
}
2 changes: 0 additions & 2 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pub fn handle_events<T>(
actions: &mut Vec<Action>,
) {
*control_flow = ControlFlow::Poll;
// TODO(mathias): Fix!
// context.swap_buffers().unwrap();

match event {
Event::WindowEvent { event, .. } => {
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ fn main() -> anyhow::Result<(), anyhow::Error> {

if config.files.is_some() {
log::info!("loading existing shader");
// app.init(config);
app.run(config);
}
Ok(())
Expand Down
4 changes: 1 addition & 3 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub struct AppWindow {
gl_context: Option<PossiblyCurrentContext>,
gl_surface: Option<Surface<WindowSurface>>,
// glow
// pub gl: Option<Arc<glow::Context>>,

// winit
pub window: Option<Window>,
Expand Down Expand Up @@ -73,6 +72,7 @@ impl AppWindow {

let fallback_context_attributes = ContextAttributesBuilder::new()
// When GlProfile::Core is used at least 3.3 will be used
// TODO(mathias): Take a closer look at how this works and if we can have fallbacks
.with_context_api(ContextApi::OpenGl(None))
.build(raw_window_handle);

Expand All @@ -95,7 +95,6 @@ impl AppWindow {
})
});

// Create and return self and return gl and event_loop
(
Self {
not_current_context,
Expand All @@ -104,7 +103,6 @@ impl AppWindow {
gl_surface: None,
window,
},
// gl,
event_loop,
)
}
Expand Down

0 comments on commit 4c8df27

Please sign in to comment.