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 have a weird use case for piston2d-graphics, where I'm making draw calls without a game loop, because I'm generating a batch of one-off images in a headless OpenGL context. The problem is that, given a glutin::HeadlessContext with dimensions widthxheight, I don't know how to construct a graphics::Viewport that covers exactly that rectangle.
For clarity, here's where my code diverges from regular code. Where a lot of sample code suggests something like
I instead use code like this, because I don't have a window or event loop:
letmut glgraphics = GlGraphics::new(opengl);let viewport = Viewport{rect:[0,0, width, height],// pretty sure this is wrong!draw_size:[width asu32, height asu32],window_size:[width asu32, height asu32],};for _ insome_iterator(){
glgraphics.draw(&viewport, |c, g| {/* what I'd like to write is graphics::image(&some_texture, c.transform, g); but to make sure my viewport coordinates are sensible I currently write */
graphics::Rectangle::new([1.0,1.0,1.0,1.0]).draw([0.0,0.0,1000.0,1000.0],&c.draw_state, c.transform, g);// and, spoiler, they're not});}
The resulting image shows the square stretched out of shape, and partially off the horizontal edge it should be aligned to, and I'm pretty sure it's the result of my initial viewport dimensions being wrong.
The text was updated successfully, but these errors were encountered:
I have a weird use case for piston2d-graphics, where I'm making draw calls without a game loop, because I'm generating a batch of one-off images in a headless OpenGL context. The problem is that, given a
glutin::HeadlessContext
with dimensionswidth
xheight
, I don't know how to construct a graphics::Viewport that covers exactly that rectangle.For clarity, here's where my code diverges from regular code. Where a lot of sample code suggests something like
I instead use code like this, because I don't have a window or event loop:
The resulting image shows the square stretched out of shape, and partially off the horizontal edge it should be aligned to, and I'm pretty sure it's the result of my initial viewport dimensions being wrong.
The text was updated successfully, but these errors were encountered: