1

I can't find a single useful thing from any Google search about SDL (2.0) supporting retina displays. Could anyone point me in the right direction?

I'm using this code:

//Start SDL
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Window *screen = NULL;
    SDL_Renderer *render = NULL;
    SDL_Texture *texture = NULL;
    SDL_Event e;
    bool quit = false;
    screen = SDL_CreateWindow("Sample Image",100,100,500,500,SDL_WINDOW_SHOWN);
    render = SDL_CreateRenderer(screen,-1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    texture = IMG_LoadTexture(render,"image.bmp");
    if (texture == NULL)
    {
        printf("%s",IMG_GetError());
    }
    //Render all graphics
    SDL_RenderClear(render);
    SDL_RenderCopy(render,texture,NULL,NULL);
    SDL_RenderPresent(render);
    while (quit == false) {
        while (SDL_PollEvent(&e)) {
            if (e.type == SDL_QUIT)
                quit = true;
        }
    }
    //Remove all graphics from memory
    SDL_DestroyRenderer(render);
    SDL_DestroyTexture(texture);
    SDL_DestroyWindow(screen);
    //Quit SDL
    SDL_Quit();
Sabinni
  • 11
  • 2
  • Does it need to support them? AFAIK you just start SDL with a large display mode (2560×1600 for 13' macbook pro), and draw to the screen as normal. There is no special support needed. It's just a high quality screen. – w4etwetewtwet Jul 29 '13 at 09:14
  • Hmm, seems no such support exists. – Sabinni Jul 29 '13 at 10:51
  • What do you mean by no such support? There is no difference between a Retina and normal display, it's just bigger and better quality, SDL is exactly the same. – w4etwetewtwet Jul 29 '13 at 10:52
  • Maybe he's talking about control over the scaling? – Steven Lu Jul 29 '13 at 13:30
  • Pixel doubling. Things look very pixelated in SDL. Apparently a pixel is equivalent to a point (2x2 pixels) in SDL2. So how would I go about using actual pixels? – Sabinni Jul 30 '13 at 01:45
  • Could you provide a source for that claim? I've never seen anything to suggest that a pixel in SDL is anything other than a pixel. – Haz Jul 31 '13 at 20:10
  • @Haz Myself. I'm using SDL2 on my retina Macbook Pro and everything is pixelated in a window. – Sabinni Aug 01 '13 at 06:57
  • Could you show us the code you're using? – Haz Aug 02 '13 at 05:30
  • Done, I added it to the OP. It's not the whole file but you get the gist. – Sabinni Aug 05 '13 at 23:33
  • possible duplicate of [SDL 2.0 retina mac](http://stackoverflow.com/questions/18544881/sdl-2-0-retina-mac) – genpfault Aug 18 '15 at 14:35

1 Answers1

2
SDL_Window* win = SDL_CreateWindow("test",
    SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 600, 480,
    SDL_WINDOW_RESIZABLE|SDL_WINDOW_OPENGL|SDL_WINDOW_ALLOW_HIGHDPI);

the "SDL_WINDOW_ALLOW_HIGHDPI" flag can do it for you.

ZhuYaDong
  • 191
  • 1
  • 5