Re: [AD] Meaning of the texture coordinates for the primitives addon

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, Sep 6, 2009 at 4:39 PM, Peter Wang <novalazy@xxxxxxxxxx> wrote:
No takers?  Scaling a bitmap is obviously just a subset of texture
mapping, so I think this makes sense.  Most of the time you want to
scale the whole of a source bitmap, so it would be more convenient
to pass (0,0,1,1) instead of (0,0,sw,sh), too.

But why do you want to use different coordinates for target and source?

al_set_target_bitmap(A);
al_draw_line(20, 20, 70, 70);
al_set_target_bitmap(B);
al_draw_bitmap_region(A, 20, 20, 50, 50, 0, 0);

With your change, it would be:

al_set_target_bitmap(A);
al_draw_line(20, 20, 70, 70);
al_set_target_bitmap(B);
al_draw_bitmap_region(A, 20 / al_get_bitmap_width(A), 20 / al_get_bitmap_height(A), 50 / al_get_bitmap_width(A), 50 / al_get_bitmap_height(A), 0, 0);

Not nice at all. Changing it only for _scaled/_rotated and not for _region also is no solution, now suddenly you'd have to remember for each function which kind of coordinates it expects. Same for the primitives addon - whether I use al_draw_bitmap_region or al_draw_prim to draw the 50x50 pixel rectangle from bitmap A into bitmap B shouldn't use a different coordinate system or we end up with a mess like in A4.

If we always use pixels we should be fine, if we always use normalized coordinates we should be as well. As a user, there is no need to remember for each function or figure it out with trial and error - you know what to expect.

Always using pixels for *target* and always using normalized for *source* coordinates is a possibility, but as my example above shows, it's a bit confusing.

So, I still think we should use pixels everywhere, but allow the user to easily change it (with al_use_transform).


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/