/* call-seq:
* Screen.get_resolution -> [width, height]
*
* Returns the pixel dimensions of the user's display (i.e. monitor).
* (That is not the same as Screen#size, which only measures the
* Rubygame window.) You can use this information to detect
* how large of a Screen can fit on the user's display.
*
* This method can _only_ be used when there is no open Screen instance.
* This method raises SDLError if there is a Screen instance (i.e.
* you have done Screen.new before). This is a limitation of the SDL
* function SDL_GetVideoInfo, which behaves differently when a Screen
* is open than when it is closed.
*
* This method will also raise SDLError if it cannot get the display
* size for some other reason.
*
*/
VALUE rbgm_screen_getresolution(VALUE module)
{
VALUE array;
const SDL_VideoInfo* hw;
init_video_system();
/* Test for existing Screen */
SDL_Surface *surface;
surface = SDL_GetVideoSurface();
if(surface != NULL)
{
rb_raise(eSDLError, "You cannot get resolution when there is " \
"an open Screen. See the docs for the reason.");
}
hw = SDL_GetVideoInfo();
if(hw==NULL)
{
rb_raise(eSDLError,"Couldn't get video info: %s",SDL_GetError());
}
array = rb_ary_new();
rb_ary_push(array, INT2NUM(hw->current_w));
rb_ary_push(array, INT2NUM(hw->current_h));
return array;
}