Re: [AD] _al_current_display

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


I've submitted a patch to SF.net (it was too long and repetitive to
put on the ML) What I've done is a lot of these:
@@ -411,7 +413,9 @@
  */
 bool al_hide_mouse_cursor(void)
 {
-   return _al_current_display->vt->hide_cursor(_al_current_display);
+   ALLEGRO_DISPLAY *current_display = al_get_current_display();
+   ASSERT(current_display);
+   return current_display->vt->hide_cursor(current_display);
 }

Also can someone check my macro-fu on SCREEN_W/H? (I think this is a
GNU extension)
#ifdef __GNUC__
#define SCREEN_W     (gfx_driver ? gfx_driver->w : ({ ALLEGRO_DISPLAY*
c = al_get_current_display(); c ? c->w : 0;}))
#define SCREEN_H     (gfx_driver ? gfx_driver->h : ({ ALLEGRO_DISPLAY*
c = al_get_current_display(); c ? c->h : 0;}))
#else
#define SCREEN_W     (gfx_driver ? gfx_driver->w :
al_get_current_display() ? al_get_current_display()->w : 0)
#define SCREEN_H     (gfx_driver ? gfx_driver->h :
al_get_current_display() ? al_get_current_display()->h : 0)
#endif          /* ifdef __GNUC__ */

Pete



On Sat, Aug 9, 2008 at 11:19 PM, Trent Gamblin <trent@xxxxxxxxxx> wrote:
> 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 :{)>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> --
> https://lists.sourceforge.net/lists/listinfo/alleg-developers
>




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