From: Elias P. <eli...@gm...> - 2010-05-25 13:57:48
|
On Mon, May 17, 2010 at 4:02 AM, Peter Wang <nov...@gm...> wrote: > Probably overdue for one, so I'll make it this weekend. > > Are we ready to call it a beta? > Just remembered something we discussed in #allegro some time ago - there's a bit of an API ambiguity with transformation order: al_identity_transform(t); al_translate_transform(t, 100, 0); al_rotate_transform(t, deg2rad(90)); al_use_transform(t); al_draw_pixel(100, 0, red); Someone who did not use any other libraries before Allegro might expect something like this: The pixel is drawn at 100/0, but first gets translated to 200/0, then gets rotated to 0/200. Everyone else probably will expect that the pixel first gets rotated to 0/100 and is then translated to 100/100. It's also what makes more sense usually. For example: draw_ship() { *backup = *t; al_translate_transform(t, ship.x, ship.y); al_rotate_transform(t, ship.angle); al_use_transform(t); al_draw_triangle(...); *t = *backup; } draw_scene() { al_translate_transform(t, cam.x, cam.y); al_rotate_transform(t, cam.angle); draw_ship(); } So I think best will be to rename the functions: al_translate_transform -> al_pre_translate_transform al_rotate_transform -> al_pre_rotate_transform al_scale_transform -> al_pre_scale_transform al_transform_transform -> al_pre_transform_transform This makes clear that whatever transformation is applied to the passed transformation will be done *before* the existing transformation. And maybe we can also have the _post_ versions. |