SDL 2.0/OpenGLES and iPhone Orientation

Hello guys,

What is the best practice to control the Iphone screen orientation with SDL
2.0 and Opengl GLES 2.0 . Is there a way to query what is the current
orientation ?

Thanks in advance,

Alex

I am having an issue with the IOS simlator not sure if it works with the
IOS Device.
While the IOS Simlator is running if I change Hardware -> Rotate Left or
Rotate Right to change the orientation, the code below misses some of the
events by the orientation changes. I am using SDL 2.0.3 .

SDL_Event event;

while(running)
{
while (SDL_PollEvent(&event)) {
if (event.type == SDL_WINDOWEVENT && event.window.event ==
SDL_WINDOWEVENT_RESIZED)
{
SDL_Log(“Window %d resized to %dx%d”,
event->window.windowID, event->window.data1,
event->window.data2);
}
}
}

Thanks,

Alex

Alex,

Although I do not see any reason why your code sample does not function, I can vouch that the simple test demo I put together at [1] does function as intended, under both the iOS simulator and iOS device (both v7.1), in regards to the receiving of the window size events in response to an orientation change (I see the debug logging output as expected).

The only thing I can come up with is asking what flags you initialize your SDL window with? I had to pass SDL_WINDOW_RESIZABLE in order to enable landscape orientations.

  1. https://github.com/i8degrees/hello-sdl2-ios-cmake/blob/master/src/main.mm

Cheers,
Jeffrey Carpenter
<@Jeffrey_Carpenter>On 2014/05/ 25, at 19:03, Alexander Chaliovski wrote:

I am having an issue with the IOS simlator not sure if it works with the IOS Device.
While the IOS Simlator is running if I change Hardware -> Rotate Left or Rotate Right to change the orientation, the code below misses some of the events by the orientation changes. I am using SDL 2.0.3 .

SDL_Event event;

while(running)
{
while (SDL_PollEvent(&event)) {
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED)
{
SDL_Log(“Window %d resized to %dx%d”,
event->window.windowID, event->window.data1,
event->window.data2);
}
}
}

Thanks,

Alex


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

Hi Jeffrey,

I will try your code tonight but you are not using Opengl in your example.
Can you try my example here as I have tested it on two systems and it fails
on both.

https://bugzilla.libsdl.org/show_bug.cgi?id=2561

Thanks,

Alex

Alex,

I just finished testing your code out, and it receives the resize window events without any fail on both the iOS Simulator (OS X v10.9.2) and iOS device (iPhone 4s, 7.1.1), with a non-modified compile of SDL v2.0.3 for iOS.

Cheers,
Jeffrey Carpenter
<@Jeffrey_Carpenter>On 2014/05/ 27, at 4:09, Alexander Chaliovski wrote:

Hi Jeffrey,

I will try your code tonight but you are not using Opengl in your example. Can you try my example here as I have tested it on two systems and it fails on both.

https://bugzilla.libsdl.org/show_bug.cgi?id=2561

Thanks,

Alex


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

Hi Jeffrey, that is super weird as I am using SDL v2.0.3 , OSX 10.9.2 and
IOS 7.1.1 .
If you start rotating the screen in one direction at least like 5-6 times
can you count exactly the same number of events printing from SDL ? On my
machine I am missing at least 50% .

Thanks,

AlexOn Tue, May 27, 2014 at 7:06 PM, Jeffrey Carpenter wrote:

Alex,

I just finished testing your code out, and it receives the resize window
events without any fail on both the iOS Simulator (OS X v10.9.2) and iOS
device (iPhone 4s, 7.1.1), with a non-modified compile of SDL v2.0.3 for
iOS.

Cheers,
Jeffrey Carpenter

On 2014/05/ 27, at 4:09, Alexander Chaliovski <@Alexander_Chaliovski> wrote:

Hi Jeffrey,

I will try your code tonight but you are not using Opengl in your
example. Can you try my example here as I have tested it on two systems and
it fails on both.

https://bugzilla.libsdl.org/show_bug.cgi?id=2561

Thanks,

Alex


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

Alex,

Yeah, it is definitely quite odd. I hope you are able to figure it out. I’m able to count precisely the same number of events as … wait, you aren’t counting the upside down direction as a window resize event, are you? (Although, I suppose that would be ~25% of the time). The upside down orientation is the only time I do not receive a window event – it remains in the previous orientation (landscape). I don’t know what the official spec says, but not a single app I’ve ever used on iOS has visually responded to that event, so I’m guessing that orientation doesn’t count.

