Bug texture drawing.
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
I just tried it and I see two rust logos - it works as expected here.
Hmm, perhaps its broken only for me.
Do you have some local override for gfx-rs? Perhaps, you could provide an apitrace capture for me to look.
@Potpourri which platform are you on?
@bvssvni I'm on Linux with OpenGL 2.1(of course I always change OpenGL over to 2.1).
opengl_graphics and glium_graphics doesn't have this problem.
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);
});
}
}
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
@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 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.