|
Out of curiousity, Allegro 4/5 bitmap dimensions |
Yodhe23
Member #8,726
June 2007
|
I know there will be a really good explanation... But why in Allegro 4 with bitmaps I can just get the height/width of a bitmap It seems a backward step in the pursuit of elegance imho, but as I said I am sure there is a really good explanation why I have to keep typing out so many characters. Which incidentally increases the line length, and is a slight irk when www.justanotherturn.com |
Elias
Member #358
May 2000
|
It's generally accepted that you should use getter and setter functions for field access in an API and never allow directly reading or writing them. -- |
Yodhe23
Member #8,726
June 2007
|
Ahh those general them.... shakes his fist at them and mutters something about buffer overruns in his day were do with trains not coding www.justanotherturn.com |
SiegeLord
Member #7,827
October 2006
|
Making types opaque (only interactable through pointers to them) simplifies the backwards compatibility story. Since 5.0, the internals of ALLEGRO_BITMAP changed significantly, and that would not have been possible if all the variables in that struct were directly accessible. I suppose that doesn't really apply to width/height, since those remained basically the same... but consider al_get_bitmap_flags. By your argument, you'd prefer bitmap->flags, and that was what al_get_bitmap_flags returned... but recently, it got changed to this: int al_get_bitmap_flags(ALLEGRO_BITMAP *bitmap) { if (bitmap->parent) return bitmap->parent->_flags; else return bitmap->_flags; } I.e. sub-bitmaps now inherit flags from the parent. Something like this would not have been possible to do in a backwards compatible way if we let you access that member directly. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
|