PistonDevelopers / graphics

A library for 2D graphics, written in Rust, that works with multiple back-ends
MIT License
479 stars 55 forks source link

OpenGL 3.1+ first letter of text rendered wrong #1045

Open rardiol opened 8 years ago

rardiol commented 8 years ago

Not sure if I should report it here, on glium_graphics or somewhere else.

Here's an example of the problem: https://i.imgur.com/pnB6tgv.jpg. Using OpenGL 3.0 avoids the problem. Removing any of the rectangle or image calls makes the text call work correctly.

example code:


extern crate graphics;
extern crate glium;
extern crate glium_graphics;
extern crate piston;

use std::path::Path;

use glium_graphics::{
    Glium2d, GliumWindow, OpenGL, Texture, Flip, TextureSettings, GlyphCache
};
use piston::window::WindowSettings;

use graphics::{color, text, rectangle, image, clear, Transformed};
use graphics::math::Matrix2d;

fn main() {
    let opengl = OpenGL::V3_1;
    let ref mut window: GliumWindow =
        WindowSettings::new("test", [400, 400])
        .exit_on_esc(true).opengl(opengl).fullscreen(false).vsync(false).build().unwrap();
    let mut g2d = Glium2d::new(opengl, window);

    let mut glyp = GlyphCache::new("assets/DejaVuSerif.ttf", window.clone()).unwrap();
    let texture = Texture::from_path(window, Path::new("assets/simple_com.png"), Flip::None, &TextureSettings::new()).unwrap();

    while let Some(e) = window.next() {
        use piston::input::*;
        match e {
            Event::Render(render_args) => {

                let mut target = window.draw();

                g2d.draw(&mut target, render_args.viewport(), |c, g| {
                    clear(color::WHITE, g);
                    let (width, height) = window.get_framebuffer_dimensions();
                    let c = c.trans((width/2) as f64, (height/2) as f64).transform;

                    let target = (0.0, 0.0);
                    let ntp: Matrix2d = c.trans(target.0 as f64, target.1 as f64);

                    rectangle([1.0, 1.0, 0.0, 1.0], [0.0, 0.0, 10.0, 20.0], ntp, g);

                    let target = (30.0, 30.0);
                    let ntp: Matrix2d = c.trans(target.0 as f64, target.1 as f64);

                    image(&texture, ntp, g);

                    rectangle([1.0, 1.0, 0.0, 1.0], [0.0, 0.0, 10.0, 20.0], ntp, g);

                    text([0.0, 0.0, 0.0, 1.0], 12, &"Turn",
                         &mut glyp,
                         c.trans(-200.0, 0.0), g);
                });
                target.finish().unwrap();
            }
            _ => (),
        };
    }
}

simple_com.png: https://imgur.com/2bERNVe.png

rardiol commented 8 years ago

Couldn't reproduce on another pc, running radeon.

Problem is on a linux/nouveau system.