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
SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
Hello!

Does anyone else have problems with the screen resolution on IOS 8 with Xcode 6? My application, without any code changes, looked really weird when I built it on the new IOS. The application rendered on the whole iPhone screen before, but is now only rendering in a smaller window, with the rest of the screen being black.

[IMG]http://i.imgur.com/GzQmK70.png?1[/IMG]

Here is my code setting up the window and renderer:
Code:

// Create window
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandescapeRight");
SDL_DisplayMode displayMode;
SDL_GetCurrentDisplayMode(0, &displayMode);
SDL_Window* window = NULL;
window = SDL_CreateWindow(NULL, 0, 0, displayMode.w, displayMode.h,
    SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
if (window == NULL) {
    std::cout << "SDL_CreateWindow ERROR: " << SDL_GetError() << std::endl;
}
   
// Create renderer
SDL_Renderer* renderer = NULL;
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
    std::cout << "SDL_CreateRenderer ERROR: " << SDL_GetError() << std::endl;
}
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
SDL_RenderSetLogicalSize(renderer, 480, 320);


My question is: has anyone else experienced anything like this with the new IOS? And if so, have you found any solutions?

Thanks
Carl
SDL 2 IOS 8 Screen resolution problem
Alex Szpakowski
Guest

Does the problem still happen if you use my fork of SDL containing updates and fixes to its iOS code?


https://bitbucket.org/slime73/sdl-experiments/branch/iOS-improvements
https://bitbucket.org/slime73/sdl-experiments/get/iOS-improvements.zip

On Nov 11, 2014, at 8:58 AM, doctoreamer wrote:
Quote:

My question is: has anyone else experienced anything like this with the new IOS? And if so, have you found any solutions?

Thanks
Carl
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
Thanks for the response. I will try it!
Alex Szpakowski wrote:
Does the problem still happen if you use my fork of SDL containing updates and fixes to its iOS code?


https://bitbucket.org/slime73/sdl-experiments/branch/iOS-improvements
https://bitbucket.org/slime73/sdl-experiments/get/iOS-improvements.zip

On Nov 11, 2014, at 8:58 AM, doctoreamer wrote:
Quote:

My question is: has anyone else experienced anything like this with the new IOS? And if so, have you found any solutions?

