Incorrect drawable size for fullscreen OpenGL window on OS X?

Hi,

I’m having a bit of trouble creating a fullscreen OpenGL window on OS
X, and have reduced it to a fairly minimal test case (please see the
attached program sdl_fullscreen.c).

When I run it on my computer, I get the following output:

9 display modes
display mode #0: 2880x1800
display mode #1: 2560x1600
display mode #2: 2048x1280
display mode #3: 1680x1050
display mode #4: 1440x900
display mode #5: 1280x800
display mode #6: 1024x768
display mode #7: 800x600
display mode #8: 640x480
drawable size: 1440x810

Please note that 1680x1050 (which is the window size requested by the
program) is reported as supported, but that the drawable size ends up
at 1440x810.

Making matters stranger, I can make it work by changing
SDL_WINDOW_FULLSCREEN to SDL_WINDOW_FULLSCREEN_DESKTOP, in which case
the drawable size does become 1680x1050 (which is also my desktop
resolution) as expected.

Is this a bug in SDL, or am I doing something wrong?

I am using SDL 2.0.1 on OS X 10.9. My computer is a 15" Retina MacBook
Pro with dual graphics cards: Intel HD Graphics 4000 and Nvidia
GeForce GT 650M.

Best regards,

Jesper S?rnesj?
-------------- next part --------------
A non-text attachment was scrubbed…
Name: sdl_fullscreen.c
Type: text/x-csrc
Size: 957 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140218/9ca33a29/attachment.c

I’ve looked into this further, and have discovered two things:

  1. The test case, as written, passes on the very same machine
    running Windows 7, so this seems to be an OS X-specific problem.

  2. I noticed that the game Eldritch, which uses SDL for its Mac port
    [1], does not have this problem, so I contacted David Pittman and
    asked for advice. With his help, I found that if I replace this…

    SDL_Window* window = SDL_CreateWindow("", 0, 0, 1680, 1050,
    SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
    SDL_GLContext context = SDL_GL_CreateContext(window);

… with this…

SDL_Window* window = SDL_CreateWindow("", 0, 0, 1680, 1050,

SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN);
SDL_GLContext context = SDL_GL_CreateContext(window);
SDL_ShowWindow(window);

… everything works! But why? Is this a bug in SDL?

Best regards,

Jesper S?rnesj?

[1] http://www.dphrygian.com/wordpress/?p=104On Tue, Feb 18, 2014 at 8:08 PM, Jesper S?rnesj? <@Jesper_Sarnesjo> wrote:

I’m having a bit of trouble creating a fullscreen OpenGL window on OS
X, and have reduced it to a fairly minimal test case (please see the
attached program sdl_fullscreen.c).

When I run it on my computer, I get the following output:

9 display modes
display mode #0: 2880x1800
display mode #1: 2560x1600
display mode #2: 2048x1280
display mode #3: 1680x1050
display mode #4: 1440x900
display mode #5: 1280x800
display mode #6: 1024x768
display mode #7: 800x600
display mode #8: 640x480
drawable size: 1440x810

Please note that 1680x1050 (which is the window size requested by the
program) is reported as supported, but that the drawable size ends up
at 1440x810.