flip sgp_draw_textured_rect_ex
kariem2k opened this issue · 1 comments
kariem2k commented
Hello,
I was wondering if there is a way to flip the textures drawn by sgp_draw_textured_rect_ex? I tried sending negative w,h and but does not work. Also, I don't think negative scaling will work?
Thanks
edubart commented
Both using negative height or negative scaling should work, but in both you should offset Y to work.
So the options are:
- Use negative height in
src_rect
and while offsettingy
byheight
when usingsgp_draw_textured_rect_ex
, for example you can can usesrc_rect = {w, h, -w, -h}
to draw it flipped in both axes, whereas normally you would usesrc_rect = {0, 0, w, h}
to draw unflipped. - Use negative scale, but negative scale will invert the orientation of axes, so you must also translate coordinate system by the viewport size before scaling, this means you can use something like
sgp_translate(sapp_width(), sapp_height())
and thensgp_scale(-1.0, -1.0)
. Also remember to usesgp_push_transform/sgp_pop_transform
when transforming space.