gfx_graphics icon indicating copy to clipboard operation
gfx_graphics copied to clipboard

Bug texture drawing.

Open Potpourri opened this issue 10 years ago • 10 comments

When I try drawing the same texture two or more times, texture will be drawn only first time. Example:

extern crate piston;
extern crate graphics;
extern crate piston_window;
extern crate sdl2_window;
extern crate gfx_device_gl;
extern crate gfx_graphics;

use std::cell::RefCell;
use std::rc::Rc;
use std::path::Path;
use piston::window::WindowSettings;
use piston_window::*;
use gfx_graphics::{ Texture, TextureSettings };
use sdl2_window::{ Sdl2Window, OpenGL };

fn main() {
    let window = Rc::new(RefCell::new(
        Sdl2Window::new(
            OpenGL::_3_2,
            WindowSettings::new(
                "gfx_graphics: image_test",
                [300, 300]
            )
            .exit_on_esc(true)
        )
    ));

    let events = PistonWindow::new(window, empty_app());
    let rust_logo = Texture::from_path(&mut events.canvas.borrow_mut().factory,
                                       &Path::new("./assets/rust.png"),
                                       &TextureSettings::new()).unwrap();
    for e in events {
        use graphics::*;

        e.draw_2d(|c, g| {
            clear([1.0; 4], g);
            image(&rust_logo, c.transform, g);
            image(&rust_logo, c.transform.trans(150.0, 150.0), g);
        });
    }
}

/cc @kvark

Potpourri avatar Apr 19 '15 13:04 Potpourri

I just tried it and I see two rust logos - it works as expected here.

kvark avatar Apr 19 '15 16:04 kvark

Hmm, perhaps its broken only for me.

Potpourri avatar Apr 19 '15 16:04 Potpourri

Do you have some local override for gfx-rs? Perhaps, you could provide an apitrace capture for me to look.

kvark avatar Apr 19 '15 16:04 kvark

@Potpourri which platform are you on?

bvssvni avatar Apr 22 '15 09:04 bvssvni

@bvssvni I'm on Linux with OpenGL 2.1(of course I always change OpenGL over to 2.1).

Potpourri avatar Apr 22 '15 10:04 Potpourri

opengl_graphics and glium_graphics doesn't have this problem.

Potpourri avatar Apr 22 '15 13:04 Potpourri

And this example works too fine:

extern crate piston;
extern crate graphics;
extern crate piston_window;
extern crate sdl2_window;
extern crate gfx_device_gl;
extern crate gfx_graphics;

use std::cell::RefCell;
use std::rc::Rc;
use std::path::Path;
use piston::window::WindowSettings;
use piston_window::*;
use gfx_graphics::{ Texture, TextureSettings };
use sdl2_window::{ Sdl2Window, OpenGL };

fn main() {
    let window = Rc::new(RefCell::new(
        Sdl2Window::new(
            OpenGL::_3_2,
            WindowSettings::new(
                "gfx_graphics: image_test",
                [300, 300]
            )
            .exit_on_esc(true)
        )
    ));

    let events = PistonWindow::new(window, empty_app());
    let rust_logo = Texture::from_path(&mut events.canvas.borrow_mut().factory,
                                       &Path::new("./assets/rust.png"),
                                       &TextureSettings::new()).unwrap();
    let image_2 = Texture::from_path(&mut events.canvas.borrow_mut().factory,
                                     &Path::new("./assets/image2.png"),
                                     &TextureSettings::new()).unwrap();
    for e in events {
        use graphics::*;

        e.draw_2d(|c, g| {
            clear([1.0; 4], g);
            image(&rust_logo, c.transform, g);
            image(&image_2, c.transform.trans(150.0, 0.0), g);
            image(&rust_logo, c.transform.trans(150.0, 150.0), g);
            image(&image_2, c.transform.trans(0.0, 150.0), g);
        });
    }
}

Potpourri avatar Apr 22 '15 13:04 Potpourri

Could someone else also verify that it works (or it doesn't)? It'd be strange if this thing only worked for GL-3.2

kvark avatar Apr 22 '15 13:04 kvark

@Potpourri when I moved shaders to the shaders repo I changed the order of one o_Color parameter in one of the sources to make it more consistent, and I seem to remember @cmr mentioning something about output parameters and order in older versions of OpenGL. Perhaps it could be related to this bug?

bvssvni avatar Apr 24 '15 13:04 bvssvni

@bvssvni I'm not sure. This bug I got before you moved shaders and now nothing has changed. I talks with @kvark and we found that second texture overlaid on first(in uv buffer pass the same data). It is not known why this is happening only on old OpenGL and only with the same texture.

Potpourri avatar Apr 24 '15 13:04 Potpourri