diff --git a/beppe_online/Cargo.toml b/beppe_online/Cargo.toml
index f09ae56..c3c796e 100644
--- a/beppe_online/Cargo.toml
+++ b/beppe_online/Cargo.toml
@@ -12,16 +12,5 @@ crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2"
-js-sys = "0.3"
-yew = { git = "https://github.com/yewstack/yew/", features = ["csr"] }
+leptos = { version = "0.6.12", features = ["csr"] }
-[dependencies.web-sys]
-version = "0.3"
-features = [
- 'HtmlCanvasElement',
- 'WebGlBuffer',
- 'WebGlProgram',
- 'WebGlRenderingContext',
- 'WebGlShader',
- 'WebGlUniformLocation',
-]
diff --git a/beppe_online/index.html b/beppe_online/index.html
index 202cc6f..a37c733 100644
--- a/beppe_online/index.html
+++ b/beppe_online/index.html
@@ -1,10 +1,6 @@
-
-
- Yew App
-
diff --git a/beppe_online/src/lib.rs b/beppe_online/src/lib.rs
index 7e341e1..a303637 100644
--- a/beppe_online/src/lib.rs
+++ b/beppe_online/src/lib.rs
@@ -1,119 +1,5 @@
-use std::cell::RefCell;
-use std::rc::Rc;
-
-use wasm_bindgen::prelude::*;
-use wasm_bindgen::JsCast;
-use web_sys::{window, HtmlCanvasElement, WebGlRenderingContext as GL, WebGlRenderingContext};
-
-use yew::{html, Component, Context, Html, NodeRef};
-
-
-pub struct App {
- node_ref: NodeRef,
-}
-
-impl Component for App {
- type Message = ();
- type Properties = ();
-
- fn create(_ctx: &Context) -> Self {
- Self {
- node_ref: NodeRef::default(),
- }
- }
-
- fn view(&self, _ctx: &Context) -> Html {
- html! {
-
- }
- }
-
- fn rendered(&mut self, _ctx: &Context, first_renderer: bool) {
- if !first_renderer {
- return;
- }
-
- let canvas = self.node_ref.cast::().unwrap();
- let gl: GL = canvas
- .get_context("webgl")
- .unwrap()
- .unwrap()
- .dyn_into()
- .unwrap();
- Self::render_gl(gl);
- }
-}
-
-impl App {
- fn request_animation_frame(f: &Closure) {
- window()
- .unwrap()
- .request_animation_frame(f.as_ref().unchecked_ref())
- .expect("should register `requestAnimationFrame` OK");
- }
-
- fn render_gl(gl: WebGlRenderingContext) {
-
- let mut timestamp = 0.0;
-
- let vert_code = include_str!("./basic.vert");
- let frag_code = include_str!("./basic.frag");
-
- let vertices: Vec = vec![
- -1.0, -1.0,
- 1.0, -1.0,
- -1.0, 1.0,
- -1.0, 1.0,
- 1.0, -1.0,
- 1.0, 1.0,
- ];
- let vertex_buffer = gl.create_buffer().unwrap();
- let verts = js_sys::Float32Array::from(vertices.as_slice());
-
- gl.bind_buffer(GL::ARRAY_BUFFER, Some(&vertex_buffer));
- gl.buffer_data_with_array_buffer_view(GL::ARRAY_BUFFER, &verts, GL::STATIC_DRAW);
-
- let vert_shader = gl.create_shader(GL::VERTEX_SHADER).unwrap();
- gl.shader_source(&vert_shader, vert_code);
- gl.compile_shader(&vert_shader);
-
- let frag_shader = gl.create_shader(GL::FRAGMENT_SHADER).unwrap();
- gl.shader_source(&frag_shader, frag_code);
- gl.compile_shader(&frag_shader);
-
- let shader_program = gl.create_program().unwrap();
- gl.attach_shader(&shader_program, &vert_shader);
- gl.attach_shader(&shader_program, &frag_shader);
- gl.link_program(&shader_program);
-
- gl.use_program(Some(&shader_program));
-
- let position = gl.get_attrib_location(&shader_program, "a_position") as u32;
- gl.vertex_attrib_pointer_with_i32(position, 2, GL::FLOAT, false, 0, 0);
- gl.enable_vertex_attrib_array(position);
-
- let time = gl.get_uniform_location(&shader_program, "u_time");
- gl.uniform1f(time.as_ref(), timestamp as f32);
-
- gl.draw_arrays(GL::TRIANGLES, 0, 6);
-
- let cb = Rc::new(RefCell::new(None));
-
- *cb.borrow_mut() = Some(Closure::wrap(Box::new({
- let cb = cb.clone();
- move || {
- timestamp += 20.0;
- gl.uniform1f(time.as_ref(), timestamp as f32);
- gl.draw_arrays(GL::TRIANGLES, 0, 6);
- App::request_animation_frame(cb.borrow().as_ref().unwrap());
- }
- }) as Box));
-
- App::request_animation_frame(cb.borrow().as_ref().unwrap());
- }
-
-}
+use leptos::*;
fn main() {
- yew::Renderer::::new().render();
+ mount_to_body(|| view! { "hi"
})
}