bugsyth_engine

Crates.iobugsyth_engine
lib.rsbugsyth_engine
version0.6.0
created_at2025-02-07 02:06:30.159743+00
updated_at2025-03-21 21:54:53.813499+00
descriptionlittle framework using glium
homepage
repositoryhttps://github.com/bugsyth/bugsyth_engine
max_upload_size
id1546427
size1,574,478
Bugsyth (bugsyth)

documentation

README

More a framework, not an engine Still working on this, most features probably won't work correctly

Uses glium for rendering, fontdue for text rasterization, winit for event handling, and cpal for audio

Example

use bugsyth_engine::prelude::*;

#[derive(Clone, Copy)]
struct Vertex {
    position: [f32; 2],
    color: [f32; 3],
}
implement_vertex!(Vertex, position, color);

fn main() -> EngineResult {
    let (event_loop, mut ctx) = init("Simple", (960, 720))?;
    ctx.new_program(
        "simple",
        "
    in vec2 position;
    in vec3 color;

    out vec3 v_color;

    void main() {
        v_color = color;
        gl_Position = vec4(position, 0.0, 1.0);
    }
    ",
        "
    in vec3 v_color;

    out vec4 color;

    void main() {
        color = vec4(v_color, 1.0);
    }
    ",
        None,
    )
    .unwrap();
    let game = Game {
        tri: Triangle {
            vbo: VertexBuffer::new(
                &ctx.display,
                &[
                    Vertex {
                        position: [-0.5, -0.5],
                        color: [1.0, 0.0, 0.0],
                    },
                    Vertex {
                        position: [0.5, 0.5],
                        color: [0.0, 1.0, 0.0],
                    },
                    Vertex {
                        position: [-0.5, 0.5],
                        color: [0.0, 0.0, 1.0],
                    },
                ],
            )
            .unwrap(),
            ibo: NoIndices(PrimitiveType::TrianglesList),
            draw_params: DrawParameters {
                ..Default::default()
            },
        },
    };
    run(game, event_loop, ctx)?;
    Ok(())
}

struct Game {
    tri: Triangle<'static>,
}

impl GameState for Game {
    fn draw(&mut self, ctx: &mut Context, renderer: &mut impl Renderer) {
        renderer.clear_color(0.0, 0.0, 0.0, 1.0);
        renderer.draw(ctx, &self.tri, &uniform! {}).unwrap();
    }
}

struct Triangle<'a> {
    vbo: VertexBuffer<Vertex>,
    ibo: NoIndices,
    draw_params: DrawParameters<'a>,
}

impl<'a> Drawable for Triangle<'a> {
    fn get_vbo(&self) -> impl MultiVerticesSource {
        &self.vbo
    }
    fn get_ibo(&self) -> impl Into<IndicesSource> {
        &self.ibo
    }
    fn get_program(&self) -> String {
        "simple".to_string()
    }
    fn get_draw_params(&self) -> DrawParameters {
        self.draw_params.clone()
    }
}

More examples here

Commit count: 38

cargo fmt