Best Practices for landscaped mode on iOS

Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm

For what it’s worth, I’m using landscape mode with Maelstrom with no hacks
and it’s working fine here… ?On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai wrote:

Hi All,

I know landscaped mode is not officially supported in the iOS build, but
like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually
landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode,
though it is not rotated, just showing a landscape screen at the bottom of
a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a
common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by
rotating manually once. It looks like the iOS device knows it is in
landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view
controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote:> For what it’s worth, I’m using landscape mode with Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <gorm at kotoristudios.com (gorm at kotoristudios.com)> wrote:

Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.?

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once.?It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees??

Cheers,
Gorm


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME
screenshot 1: http://imgur.com/J2FbO

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
GormOn Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote:
For what it’s worth, I’m using landscape mode with Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote:
Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won’t need to send SDL any hints as well.

gormlai wrote:> Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME (http://imgur.com/VQbME)
screenshot 1: http://imgur.com/J2FbO (http://imgur.com/J2FbO)

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

  	 	What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation? 

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote:	For what it's worth, I'm using landscape mode with Maelstrom with no hacks and it's working fine here... ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote:	 Hi All, 

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO, that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won’t need to send SDL any hints as well.

gormlai wrote:
Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME
screenshot 1: http://imgur.com/J2FbO

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote:
What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote: For what it’s worth, I’m using landscape mode with Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote: Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

the width and height need to be changed globally

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote:> So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO (http://imgur.com/J2FbO), that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

  	 	Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won't need to send SDL any hints as well. 








gormlai wrote:	Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME (http://imgur.com/VQbME)
screenshot 1: http://imgur.com/J2FbO (http://imgur.com/J2FbO)

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote:	 		 	What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation? 

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote:	For what it's worth, I'm using landscape mode with Maelstrom with no hacks and it's working fine here... ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote:	 Hi All, 

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

That is exactly, what I am doing, and as I said everything is good after the first first manual rotation.On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

the width and height need to be changed globally

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote:
So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO, that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote:
Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won’t need to send SDL any hints as well.

gormlai wrote: Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME
screenshot 1: http://imgur.com/J2FbO

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote: What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote: For what it’s worth, I’m using landscape mode with Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote: Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You running it on simulator or actual device? I don’t have the actual device with me but I ran it from the simulator and everything works fine, I even downloaded the latest SDL from mercurial just to make sure there was no bug in SDL and it started up in landscape mode.

gormlai wrote:> That is exactly, what I am doing, and as I said everything is good after the first first manual rotation.

On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

  	 	the width and height need to be changed globally 

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote:	So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO (http://imgur.com/J2FbO), that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote:	 		 	Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won't need to send SDL any hints as well. 








gormlai wrote:	Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME (http://imgur.com/VQbME)
screenshot 1: http://imgur.com/J2FbO (http://imgur.com/J2FbO)

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote:	 		 	What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation? 

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote:	For what it's worth, I'm using landscape mode with Maelstrom with no hacks and it's working fine here... ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote:	 Hi All, 

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

I actually just pulled the latest build from mercurial as well.

One big difference though could be that I am using a device (I have a lot of other small libraries that doesn’t run in the simulator atm).

I would be super interested if anyone had a minimal iOS opengl landscape example (Though the official read me still does say it is not supported :-), which was why I phrased this as a best practices question).

Best,
GormOn Sunday, September 9, 2012 at 7:14 PM, stevo5800 wrote:

You running it on simulator or actual device? I don’t have the actual device with me but I ran it from the simulator and everything works fine, I even downloaded the latest SDL from mercurial just to make sure there was no bug in SDL and it started up in landscape mode.

gormlai wrote:
That is exactly, what I am doing, and as I said everything is good after the first first manual rotation.

On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

Quote:
the width and height need to be changed globally

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote: So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO, that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote: Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won’t need to send SDL any hints as well.

gormlai wrote: Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME
screenshot 1: http://imgur.com/J2FbO

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote: What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote: For what it’s worth, I’m using landscape mode with Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote: Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I don’t know about minimal, but you can grab Maelstrom:
http://hg.libsdl.org/Maelstrom

I think you need to comment out one thing before it compiles on iOS, but
other than that it should work fine.On Sun, Sep 9, 2012 at 11:21 AM, Gorm Lai wrote:

I actually just pulled the latest build from mercurial as well.

One big difference though could be that I am using a device (I have a lot
of other small libraries that doesn’t run in the simulator atm).

I would be super interested if anyone had a minimal iOS opengl landscape
example (Though the official read me still does say it is not supported
:-), which was why I phrased this as a best practices question).

Best,
Gorm

On Sunday, September 9, 2012 at 7:14 PM, stevo5800 wrote:

You running it on simulator or actual device? I don’t have the actual
device with me but I ran it from the simulator and everything works fine, I
even downloaded the latest SDL from mercurial just to make sure there was
no bug in SDL and it started up in landscape mode.

gormlai wrote: That is exactly, what I am doing, and as I said everything
is good after the first first manual rotation.

On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

Quote: the width and height need to be changed globally

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote: So, I tried switching the parameters, and it has no effect.
The game is always in portrait mode on startup. The call that seems to
decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the
bottom of the screen (with the upper part black) like in the screenshot
here http://imgur.com/J2FbO, that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode
screen. This is independent of whether or not I switch the parameters in
the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape
mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote: Try switching the width and height then it will force it to start
in landscape mode so lets say native res is w = 768; height = 1024 reverse
them to w = 1024; h = 768, then the only rotation it will register is the
opposite side that is same width and height, you won’t need to send SDL any
hints as well.

gormlai wrote: Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care
to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes
only.

The problem is only on startup. I have linked to 2 screenshots. The first
is trivial and just shows the iPad showing the default launch screen in the
correct orientation on launch. The second screenshot shows the game on
startup until any screen rotations has been provoked. The screenshot
clearly shows that it is either the app/SDL thinking it is in the wrong
screen mode, while the SDK knows it is in landscape mode as the welcome
greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME
screenshot 1: http://imgur.com/J2FbO

Also, I can force the screen to rotate into the correct orientation by
simply rotating the device manually with my hands, after which everything
works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote: What view is giving you issues the SDL or new UIView? Does your app
only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape
mode to get my app to start in landscape I flipped the Width and Height and
it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of
notice without that flag the window does indeed still resize but only if
it’s the opposite same width and height(perfect for my app). The way I
programmed the view in my example, my new UIView did not auto rotate was
kinda scratching my head onto why it would not pick up rotation, problem
was simple I added a view to the window but SDL also has a view there, so
I’m putting in a second view, according to Apple documentation, only one
viewcontroller will respond to rotations and thats the first one(SDL view).
Not a big deal since it then tells me I could add the view to the current
SDL view in instead of adding it to the window, so now any rotations SDL
does your other UIView will rotate with it, so no more need of manual
rotation like I did before.

Sam Lantinga wrote: For what it’s worth, I’m using landscape mode with
Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote: Hi All,

I know landscaped mode is not officially supported in the iOS build, but
like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually
landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode,
though it is not rotated, just showing a landscape screen at the bottom of
a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a
common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by
rotating manually once. It looks like the iOS device knows it is in
landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view
controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

No one can confirm that iPad rotations work or do not work properly on the actual device? I’m a little confused here rotation works properly for me on simulator iPad and iPod, and on iPod and iPhone device. iPad is the only device I do not have. I don’t see much difference in maelstrom seems like you just flipped the width and height. Correct me if I’m wrong he is complaining about the app not starting in landscape mode, so to get the app to start in landscape mode all you need to do is reverse the width and width height right? Well thats what I’m doing and I know many others doing the same thing to get there app to start in landscape mode. So what’s bothering me is what is making he’s app have this weird effect?

Sam Lantinga wrote:> I don’t know about minimal, but you can grab Maelstrom:http://hg.libsdl.org/Maelstrom (http://hg.libsdl.org/Maelstrom)

I think you need to comment out one thing before it compiles on iOS, but other than that it should work fine.

On Sun, Sep 9, 2012 at 11:21 AM, Gorm Lai <gorm at kotoristudios.com (gorm at kotoristudios.com)> wrote:

I actually just pulled the latest build from mercurial as well.

One big difference though could be that I am using a device (I have a lot of other small libraries that doesn’t run in the simulator atm).

I would be super interested if anyone had a minimal iOS opengl landscape example (Though the official read me still does say it is not supported :-), which was why I phrased this as a best practices question).

Best,
Gorm

On Sunday, September 9, 2012 at 7:14 PM, stevo5800 wrote:

  	 	You running it on simulator or actual device? I don't have the actual device with me but I ran it from the simulator and everything works fine, I even downloaded the latest SDL from mercurial just to make sure there was no bug in SDL and it started up in landscape mode. 








gormlai wrote:	That is exactly, what I am doing, and as I said everything is good after the first first manual rotation.

On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

Quote: 	 		 	the width and height need to be changed globally 

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote:	So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO (http://imgur.com/J2FbO), that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote:	 		 	Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won't need to send SDL any hints as well. 








gormlai wrote:	Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME (http://imgur.com/VQbME)
screenshot 1: http://imgur.com/J2FbO (http://imgur.com/J2FbO)

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote:	 		 	What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation? 

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote:	For what it's worth, I'm using landscape mode with Maelstrom with no hacks and it's working fine here... ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote:	 Hi All, 

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

Thanks, Sam for the link. I have taken a look at the code, and after comparing with my own code and trying a few settings, I am pretty sure it has to do with my use of OpenGL.

The main offending piece of code looks to be glViewport. As an example on the iPad 1, the parameters resolve to glViewport(0,0,1024,768) which gives me the wide screen but still in portrait mode (with some of the picture not visible). If I use glViewport(0,0,768,1024) then I get a normal portrait mode.

To me this indicates there is an NSOpenGLView or the like, that haven’t figured out, the screen has rotated yet?

I use OpenGL 2.0 (so all matrices, etc are set up in shaders), and also render targets are used a lot.

Thanks for hanging in there for me so far guys. Did I mention I used the SDL1.2 almost all the time through its existence? :slight_smile:

Cheers,
GormOn Wednesday, September 12, 2012 at 10:33 AM, stevo5800 wrote:

No one can confirm that iPad rotations work or do not work properly on the actual device? I’m a little confused here rotation works properly for me on simulator iPad and iPod, and on iPod and iPhone device. iPad is the only device I do not have. I don’t see much difference in maelstrom seems like you just flipped the width and height. Correct me if I’m wrong he is complaining about the app not starting in landscape mode, so to get the app to start in landscape mode all you need to do is reverse the width and width height right? Well thats what I’m doing and I know many others doing the same thing to get there app to start in landscape mode. So what’s bothering me is what is making he’s app have this weird effect?

Sam Lantinga wrote:
I don’t know about minimal, but you can grab Maelstrom:http://hg.libsdl.org/Maelstrom

I think you need to comment out one thing before it compiles on iOS, but other than that it should work fine.

On Sun, Sep 9, 2012 at 11:21 AM, Gorm Lai <> wrote:

Quote:
I actually just pulled the latest build from mercurial as well.

One big difference though could be that I am using a device (I have a lot of other small libraries that doesn’t run in the simulator atm).

I would be super interested if anyone had a minimal iOS opengl landscape example (Though the official read me still does say it is not supported , which was why I phrased this as a best practices question).

Best,
Gorm

On Sunday, September 9, 2012 at 7:14 PM, stevo5800 wrote:

Quote:
You running it on simulator or actual device? I don’t have the actual device with me but I ran it from the simulator and everything works fine, I even downloaded the latest SDL from mercurial just to make sure there was no bug in SDL and it started up in landscape mode.

gormlai wrote: That is exactly, what I am doing, and as I said everything is good after the first first manual rotation.

On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

Quote: the width and height need to be changed globally

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote: So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO, that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote: Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won’t need to send SDL any hints as well.

gormlai wrote: Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME
screenshot 1: http://imgur.com/J2FbO

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote: What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote: For what it’s worth, I’m using landscape mode with Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote: Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

That might be another difference from mine and yours I’m using OpenGL 1.0 renderer

gormlai wrote:> Thanks, Sam for the link. I have taken a look at the code, and after comparing with my own code and trying a few settings, I am pretty sure it has to do with my use of OpenGL.

The main offending piece of code looks to be glViewport. As an example on the iPad 1, the parameters resolve to glViewport(0,0,1024,768) which gives me the wide screen but still in portrait mode (with some of the picture not visible). If I use glViewport(0,0,768,1024) then I get a normal portrait mode.

To me this indicates there is an NSOpenGLView or the like, that haven’t figured out, the screen has rotated yet?

I use OpenGL 2.0 (so all matrices, etc are set up in shaders), and also render targets are used a lot.

Thanks for hanging in there for me so far guys. Did I mention I used the SDL1.2 almost all the time through its existence? :slight_smile:

Cheers,
Gorm

On Wednesday, September 12, 2012 at 10:33 AM, stevo5800 wrote:

  	 	No one can confirm that iPad rotations work or do not work properly on the actual device? I'm a little confused here rotation works properly for me on simulator iPad and iPod, and on iPod and iPhone device. iPad is the only device I do not have. I don't see much difference in maelstrom seems like you just flipped the width and height. Correct me if I'm wrong he is complaining about the app not starting in landscape mode, so to get the app to start in landscape mode all you need to do is reverse the width and width height right? Well thats what I'm doing and I know many others doing the same thing to get there app to start in landscape mode. So what's bothering me is what is making he's app have this weird effect? 








Sam Lantinga wrote:	I don't know about minimal, but you can grab Maelstrom:http://hg.libsdl.org/Maelstrom (http://hg.libsdl.org/Maelstrom)

I think you need to comment out one thing before it compiles on iOS, but other than that it should work fine.

On Sun, Sep 9, 2012 at 11:21 AM, Gorm Lai <> wrote:

Quote:	 I actually just pulled the latest build from mercurial as well. 

One big difference though could be that I am using a device (I have a lot of other small libraries that doesn’t run in the simulator atm).

I would be super interested if anyone had a minimal iOS opengl landscape example (Though the official read me still does say it is not supported [Image: http://forums.libsdl.org/images/smiles/icon_smile.gif ], which was why I phrased this as a best practices question).

Best,
Gorm

On Sunday, September 9, 2012 at 7:14 PM, stevo5800 wrote:

Quote:	 		 	You running it on simulator or actual device? I don't have the actual device with me but I ran it from the simulator and everything works fine, I even downloaded the latest SDL from mercurial just to make sure there was no bug in SDL and it started up in landscape mode. 








gormlai wrote:	That is exactly, what I am doing, and as I said everything is good after the first first manual rotation.

On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

Quote: 	 		 	the width and height need to be changed globally 

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote:	So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO (http://imgur.com/J2FbO), that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote:	 		 	Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won't need to send SDL any hints as well. 








gormlai wrote:	Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME (http://imgur.com/VQbME)
screenshot 1: http://imgur.com/J2FbO (http://imgur.com/J2FbO)

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote:	 		 	What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation? 

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote:	For what it's worth, I'm using landscape mode with Maelstrom with no hacks and it's working fine here... ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote:	 Hi All, 

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

Unfortunately, it looks like I am starting to agree with you stevo. I made a minimal example to prove the behavior to you guys, but (unfortunately for my ego) so far it looks like it is behaving like it should.

I will have to dig further into this, to figure out what it is I am doing that is causing this behavior.On Friday, September 14, 2012 at 7:59 AM, stevo5800 wrote:

That might be another difference from mine and yours I’m using OpenGL 1.0 renderer

gormlai wrote:
Thanks, Sam for the link. I have taken a look at the code, and after comparing with my own code and trying a few settings, I am pretty sure it has to do with my use of OpenGL.

The main offending piece of code looks to be glViewport. As an example on the iPad 1, the parameters resolve to glViewport(0,0,1024,768) which gives me the wide screen but still in portrait mode (with some of the picture not visible). If I use glViewport(0,0,768,1024) then I get a normal portrait mode.

To me this indicates there is an NSOpenGLView or the like, that haven’t figured out, the screen has rotated yet?

I use OpenGL 2.0 (so all matrices, etc are set up in shaders), and also render targets are used a lot.

Thanks for hanging in there for me so far guys. Did I mention I used the SDL1.2 almost all the time through its existence?

Cheers,
Gorm

On Wednesday, September 12, 2012 at 10:33 AM, stevo5800 wrote:

Quote:
No one can confirm that iPad rotations work or do not work properly on the actual device? I’m a little confused here rotation works properly for me on simulator iPad and iPod, and on iPod and iPhone device. iPad is the only device I do not have. I don’t see much difference in maelstrom seems like you just flipped the width and height. Correct me if I’m wrong he is complaining about the app not starting in landscape mode, so to get the app to start in landscape mode all you need to do is reverse the width and width height right? Well thats what I’m doing and I know many others doing the same thing to get there app to start in landscape mode. So what’s bothering me is what is making he’s app have this weird effect?

Sam Lantinga wrote: I don’t know about minimal, but you can grab Maelstrom:http://hg.libsdl.org/Maelstrom

I think you need to comment out one thing before it compiles on iOS, but other than that it should work fine.

On Sun, Sep 9, 2012 at 11:21 AM, Gorm Lai <> wrote:

Quote: I actually just pulled the latest build from mercurial as well.

One big difference though could be that I am using a device (I have a lot of other small libraries that doesn’t run in the simulator atm).

I would be super interested if anyone had a minimal iOS opengl landscape example (Though the official read me still does say it is not supported , which was why I phrased this as a best practices question).

Best,
Gorm

On Sunday, September 9, 2012 at 7:14 PM, stevo5800 wrote:

Quote: You running it on simulator or actual device? I don’t have the actual device with me but I ran it from the simulator and everything works fine, I even downloaded the latest SDL from mercurial just to make sure there was no bug in SDL and it started up in landscape mode.

gormlai wrote: That is exactly, what I am doing, and as I said everything is good after the first first manual rotation.

On Sunday, September 9, 2012 at 6:38 PM, stevo5800 wrote:

Quote: the width and height need to be changed globally

example

//global variables
#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

window = SDL_CreateWindow(0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS |
SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN);
if (!window) {
printf(“Could not initialize Window\n”);
//return 1;
}

ctx = SDL_GL_CreateContext(window);

glClearColor(0, 0, 0, 0);
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 1, -1 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gormlai wrote: So, I tried switching the parameters, and it has no effect. The game is always in portrait mode on startup. The call that seems to decide what happens is the call to glViewport

if I call glViewport(0,0,width,height) it creates a rectangle in the bottom of the screen (with the upper part black) like in the screenshot here http://imgur.com/J2FbO, that I posted before.

If I use glViewport(0,0,height,width) it creates a full portrait mode screen. This is independent of whether or not I switch the parameters in the call to SDL_CreateWindow

It looks to me like the OpenGL context has discovered it is in landscape mode the first manual rotation happens. Would this be a possibility?

On Sunday, September 9, 2012 at 5:53 PM, stevo5800 wrote:

Quote: Try switching the width and height then it will force it to start in landscape mode so lets say native res is w = 768; height = 1024 reverse them to w = 1024; h = 768, then the only rotation it will register is the opposite side that is same width and height, you won’t need to send SDL any hints as well.

gormlai wrote: Thanks for the answers so far. To answer:

The app is only supposed to work in landscape mode. I have also taken care to avoid SDL_WINDOW_RESIZABLE

The setup I currently use is:

unsigned int windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL;
#if defined(IOS)
windowFlags |= SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN;
SDL_SetHint(“SDL_HINT_ORIENTATIONS”, “LandscapeLeft LandscapeRight”);
#endif

This works as expected, and I can force rotation to either landscape modes only.

The problem is only on startup. I have linked to 2 screenshots. The first is trivial and just shows the iPad showing the default launch screen in the correct orientation on launch. The second screenshot shows the game on startup until any screen rotations has been provoked. The screenshot clearly shows that it is either the app/SDL thinking it is in the wrong screen mode, while the SDK knows it is in landscape mode as the welcome greeting from GameCenter is shown with the correct orientation.

screenshot 0: http://imgur.com/VQbME
screenshot 1: http://imgur.com/J2FbO

Also, I can force the screen to rotate into the correct orientation by simply rotating the device manually with my hands, after which everything works as expected.

I have also set the landscape modes in the plist.

Any ideas?,
Gorm

On Sunday, September 9, 2012 at 4:56 PM, stevo5800 wrote:

Quote: What view is giving you issues the SDL or new UIView? Does your app only work in landscape mode or you support all rotation?

Not sure if this is your problem also but, my app only runs in landscape mode to get my app to start in landscape I flipped the Width and Height and it rotate for you automatic, so no SDL_WINDOW_RESIZABLE. As you might of notice without that flag the window does indeed still resize but only if it’s the opposite same width and height(perfect for my app). The way I programmed the view in my example, my new UIView did not auto rotate was kinda scratching my head onto why it would not pick up rotation, problem was simple I added a view to the window but SDL also has a view there, so I’m putting in a second view, according to Apple documentation, only one viewcontroller will respond to rotations and thats the first one(SDL view). Not a big deal since it then tells me I could add the view to the current SDL view in instead of adding it to the window, so now any rotations SDL does your other UIView will rotate with it, so no more need of manual rotation like I did before.

Sam Lantinga wrote: For what it’s worth, I’m using landscape mode with Maelstrom with no hacks and it’s working fine here… ?

On Sat, Sep 8, 2012 at 2:50 AM, Gorm Lai <> wrote:

Quote: Hi All,

I know landscaped mode is not officially supported in the iOS build, but like most people I kinda got it to work.

I have now started to remove and refactor some of my hacks, and actually landscaped mode seems to work great now, except when the app starts up.

In this case, the screen is shown in portrait mode on the iPad mode, though it is not rotated, just showing a landscape screen at the bottom of a portrait mode (imagine a 768x1024 and 1024x768 screen intersecting with a common starting point in the lowest left corner)

It is quite easy to force the screen back into landscape mode, simply by rotating manually once. It looks like the iOS device knows it is in landscape mode at startup, but SDL doesn’t.

What would be the best workaround for this? Taking the topmost view controller and rotating it 90 degrees?

Cheers,
Gorm


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list

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


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Message-ID:
Content-Type: text/plain; charset=“utf-8”

Unfortunately, it looks like I am starting to agree with you stevo. I made a
minimal example to prove the behavior to you guys, but (unfortunately for my
ego) so far it looks like it is behaving like it should.

I will have to dig further into this, to figure out what it is I am doing
that is causing this behavior.

Personal experience suggests a typo. Start copying the relevant pieces
of code into a separate editor window to see if you can spot it in
isolation.

This kind of thing kept me from deleting ‘windows’ in a small piece of
Javascript that I had written (I found the problem yesterday, after a
month or three of the code sitting on my harddrive).> Date: Sun, 16 Sep 2012 11:40:54 +0100

From: Gorm Lai
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Best Practices for landscaped mode on iOS

Ok, so I got a little further with this, and it looks like when I just called glClear everything worked, but the rotation was still wrong in the texturing (link to picture here http://imgur.com/H77zd ). You can see the glClear clears the whole viewport as it is white above (to the left of the picture), but the textured image itself is rotated wrong.

I then went into [SDL_uikitopenglview update_frame] and the backingWidth and backingHeight in the sdl code are set to portrait mode values initially (w=768,h=1024). However, after I manually do one rotation of the device, then they change to be correct for landscape ( w=1024, h=768).

Please note after this is it only possible for me to rotate between landscape_left and landscape_right as it should be, and that game center from the beginning knows we are landscape mode, even when SDL_uikitopenglview doesn’t ( proof here: http://i.imgur.com/J2FbO.png ).

To me it looks like the CEAGLView inside SDL_uikitopenglview doesn’t know that the initial rotation should landscape.

Opinions would be highly appreciated :),

Best,
GormOn Monday, September 17, 2012 at 6:50 AM, Jared Maddox wrote:

Date: Sun, 16 Sep 2012 11:40:54 +0100
From: Gorm Lai <@Gorm_Lai (mailto:@Gorm_Lai)>
To: sdl at lists.libsdl.org (mailto:sdl at lists.libsdl.org)
Subject: Re: [SDL] Best Practices for landscaped mode on iOS
Message-ID: <B4EE19DB404F40F684FAA682F250BC01 at kotoristudios.com (mailto:B4EE19DB404F40F684FAA682F250BC01 at kotoristudios.com)>
Content-Type: text/plain; charset=“utf-8”

Unfortunately, it looks like I am starting to agree with you stevo. I made a
minimal example to prove the behavior to you guys, but (unfortunately for my
ego) so far it looks like it is behaving like it should.

I will have to dig further into this, to figure out what it is I am doing
that is causing this behavior.

Personal experience suggests a typo. Start copying the relevant pieces
of code into a separate editor window to see if you can spot it in
isolation.

This kind of thing kept me from deleting ‘windows’ in a small piece of
Javascript that I had written (I found the problem yesterday, after a
month or three of the code sitting on my harddrive).


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

So I was fixing rotation for iOS 6.0 last night, and things might be better
now.

Try grabbing the latest snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip

Also make sure your supported orientations are set in the Xcode target
summary (if Game Center thinks it’s correct then it probably is)On Sun, Sep 23, 2012 at 1:20 PM, Gorm Lai wrote:

Ok, so I got a little further with this, and it looks like when I just
called glClear everything worked, but the rotation was still wrong in the
texturing (link to picture here http://imgur.com/H77zd ). You can see the
glClear clears the whole viewport as it is white above (to the left of the
picture), but the textured image itself is rotated wrong.

I then went into [SDL_uikitopenglview update_frame] and the backingWidth
and backingHeight in the sdl code are set to portrait mode values initially
(w=768,h=1024). However, after I manually do one rotation of the device,
then they change to be correct for landscape ( w=1024, h=768).

Please note after this is it only possible for me to rotate between
landscape_left and landscape_right as it should be, and that game center
from the beginning knows we are landscape mode, even
when SDL_uikitopenglview doesn’t ( proof here:
http://i.imgur.com/J2FbO.png ).

To me it looks like the CEAGLView inside SDL_uikitopenglview doesn’t know
that the initial rotation should landscape.

Opinions would be highly appreciated :),

Best,
Gorm

On Monday, September 17, 2012 at 6:50 AM, Jared Maddox wrote:

Date: Sun, 16 Sep 2012 11:40:54 +0100
From: Gorm Lai
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Best Practices for landscaped mode on iOS
Message-ID:
Content-Type: text/plain; charset=“utf-8”

Unfortunately, it looks like I am starting to agree with you stevo. I made
a
minimal example to prove the behavior to you guys, but (unfortunately for
my
ego) so far it looks like it is behaving like it should.

I will have to dig further into this, to figure out what it is I am doing
that is causing this behavior.

Personal experience suggests a typo. Start copying the relevant pieces
of code into a separate editor window to see if you can spot it in
isolation.

This kind of thing kept me from deleting ‘windows’ in a small piece of
Javascript that I had written (I found the problem yesterday, after a
month or three of the code sitting on my harddrive).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi Sam,

Your snapshot was why I got back on this. I have also pulled the latest from trunk. I am sure that it is the right code, as I was forced to install the new Xcode with the iOS 6.0 SDK to get it compiling :).

I have even grabbed a plist from a different project, to make sure everything is setup right.

If I leave the status bar on, I can see that

  1. On startup, the landscape mode is set correctly when the splash screen is
  2. Momentarily, SDL creates a portrait mode even when I ask for a landscape (w=1024,h=768)
  3. SDL switches correctly back to landscape with the ViewController at least, as game center knows the correct orientation (at this point the status bar is no longer visible).

My suspicion is that during step 2, the CEAGLView layer is created in portrait mode, and never discovers / is not correctly notified of the landscape mode, until a manual rotation of the device is done. Sam, you might know better of course.

Thank you for staying with me on this. I might have to dive deeper into SDL to figure out what is going on, as I have to get the game out to the first testers in a couple of days (it might still be a bug in my code, but I think the only place to find the explanation is in the SDL source).

Any more advice is always welcome,

Best,
GormOn Monday, September 24, 2012 at 1:30 AM, Sam Lantinga wrote:

So I was fixing rotation for iOS 6.0 last night, and things might be better now.

Try grabbing the latest snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip

Also make sure your supported orientations are set in the Xcode target summary (if Game Center thinks it’s correct then it probably is)

On Sun, Sep 23, 2012 at 1:20 PM, Gorm Lai <@Gorm_Lai (mailto:@Gorm_Lai)> wrote:

Ok, so I got a little further with this, and it looks like when I just called glClear everything worked, but the rotation was still wrong in the texturing (link to picture here http://imgur.com/H77zd ). You can see the glClear clears the whole viewport as it is white above (to the left of the picture), but the textured image itself is rotated wrong.

I then went into [SDL_uikitopenglview update_frame] and the backingWidth and backingHeight in the sdl code are set to portrait mode values initially (w=768,h=1024). However, after I manually do one rotation of the device, then they change to be correct for landscape ( w=1024, h=768).

Please note after this is it only possible for me to rotate between landscape_left and landscape_right as it should be, and that game center from the beginning knows we are landscape mode, even when SDL_uikitopenglview doesn’t ( proof here: http://i.imgur.com/J2FbO.png ).

To me it looks like the CEAGLView inside SDL_uikitopenglview doesn’t know that the initial rotation should landscape.

Opinions would be highly appreciated :),

Best,
Gorm

On Monday, September 17, 2012 at 6:50 AM, Jared Maddox wrote:

Date: Sun, 16 Sep 2012 11:40:54 +0100
From: Gorm Lai <@Gorm_Lai (mailto:@Gorm_Lai)>
To: sdl at lists.libsdl.org (mailto:sdl at lists.libsdl.org)
Subject: Re: [SDL] Best Practices for landscaped mode on iOS
Message-ID: <B4EE19DB404F40F684FAA682F250BC01 at kotoristudios.com (mailto:B4EE19DB404F40F684FAA682F250BC01 at kotoristudios.com)>
Content-Type: text/plain; charset=“utf-8”

Unfortunately, it looks like I am starting to agree with you stevo. I made a
minimal example to prove the behavior to you guys, but (unfortunately for my
ego) so far it looks like it is behaving like it should.

I will have to dig further into this, to figure out what it is I am doing
that is causing this behavior.

Personal experience suggests a typo. Start copying the relevant pieces
of code into a separate editor window to see if you can spot it in
isolation.

This kind of thing kept me from deleting ‘windows’ in a small piece of
Javascript that I had written (I found the problem yesterday, after a
month or three of the code sitting on my harddrive).


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org (mailto:SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yep, it sounds like it might be a bug in SDL code. Feel free to dig
deeper, and if you can send a reproducible case I’m happy to poke at it.

One thing I haven’t tried is explicitly setting the orientation when an iOS
window is shown.

What orientation is your device when you start? If you hold it in
landscape mode at the start, does it have the same problem?On Mon, Sep 24, 2012 at 1:12 AM, Gorm Lai wrote:

Hi Sam,

Your snapshot was why I got back on this. I have also pulled the latest
from trunk. I am sure that it is the right code, as I was forced to install
the new Xcode with the iOS 6.0 SDK to get it compiling :).

I have even grabbed a plist from a different project, to make sure
everything is setup right.

If I leave the status bar on, I can see that

  1. On startup, the landscape mode is set correctly when the splash screen
    is
  2. Momentarily, SDL creates a portrait mode even when I ask for a
    landscape (w=1024,h=768)
  3. SDL switches correctly back to landscape with the ViewController at
    least, as game center knows the correct orientation (at this point the
    status bar is no longer visible).

My suspicion is that during step 2, the CEAGLView layer is created in
portrait mode, and never discovers / is not correctly notified of the
landscape mode, until a manual rotation of the device is done. Sam, you
might know better of course.

Thank you for staying with me on this. I might have to dive deeper into
SDL to figure out what is going on, as I have to get the game out to the
first testers in a couple of days (it might still be a bug in my code, but
I think the only place to find the explanation is in the SDL source).

Any more advice is always welcome,

Best,
Gorm

On Monday, September 24, 2012 at 1:30 AM, Sam Lantinga wrote:

So I was fixing rotation for iOS 6.0 last night, and things might be
better now.

Try grabbing the latest snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip

Also make sure your supported orientations are set in the Xcode target
summary (if Game Center thinks it’s correct then it probably is)

On Sun, Sep 23, 2012 at 1:20 PM, Gorm Lai wrote:

Ok, so I got a little further with this, and it looks like when I just
called glClear everything worked, but the rotation was still wrong in the
texturing (link to picture here http://imgur.com/H77zd ). You can see the
glClear clears the whole viewport as it is white above (to the left of the
picture), but the textured image itself is rotated wrong.

I then went into [SDL_uikitopenglview update_frame] and the backingWidth
and backingHeight in the sdl code are set to portrait mode values initially
(w=768,h=1024). However, after I manually do one rotation of the device,
then they change to be correct for landscape ( w=1024, h=768).

Please note after this is it only possible for me to rotate between
landscape_left and landscape_right as it should be, and that game center
from the beginning knows we are landscape mode, even
when SDL_uikitopenglview doesn’t ( proof here:
http://i.imgur.com/J2FbO.png ).

To me it looks like the CEAGLView inside SDL_uikitopenglview doesn’t know
that the initial rotation should landscape.

Opinions would be highly appreciated :),

Best,
Gorm

On Monday, September 17, 2012 at 6:50 AM, Jared Maddox wrote:

Date: Sun, 16 Sep 2012 11:40:54 +0100
From: Gorm Lai
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Best Practices for landscaped mode on iOS
Message-ID:
Content-Type: text/plain; charset=“utf-8”

Unfortunately, it looks like I am starting to agree with you stevo. I made
a
minimal example to prove the behavior to you guys, but (unfortunately for
my
ego) so far it looks like it is behaving like it should.

I will have to dig further into this, to figure out what it is I am doing
that is causing this behavior.

Personal experience suggests a typo. Start copying the relevant pieces
of code into a separate editor window to see if you can spot it in
isolation.

This kind of thing kept me from deleting ‘windows’ in a small piece of
Javascript that I had written (I found the problem yesterday, after a
month or three of the code sitting on my harddrive).


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org