Re: [AD] _al_current_display |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: "Coordination of admins/developers of the game programming library Allegro" <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] _al_current_display
- From: "Trent Gamblin" <trent@xxxxxxxxxx>
- Date: Sat, 9 Aug 2008 16:19:10 -0600 (MDT)
On Sat, August 9, 2008 4:13 pm, Peter Hull said:
> Bit of a whinge, but can we deprecate the use of
> _al_current_display?
> I think it's misleading.
> It's used like this: (in lots of places)
> ALLEGRO_BITMAP *al_get_backbuffer(void)
> {
> ASSERT(_al_current_display);
>
> return
> _al_current_display->vt->get_backbuffer(_al_current_display);
> }
> which would be OK if _al_current_display were a global but it's
> actually a macro
> #define _al_current_display al_get_current_display()
> so that function gets called 3 separate times (all right, 2 in
> release
> builds) . al_get_current_display() is non-trivial because it
> accesses
> the thread-local storage stuff, and on OS X that means a call into
> pthreads.
> It may not be a problem but I think it would be clearer to write
> ALLEGRO_BITMAP *al_get_backbuffer(void)
> {
> ALLEGRO_DISPLAY* current = al_get_current_display();
> ASSERT(current);
>
> return current->vt->get_backbuffer(current);
> }
Yes, I had the same thoughts. The only reason it is the way it is
now is because it /used/ to be a global, and it was easier to make
a define rather than change all the code. We should definately phase
it out.
Trent :{)>