You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to draw a texture which I've loaded from a file, but when I borrow the code from piston-examples, I get an error saying that the image function, which in the example accepts a piston_window::G2dTexture, is actually expecting an graphics::Graphics::Texture. I don't know how to convert from one to the other, what the difference is, or why the image drawing function wants a different type. I'm using the OpenGL backend, if that helps. Here's the error:
type mismatch resolving `<opengl_graphics::GlGraphics as graphics::Graphics>::Texture == piston_window::Texture<gfx_device_gl::Resources>`
expected struct `opengl_graphics::Texture`, found struct `piston_window::Texture`
note: expected type `opengl_graphics::Texture`
found type `piston_window::Texture<gfx_device_gl::Resources>`
and here's the relevant portions of my code:
for t in tiles {let assets = find_folder::Search::ParentsThenKids(3,3).for_folder("Tiles/").unwrap();let asset = assets.join(t.to_owned() + ".png");let asset:G2dTexture = Texture::from_path(&mut window.factory,&asset,Flip::None,&TextureSettings::new(),).unwrap();
game.texture_map.insert(t.to_owned(), asset);}
and
pubfndisplay_terrain(gl:&mutGlGraphics,args:&RenderArgs,(x, y):Point2D,tile:G2dTexture,){let(iso_x, iso_y) = twod_to_iso((x *64, y *64));image(&tile,[[0.0;3];2], gl);}
There is an intermediary function between the draw call and display_terrain that wraps it in the appropriate self.gl.draw(args.viewport(), |c, g| { /* ... */ });
Any help would be appreciated! Thanks.
The text was updated successfully, but these errors were encountered:
use piston_window::{image, Context, G2d, G2dTexture};
Before, I was importing image from graphics directly iirc, or openGL. What I found out was that piston_window re-exports everything with its own wrappers to work correctly with their types. Just use what piston_window exports.
I'm trying to draw a texture which I've loaded from a file, but when I borrow the code from
piston-examples
, I get an error saying that theimage
function, which in the example accepts apiston_window::G2dTexture
, is actually expecting angraphics::Graphics::Texture
. I don't know how to convert from one to the other, what the difference is, or why the image drawing function wants a different type. I'm using the OpenGL backend, if that helps. Here's the error:and here's the relevant portions of my code:
and
There is an intermediary function between the draw call and
display_terrain
that wraps it in the appropriateself.gl.draw(args.viewport(), |c, g| { /* ... */ });
Any help would be appreciated! Thanks.
The text was updated successfully, but these errors were encountered: