1. Anders Ruud
  2. love
  3. Issues

Issues

Issue #40 resolved

Get desktop resolution within love.conf(t)

FelipeBudinich
created an issue

It would be pretty nice if we could get the user's desktop resolution this way (or something like that):

{{{ t.screen.width = "desktop" t.screen.height = "desktop" }}}

I propose that we call SDL_GetVideoInfo before calling SDL_SetVideoMode, that way it gives the current desktop values.

This way, we could failproof the fullscreen mode, (it would fail only if the user is using a dual or triple monitor setup, but that is an SDL shortcoming), and also we could easily letterbox our games if we don't want stretching.

Comments (12)

  1. FelipeBudinich reporter

    "is it reasonable to expect people to have that?"

    From my Windows centric point of view, yes.

    but not really reasonable for the rest, at least for a while, i guess it will become more common in the next year or so.

    (by the way, sorry for all the changes, i'm not used to this system)

  2. Andrzej Giniewicz

    Maybe use 0 for width and height? It leaves current desktop resolution and is supported from SDL 1.2.10 and up (it means from May 2006). If we need values, there is current_w and current_h in the SDL_VideoInfo after video initialization. See SDL release notes for details. Though I doubt it was documented, I know it works as I tested it before.

  3. Andrzej Giniewicz

    interesting... I just runned

    #include "SDL/SDL.h"
    
    int main() {
      SDL_Init(SDL_INIT_VIDEO);
      SDL_SetVideoMode(0,0,0,SDL_OPENGL);
      SDL_Delay(2000);
      SDL_Quit();
      return 0;
    }
    

    and it just works (in both windowed and fullscreen mode, with autodetected width, height and depth)... what way you tested it?

    edit: I guess I know, maybe you entered those in love.conf? I can say that I wasn't testing this - only on library side. Maybe the width/height is used in many places not only during setting video mode? I don't know - wasn't reading love code.

  4. Andrzej Giniewicz

    Actually I just entered zeros in love.conf and it indeed does not work - no window.

    I think that it's due to use of width/height in glViewport right after video initialization (i.e. glViewport(0,0,0,0)) and further in code - it can be easily avoided by using stuff like:

    const SDL_VideoInfo* videoinfo = SDL_GetVideoInfo();
    width = videoinfo->current_w
    height = videoinfo->current_h
    

    after video mode is created, to get values that are automatically detected by 0 width/height. I just tested, and by adding those to previous sample in C/C++ and printing width/height, I get desktop resolution even that I used 0/0 in SDL_SetVideoMode.

  5. Andrzej Giniewicz

    Ah, one thing - SDL_GetVideoInfo does not require 1.2.13 - current its form does. But width/height was available since 1.2.10 - in docs there is:

    "Width and height of the current video mode, or of the desktop mode if SDL_GetVideoInfo was called before SDL_SetVideoMode (available since SDL 1.2.10)" at http://www.libsdl.org/cgi/docwiki.cgi/SDL_VideoInfo - and there are lots of samples with SDL_GetVideoInfo that dates to 2006 and earlier (though earlier samples does not include width/height).

  6. Log in to comment