Thanks
Carl
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
I built your fork of SDL using the Xcode project. Then I swapped out the original SDL in my project to your version and tried to build. Was not successful, this is the linker error I got:

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_CMMotionManager", referenced from:
objc-class-ref in libSDL2Test.a(SDL_sysjoystick.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do I need to do anything else to make your version work? I'm sorry if it's obvious, I'm new to SDL and IOS development.

Alex Szpakowski wrote:
Does the problem still happen if you use my fork of SDL containing updates and fixes to its iOS code?


https://bitbucket.org/slime73/sdl-experiments/branch/iOS-improvements
https://bitbucket.org/slime73/sdl-experiments/get/iOS-improvements.zip

On Nov 11, 2014, at 8:58 AM, doctoreamer wrote:
Quote:

My question is: has anyone else experienced anything like this with the new IOS? And if so, have you found any solutions?

Thanks
Carl
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL 2 IOS 8 Screen resolution problem
Alex Szpakowski
Guest

Recent versions of SDL for iOS need your app to link with the CoreMotion framework.

On Nov 11, 2014, at 5:01 PM, doctoreamer wrote:
Quote:
I built your fork of SDL using the Xcode project. Then I swapped out the original SDL in my project to your version and tried to build. Was not successful, this is the linker error I got:

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_CMMotionManager", referenced from:
objc-class-ref in libSDL2Test.a(SDL_sysjoystick.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do I need to do anything else to make your version work? I'm sorry if it's obvious, I'm new to SDL and IOS development.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
It worked, the game renders on the whole screen again! Thanks alot for your work on this! Will your fork eventually merge with SDL?

Alex Szpakowski wrote:
Recent versions of SDL for iOS need your app to link with the CoreMotion framework.

On Nov 11, 2014, at 5:01 PM, doctoreamer wrote:
Quote:
I built your fork of SDL using the Xcode project. Then I swapped out the original SDL in my project to your version and tried to build. Was not successful, this is the linker error I got:

Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_CMMotionManager", referenced from:
objc-class-ref in libSDL2Test.a(SDL_sysjoystick.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do I need to do anything else to make your version work? I'm sorry if it's obvious, I'm new to SDL and IOS development.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL 2 IOS 8 Screen resolution problem
Alex Szpakowski
Guest

I hope so! Thanks for testing. Smile

On Nov 11, 2014, at 5:14 PM, doctoreamer wrote:
Quote:
It worked, the game renders on the whole screen again! Thanks alot for your work on this! Will your fork eventually merge with SDL?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
I think I've found a bug with your fork. When I press the home button while the game is running, and then open the application again, the application is "frozen". When the game is frozen the background image is not filling the whole screen and no touch input is handled. None of this happens on the official SDL release (2.0.4).

[img]http://i.imgur.com/paIhoMn.png?1[/img]


Alex Szpakowski wrote:
I hope so! Thanks for testing. Smile

On Nov 11, 2014, at 5:14 PM, doctoreamer wrote:
Quote:
It worked, the game renders on the whole screen again! Thanks alot for your work on this! Will your fork eventually merge with SDL?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[/img]
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
Never mind the image linked, it doesn't show anything on a white background. It was supposed to show how the background image didn't fill the whole screen, and the rest is white.

doctoreamer wrote:
I think I've found a bug with your fork. When I press the home button while the game is running, and then open the application again, the application is "frozen". When the game is frozen the background image is not filling the whole screen and no touch input is handled. None of this happens on the official SDL release (2.0.4).

[img]http://i.imgur.com/paIhoMn.png?1[/img]


Alex Szpakowski wrote:
I hope so! Thanks for testing. Smile

On Nov 11, 2014, at 5:14 PM, doctoreamer wrote:
Quote:
It worked, the game renders on the whole screen again! Thanks alot for your work on this! Will your fork eventually merge with SDL?

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[/img]
SDL 2 IOS 8 Screen resolution problem
Alex Szpakowski
Guest

I can’t reproduce this – sending apps into and out of the background works fine for me, although I’ve been testing with code that uses raw OpenGL (and handles iOS multitasking properly by calling glFinish in SDL_APP_DIDENTERBACKGROUND via an event watch callback.)

On Nov 12, 2014, at 6:03 AM, doctoreamer wrote:
Quote:
I think I've found a bug with your fork. When I press the home button while the game is running, and then open the application again, the application is "frozen". When the game is frozen the background image is not filling the whole screen and no touch input is handled. None of this happens on the official SDL release (2.0.4).

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
I'm not using raw OpenGL, I'm rendering using SDL_Textures and functions like SDL_RenderCopy() instead. Multitasking is not an issue when I'm using official SDL, even though my code does nothing to handle events like SDL_APP_DIDENTERBACKGROUND. I realise that I probably should handle these events anyway, but thought it might be interesting to point out the difference in behaviour.

Is using raw OpenGL much preferable to the SDL rendering methods when building iOS applications?

Thanks alot for your responses!

Alex Szpakowski wrote:
I can’t reproduce this – sending apps into and out of the background works fine for me, although I’ve been testing with code that uses raw OpenGL (and handles iOS multitasking properly by calling glFinish in SDL_APP_DIDENTERBACKGROUND via an event watch callback.)

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL 2 IOS 8 Screen resolution problem
Alex Szpakowski
Guest

I ran the iOS keyboard demo (which uses SDL_Render) and I still can’t reproduce the issue – do you have a minimal test case available?


Using raw OpenGL (ES) is preferable if you need the level of control it gives compared to the SDL_Render API, but if you don’t then SDL_Render should be fine.

On Nov 12, 2014, at 6:29 PM, doctoreamer wrote:
Quote:
I'm not using raw OpenGL, I'm rendering using SDL_Textures and functions like SDL_RenderCopy() instead. Multitasking is not an issue when I'm using official SDL, even though my code does nothing to handle events like SDL_APP_DIDENTERBACKGROUND. I realise that I probably should handle these events anyway, but thought it might be interesting to point out the difference in behaviour.

Is using raw OpenGL much preferable to the SDL rendering methods when building iOS applications?

Thanks alot for your responses!

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
I reproduced the issue with this code:
Code:

#include "SDL.h"
#include <iostream>
#include "SDL_image.h"

int main(int argc, char* args[])
{
    // Initiate SDL
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
    {
        std::cout << "SDL_Init ERROR: " << SDL_GetError() << std::endl;
    }
   
    // Create window
    SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandescapeRight");   
    SDL_DisplayMode displayMode;
    SDL_GetCurrentDisplayMode(0, &displayMode);
    SDL_Window* window = NULL;
    window = SDL_CreateWindow(NULL, 0, 0, displayMode.w, displayMode.h,
            SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
    if (window == NULL)
    {
        std::cout << "SDL_CreateWindow ERROR: " << SDL_GetError() << std::endl;
    }
   
    // Create renderer
    SDL_Renderer* renderer = NULL;
    renderer = SDL_CreateRenderer(window, -1, 0);
    if (renderer == NULL)
    {
        std::cout << "SDL_CreateRenderer ERROR: " << SDL_GetError() << std::endl;
    }
    SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
    SDL_RenderSetLogicalSize(renderer, 480, 320);
 
    // Load texture
    SDL_Texture* texture = NULL;
    std::string filePath = "Textures/MenuSystem/MainMenuBackground.png";
    SDL_Surface* surface = IMG_Load(filePath.c_str());
    if (surface == NULL)
    {
        std::cout << "ERROR IN: FileUtility::loadTexture() - IMG_Load ERROR: " << filePath.c_str() <<  " - " << IMG_GetError() << std::endl;
    }
    else
    {
        texture = SDL_CreateTextureFromSurface(renderer, surface);
        if (texture == NULL)
        {
            std::cout << "ERROR IN: FileUtility::loadTexture() - SDL_CreateTextureFromSurface ERROR: " << filePath.c_str() << " - " << IMG_GetError() << std::endl;
        }
        SDL_FreeSurface(surface);
    }
   
    // Run loop
    bool isRunning = true;
    while (isRunning)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            if (event.type == SDL_QUIT)
            {
                isRunning = false;
            }
        }

        SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
        SDL_RenderClear(renderer);
        SDL_SetRenderDrawColor(renderer, 0xFF, 0, 0, 0xFF);
        SDL_RenderCopy(renderer, texture, NULL, NULL);
        SDL_RenderPresent(renderer);
    }
   
   // Destroy renderer
   SDL_DestroyRenderer(renderer);
   
   // Destroy window
   SDL_DestroyWindow(window);
   
   // Quit SDL
   SDL_Quit();
   
   return 0;
}


Alex Szpakowski wrote:
I ran the iOS keyboard demo (which uses SDL_Render) and I still can’t reproduce the issue – do you have a minimal test case available?


Using raw OpenGL (ES) is preferable if you need the level of control it gives compared to the SDL_Render API, but if you don’t then SDL_Render should be fine.

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL 2 IOS 8 Screen resolution problem
Alex Szpakowski
Guest

Thanks for the test code! My latest commit to the iOS-improvements branch of my repository should fix the issue, I think.

On Nov 18, 2014, at 4:14 PM, doctoreamer wrote:
Quote:
I reproduced the issue with this code: [..]


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Re: SDL 2 IOS 8 Screen resolution problem
doctoreamer


Joined: 08 Oct 2014
Posts: 12
I tried running the program I posted here with your new commit. The issue now happens as soon as I run the app and not only when switching applications.

Alex Szpakowski wrote:
Thanks for the test code! My latest commit to the iOS-improvements branch of my repository should fix the issue, I think.

_______________________________________________
SDL mailing list

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


Joined: 08 Oct 2014
Posts: 12
By the way, I'm testing on a iPhone 4s device.
SDL 2 IOS 8 Screen resolution problem
Alex Szpakowski
Guest

I can’t reproduce it with my branch with my latest commits. When using a simulated iPhone 4s / iOS 8.1, my test image (since I don’t have access to your images) always fills the whole screen, and when using a physical iPad 2 with iOS 8.1 it’s letterboxed to the 480/320 aspect ratio as expected and fills the whole screen aside from that.

On Nov 21, 2014, at 7:27 PM, doctoreamer wrote:
Quote:
I tried running the program I posted here with your new commit. The issue now happens as soon as I run the app and not only when switching applications.

_______________________________________________
SDL mailing list

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