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

Bug texture drawing. #217

Open
Potpourri opened this issue Apr 19, 2015 · 10 comments
Open

Bug texture drawing. #217

Potpourri opened this issue Apr 19, 2015 · 10 comments

Comments

@Potpourri
Copy link
Member

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

@kvark
Copy link
Member

kvark commented Apr 19, 2015

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

@Potpourri
Copy link
Member Author

Hmm, perhaps its broken only for me.

@kvark
Copy link
Member

kvark commented Apr 19, 2015

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

@bvssvni
Copy link
Member

bvssvni commented Apr 22, 2015

@Potpourri which platform are you on?

@Potpourri
Copy link
Member Author

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

@Potpourri
Copy link
Member Author

opengl_graphics and glium_graphics doesn't have this problem.

@Potpourri
Copy link
Member Author

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);
        });
    }
}

@kvark
Copy link
Member

kvark commented Apr 22, 2015

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

@bvssvni
Copy link
Member

bvssvni commented Apr 24, 2015

@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?

@Potpourri
Copy link
Member Author

@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.

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

No branches or pull requests

3 participants