edubart/sokol_gp

flip sgp_draw_textured_rect_ex

kariem2k opened this issue · 1 comments

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

Both using negative height or negative scaling should work, but in both you should offset Y to work.
So the options are:

  1. Use negative height in src_rect and while offsetting y by height when using sgp_draw_textured_rect_ex, for example you can can use src_rect = {w, h, -w, -h} to draw it flipped in both axes, whereas normally you would use src_rect = {0, 0, w, h} to draw unflipped.
  2. 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 then sgp_scale(-1.0, -1.0). Also remember to use sgp_push_transform/sgp_pop_transform when transforming space.