Cheers,
Jeffrey Carpenter
<@Jeffrey_Carpenter>On 2014/05/ 27, at 15:17, Alexander Chaliovski wrote:

Hi Jeffrey, that is super weird as I am using SDL v2.0.3 , OSX 10.9.2 and IOS 7.1.1 .
If you start rotating the screen in one direction at least like 5-6 times can you count exactly the same number of events printing from SDL ? On my machine I am missing at least 50% .

Thanks,

Alex

On Tue, May 27, 2014 at 7:06 PM, Jeffrey Carpenter <@Jeffrey_Carpenter> wrote:
Alex,

I just finished testing your code out, and it receives the resize window events without any fail on both the iOS Simulator (OS X v10.9.2) and iOS device (iPhone 4s, 7.1.1), with a non-modified compile of SDL v2.0.3 for iOS.

Cheers,
Jeffrey Carpenter
<@Jeffrey_Carpenter>

On 2014/05/ 27, at 4:09, Alexander Chaliovski wrote:

Hi Jeffrey,

I will try your code tonight but you are not using Opengl in your example. Can you try my example here as I have tested it on two systems and it fails on both.

https://bugzilla.libsdl.org/show_bug.cgi?id=2561

Thanks,

Alex


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

Yep, SDL?s UIKit code disallows upside-down orientations on iPhones and iPod Touches.On May 27, 2014, at 10:13 PM, Jeffrey Carpenter wrote:

Alex,

Yeah, it is definitely quite odd. I hope you are able to figure it out. I’m able to count precisely the same number of events as … wait, you aren’t counting the upside down direction as a window resize event, are you? (Although, I suppose that would be ~25% of the time). The upside down orientation is the only time I do not receive a window event – it remains in the previous orientation (landscape). I don’t know what the official spec says, but not a single app I’ve ever used on iOS has visually responded to that event, so I’m guessing that orientation doesn’t count.

Cheers,
Jeffrey Carpenter


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

I don’t have upside-down orientations enabled. I guess I will try the
latest SDL from the repository and see how it goes. Thanks for the help.

AlexOn Wed, May 28, 2014 at 2:16 AM, Alex Szpakowski wrote:

Yep, SDL?s UIKit code disallows upside-down orientations on iPhones and
iPod Touches.

On May 27, 2014, at 10:13 PM, Jeffrey Carpenter wrote:

Alex,

Yeah, it is definitely quite odd. I hope you are able to figure it out.
I’m able to count precisely the same number of events as … wait, you
aren’t counting the upside down direction as a window resize event, are
you? (Although, I suppose that would be ~25% of the time). The upside down
orientation is the only time I do not receive a window event – it remains
in the previous orientation (landscape). I don’t know what the official
spec says, but not a single app I’ve ever used on iOS has visually
responded to that event, so I’m guessing that orientation doesn’t count.

Cheers,
Jeffrey Carpenter


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

Hey guys I am still having the same issue with latest SDL 2.0.3 and latest
Xcode with IOS 7.1 .
I have uploaded my Xcode project if anyone has the time to look into it.
When I start the simulator I am getting black screen when I invoke the
rotation I am getting wrong orientation on the arrow. Please let me know on
what is the correct way to handle the orientation. As I am running into
similar problems with Opengl ES 2.0 .

https://github.com/sabotage3d/gltestOn Wed, May 28, 2014 at 8:10 PM, Alexander Chaliovski <@Alexander_Chaliovski> wrote:

I don’t have upside-down orientations enabled. I guess I will try the
latest SDL from the repository and see how it goes. Thanks for the help.

Alex

On Wed, May 28, 2014 at 2:16 AM, Alex Szpakowski wrote:

Yep, SDL?s UIKit code disallows upside-down orientations on iPhones and
iPod Touches.

On May 27, 2014, at 10:13 PM, Jeffrey Carpenter wrote:

Alex,

Yeah, it is definitely quite odd. I hope you are able to figure it out.
I’m able to count precisely the same number of events as … wait, you
aren’t counting the upside down direction as a window resize event, are
you? (Although, I suppose that would be ~25% of the time). The upside down
orientation is the only time I do not receive a window event – it remains
in the previous orientation (landscape). I don’t know what the official
spec says, but not a single app I’ve ever used on iOS has visually
responded to that event, so I’m guessing that orientation doesn’t count.

Cheers,
Jeffrey Carpenter


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

After further investigation there were two problems with my test. First I
was creating framebuffer while SDL is already doing it. Second you were
right the only screen change is between Landscape and Portrait that is two
events.