Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL 3.1+ first letter of text rendered wrong #1045

Open
rardiol opened this issue Jun 15, 2016 · 1 comment
Open

OpenGL 3.1+ first letter of text rendered wrong #1045

rardiol opened this issue Jun 15, 2016 · 1 comment
Labels

Comments

@rardiol
Copy link

rardiol commented Jun 15, 2016

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

@bvssvni bvssvni added the bug label Jun 15, 2016
@rardiol
Copy link
Author

rardiol commented Jun 17, 2016

Couldn't reproduce on another pc, running radeon.

Problem is on a linux/nouveau system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants