The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Retina display support in SDL 2.0.1 not working?
kloffy


Joined: 24 Oct 2013
Posts: 6
I am experimenting with the new HighDPI support on my MacBook Pro with Mac OS X (10.8.5). However, so far I have not managed to get it to work.

Here is the code that I am currently using:

Code:
#include <iostream>

#include <SDL2/SDL.h>

#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>

std::ostream& operator<<(std::ostream& os, SDL_version const& version)
{
    return os <<
        static_cast<int>(version.major) << "." <<
        static_cast<int>(version.minor) << "." <<
        static_cast<int>(version.patch);
}

int main()
{
    SDL_version compiled, linked;
   
    SDL_VERSION(&compiled);
    SDL_GetVersion(&linked);

    std::cout << "Compiled: " << compiled << std::endl;
    std::cout << "Linked: " << linked << std::endl;
   
    SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
   
    SDL_Init(SDL_INIT_VIDEO);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

    auto window = SDL_CreateWindow(
        "SDL2",
        SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480,
        SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI
    );
   
    if (window == nullptr)
    {
        std::cerr << "Could not create window: " << SDL_GetError() << std::endl;
        return 1;
    }

    auto context = SDL_GL_CreateContext(window);

    if (context == nullptr)
    {
        std::cerr << "Could not create context." << std::endl;
        return 1;
    }
   
    int w, h;
    SDL_GL_GetDrawableSize(window, &w, &h);
    std::cout << "Drawable:" << w << "x" << h << std::endl;

    bool done = false;
    SDL_Event event;
    while (!done)
    {
        while ( SDL_PollEvent( &event ) )
        {
            switch ( event.type )
            {
            case SDL_QUIT:
                done = true;
                break;
            }
        }
       
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
       
        SDL_GL_SwapWindow(window);
    }

    SDL_GL_DeleteContext(context);
    SDL_DestroyWindow(window);

    SDL_Quit();
}


The window border is still pixelated and the drawable size is reported as 640x480. I am compiling with Xcode 5.0, just in case that matters. I realize that it is a new feature, but I was under the impression that it should be work in SDL 2.0.1. My questions are: Am I making a mistake? Has anybody else managed to get HighDPI to work?
Retina display support in SDL 2.0.1 not working?
Stefanos A.
Guest

Yes, it is working fine here using 2.0.1 on Mac OS X 10.9.



2013/10/25 kloffy
Quote:
I am experimenting with the new HighDPI support on my MacBook Pro with Mac OS X (10.8.5). However, so far I have not managed to get it to work.

Here is the code that I am currently using:




Code:

#include

#include

#include
#include

std::ostream& operator<<(std::ostream& os, SDL_version const& version)
{
    return os <<
        static_cast(version.major) << "." <<
        static_cast(version.minor) << "." <<
        static_cast(version.patch);
}

int main()
{
    SDL_version compiled, linked;
   
    SDL_VERSION(&compiled);
    SDL_GetVersion(&linked);

    std::cout << "Compiled: " << compiled << std::endl;
    std::cout << "Linked: " << linked << std::endl;
   
    SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
   
    SDL_Init(SDL_INIT_VIDEO);

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);

    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

    auto window = SDL_CreateWindow(
        "SDL2",
        SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480,
        SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI
    );
   
    if (window == nullptr)
    {
        std::cerr << "Could not create window: " << SDL_GetError() << std::endl;
        return 1;
    }

    auto context = SDL_GL_CreateContext(window);

    if (context == nullptr)
    {
        std::cerr << "Could not create context." << std::endl;
        return 1;
    }
   
    int w, h;
    SDL_GL_GetDrawableSize(window, &w, &h);
    std::cout << "Drawable:" << w << "x" << h << std::endl;

    bool done = false;
    SDL_Event event;
    while (!done)
    {
        while ( SDL_PollEvent( &event ) )
        {
            switch ( event.type )
            {
            case SDL_QUIT:
                done = true;
                break;
            }
        }
       
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
       
        SDL_GL_SwapWindow(window);
    }

    SDL_GL_DeleteContext(context);
    SDL_DestroyWindow(window);

    SDL_Quit();
}




The window border is still pixelated and the drawable size is reported as 640x480. I am compiling with Xcode 5.0, just in case that matters. I realize that it is a new feature, but I was under the impression that it should be work in SDL 2.0.1. My questions are: Am I making a mistake? Has anybody else managed to get HighDPI to work?


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

kloffy


Joined: 24 Oct 2013
Posts: 6
Interesting, so you are getting a HighDPI window frame and a 1280x960 drawable? Thank you for testing and confirming that the code is correct. I wonder what stops it from working on my system...
Retina display support in SDL 2.0.1 not working?
urkle


Joined: 23 Sep 2012
Posts: 77
On 10/25/2013 09:41 PM, kloffy wrote:

Quote:
Interesting, so you are getting a HighDPI window frame and a 1280x960 drawable? Thank you for testing and confirming that the code is correct. I wonder what stops it from working on my system...


This is *new* code. it has been tested by a few people (both at Valve and by me). There are some quirks that we'll need to fix. Have you tested the testgl2 "test" code? as that one I know DOES work. Just pass in --allow-hidpi to it. Now.. I do have to ask.. you ARE testing this on a HiDPI capable computer AND are currently in a "retina" resolution right?


Quote:
--
Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-674-3296
Re: Retina display support in SDL 2.0.1 not working?
kloffy


Joined: 24 Oct 2013
Posts: 6
urkle wrote:
This is *new* code. it has been tested by a few people (both at Valve and by me). There are some quirks that we'll need to fix. Have you tested the testgl2 "test" code? as that one I know DOES work. Just pass in --allow-hidpi to it. Now.. I do have to ask.. you ARE testing this on a HiDPI capable computer AND are currently in a "retina" resolution right?

Yes, I am aware that it is new, in fact I mentioned that in my first post. However, I wanted to try it out since it is advertised as a feature of the latest official release (SDL 2.0.1).

The HiDPI support in testgl2 is not working for me either. I testing on a recent MacBook Pro with NVIDIA GeForce GT 650M 1024 MB graphics and a 15-inch retina display (2880x1800).

The main purpose of my post is to see if anybody else can reproduce the problem. If it is not a simple coding error on my behalf, I will consider submitting a bug report.
Retina display support in SDL 2.0.1 not working?
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2013/10/29 Edward Rudd
Quote:

On 10/25/2013 09:41 PM, kloffy wrote:

Quote:
Interesting, so you are getting a HighDPI window frame and a 1280x960 drawable? Thank you for testing and confirming that the code is correct. I wonder what stops it from working on my system...


This is *new* code. it has been tested by a few people (both at Valve and by me). There are some quirks that we'll need to fix.  Have you tested the testgl2 "test" code? as that one I know DOES work.  Just pass in --allow-hidpi to it.  Now.. I do have to ask.. you ARE testing this on a HiDPI capable computer AND are currently in a "retina" resolution right?


Quote:
--
Edward Rudd
OutOfOrder.cc
Skype: outoforder_cc
317-674-3296


testgl2 --allow-highdpi works for fine me on a 13" Iris based  rMBP. However, if I pass --fullscreen to it, forcing a video mode change, in that case the screen changes modes and goes black. Switching back to windowed mode, and into full screen again seems to work, but this is likely because this second full screen mode change is done using the fullscreen-desktop method.

Gabriel.
kloffy


Joined: 24 Oct 2013
Posts: 6
Thank you for providing more detail! It certainly seems like it is an isolated issue on my system. Unfortunately, I have run out of ideas on how to debug it. Anyway, I suppose I'll have to live with low DPI for now. Perhaps the problem will fix itself once I update to Mavericks.
rippon


Joined: 10 Feb 2014
Posts: 6
Did you ever get this working? My Mac builds don't seem to be playing nice with Retina support either - I'm building on Mavericks on my 15" MBP type-R, setting that flag as such:

g_sdlWindow = SDL_CreateWindow("Muteki Application", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 540, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);

No luck, low res app frame, low res rendering. It's not the end of the world, because my game, Dragon Fantasy, already renders at a target resolution of 320x180 because pixels are awesome. But I'd like to make it at least look like the Mac version didn't take a step back when I switched our custom porting libraries out in favor of SDL!
kloffy


Joined: 24 Oct 2013
Posts: 6
Unfortunately, I couldn't get it to work. Good to hear that I'm not the only one having problems, though. So, by the sound of it upgrading to Mavericks wouldn't help me either...
Retina display support in SDL 2.0.1 not working?
gabomdq


Joined: 28 Jul 2011
Posts: 495
Location: Argentina
2014-02-10 14:10 GMT-03:00 rippon:
Quote:
Did you ever get this working? My Mac builds don't seem to be playing nice with Retina support either - I'm building on Mavericks on my 15" MBP type-R, setting that flag as such:

g_sdlWindow = SDL_CreateWindow("Muteki Application", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 540, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);

No luck, low res app frame, low res rendering. It's not the end of the world, because my game, Dragon Fantasy, already renders at a target resolution of 320x180 because pixels are awesome. But I'd like to make it at least look like the Mac version didn't take a step back when I switched our custom porting libraries out in favor of SDL!




Did you try this with SDL from HG? I know that Broken Age for example shipped with Retina support via SDL, and running SDL tests in "high DPI" mode seems to work in my late 2013 13" MBP.



--
Gabriel.
rippon


Joined: 10 Feb 2014
Posts: 6
Haven't tried with the stuff in HG - it hasn't been super important for me yet. When 2.0.2 comes out I'll give that a go and see if it fixes it, and if not I'll poke at it more then.
Retina display support in SDL 2.0.1 not working?
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
We just added SDL high DPI support to the Mac In-Home Streaming client and it looks fantastic. Smile


On Thu, Feb 13, 2014 at 2:05 AM, Gabriel Jacobo wrote:
Quote:



2014-02-10 14:10 GMT-03:00 rippon:
Quote:
Did you ever get this working? My Mac builds don't seem to be playing nice with Retina support either - I'm building on Mavericks on my 15" MBP type-R, setting that flag as such:

g_sdlWindow = SDL_CreateWindow("Muteki Application", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 960, 540, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);

No luck, low res app frame, low res rendering. It's not the end of the world, because my game, Dragon Fantasy, already renders at a target resolution of 320x180 because pixels are awesome. But I'd like to make it at least look like the Mac version didn't take a step back when I switched our custom porting libraries out in favor of SDL!





Did you try this with SDL from HG? I know that Broken Age for example shipped with Retina support via SDL, and running SDL tests in "high DPI" mode seems to work in my late 2013 13" MBP.



--
Gabriel.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Retina display support in SDL 2.0.1 not working?
Daniel Bünzli
Guest

Le lundi, 10 février 2014 à 18:10, rippon a écrit :
Quote:
No luck, low res app frame, low res rendering.

I never tried the high dpi support using SDL_WINDOW_ALLOW_HIGHDPI. But regarding the window frame one problem I had is that it would look fine when the executable was launched on the command line, but low res when wrapped in an .app bundle. This was solved by adding the following key to the app's Info.plist :

<key>NSHighResolutionCapable</key><true/>

In any case see [1] if you need more info about troubleshooting these issue.

Daniel


[1] https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: Retina display support in SDL 2.0.1 not working?
kloffy


Joined: 24 Oct 2013
Posts: 6
Daniel Bünzli wrote:
Le lundi, 10 février 2014 à 18:10, rippon a écrit :
I never tried the high dpi support using SDL_WINDOW_ALLOW_HIGHDPI. But regarding the window frame one problem I had is that it would look fine when the executable was launched on the command line, but low res when wrapped in an .app bundle. This was solved by adding the following key to the app's Info.plist :

<key>NSHighResolutionCapable</key><true/>

That was exactly it. I guess I should have RTFM, but this is easy to miss. Thanks a lot for helping clear that up!