[AD] default values for get_desktop_resolution

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


If get_desktop_resolution fails, the behavior is undefined. I propose
that we define the behavior to not modify the width and height. It
could easily be implemented in a way that system drivers don't even
have to be aware:
----
AL_INLINE(int, get_desktop_resolution, (int *width, int *height),
{
   int w = *width;
   int h = *height;
   ASSERT(system_driver);

   if (system_driver->get_desktop_resolution &&
	   !system_driver->get_desktop_resolution(width, height)) {
     return 0;
   }
   else {
      *width = w;
      *height = h;
      return -1;
   }
})
----
(And maybe it should no longer be "inline," but not like it really matters...)

And it would be nice to do the same thing for desktop_color_depth().
But obviously it returns a value, so it's not possible as is. So
perhaps:

get_desktop_color_depth(int *cd);

And it would work in the same (modified) way as
get_desktop_resolution. desktop_color_depth could be deprecated.

Justification is primarily that 99% of the time you want to default to
some value on failure. Rarely do you care if the call succeeds or not.
The modified behavior of these functions would be especially useful in
cleaning up the examples.

--
Matthew Leverton




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