~zanneth/bedside

1dea38bcb54661bbb683cbb8f778ea3309cf361c — Charles Magahern 7 months ago 67d4052
Fix text rendering bug on some systems
2 files changed, 13 insertions(+), 5 deletions(-)

M src/main.rs
M src/texture.rs
M src/main.rs => src/main.rs +6 -5
@@ 97,13 97,13 @@ fn main() {
    clock.material = Some(MaterialComponent::with_color(&Color::WHITE));
    scene.add_entity(clock);

    // initialize two buttons
    // scene.add_entity(create_button(Vec3::new(100.0, 200.0, 0.0), Color::RED));
    // scene.add_entity(create_button(Vec3::new(100.0, 500.0, 0.0), Color::GREEN));

    // initialize border entity
    scene.add_entity(create_border(&screen_rect));

    // initialize two buttons
    scene.add_entity(create_button(Vec3::new(100.0, 200.0, 0.0), Color::RED));
    scene.add_entity(create_button(Vec3::new(100.0, 500.0, 0.0), Color::GREEN));

    // add a spinning square
    let mut square = Entity::new();
    let square_id = square.id;


@@ 135,6 135,7 @@ fn create_button(pos: Vec3, color: Color) -> Entity {
        height: 100.0
    };
    let mut button = Entity::new();
    button.name = Some("button".into());
    button.transform = Some(TransformComponent::with_position(&pos));
    button.path = Some(PathBuilder::new()
        .move_to(0.0, 0.0)


@@ 175,7 176,7 @@ fn create_border(bounds: &Rect) -> Entity {

    const BORDER_MARGIN:    f32 = 20.0;
    const BORDER_ANGLE_GAP: f32 = 40.0;
    const BORDER_THICKNESS: f32 = 2.0;
    const BORDER_THICKNESS: f32 = 3.0;

    let rect = Rect {
        x:      bounds.x + BORDER_MARGIN,

M src/texture.rs => src/texture.rs +7 -0
@@ 26,8 26,13 @@ impl Texture {
                _           => gl::BGR,
            }
        };
        let pixel_format = surface.pixel_format_enum();
        let pitch = surface.pitch() as i32 / pixel_format.byte_size_per_pixel() as i32;

        unsafe {
            gl::PixelStorei(gl::UNPACK_ALIGNMENT, 1);
            gl::PixelStorei(gl::UNPACK_ROW_LENGTH, pitch as i32);

            gl::GenTextures(1, &mut name);
            gl::BindTexture(gl::TEXTURE_2D, name);



@@ 49,6 54,8 @@ impl Texture {
                    pixels.as_ptr().cast()      /* data */
                );
            });

            gl::PixelStorei(gl::UNPACK_ROW_LENGTH, 0);
        }

        Self {