This project is read-only.

Changing Orientation

Jul 17, 2010 at 9:34 PM


I saw the pictures of windows in landscape mode on the Home page and wondered, how I can achieve this behaviour. So I searched the source code of the examples project, but unfortunately I found nothing concerning this problem. Does anybody know, how landscape mode works?



Jul 21, 2010 at 1:53 PM

the device itself must support landscape mode.

on some cell phone's like the xperia x1, it's activated when you slide out the hardware keyboard. other devices have a dedicated button. but you can change from portrait to landscape in Settings->System->Screen.

Jul 21, 2010 at 4:16 PM
Hi Tom, thanks for the answer. I now also found a way to change the screen orientation with some C# code, that is also used for changing the screen orientation when using Windows forms. So, I'm happy for now ;) Thanks for the great work with this library! Cheers Jan
Jul 26, 2010 at 10:57 PM

Hi again,

I stumbled over some problems with this again. As I said, I found a way to change the screen orientation, but there are some flaws doing this. I have to change to screen orientation before I call the Initialize() method of Screen, because when I change it later, the application is rendered as if it is in portrait mode. Which means, that the rendering area is only 480 pixels wide, but probably 800 pixels high on my Touch HD.

And this is where the problems begin: the application starts only every second or third time. When I execute the application in debug mode with VS2008, it sometimes shows me a NotSupportedException at line 267 in class Device in OpenGL. Unfortunately I don't know enough about OpenGL to tell what exactly is the problem. But maybe in this line:

IntPtr eglSurface = egl.CreateWindowSurface(display, config, window.Handle, null);

eglSurface isn't initialized properly after changing screen orientation. But why am I able to start the application after terminating it once or twice? Does anybody know what exactly the problem is here and maybe how this could be solved?

Sorry for writing a bit unsorted, maybe I can describe the problem better if there are some questions.




Jul 27, 2010 at 6:32 PM

Screen.Initialize hooks up the Resize event of the hosting window. If the size of the window changes (e.g. from 480x800 to 800x480) Silvermoon get's notified that the screen's orientation has changed. It seems that somehow the Form.Resize event is not fired.

You can try to remove some of the following values of the attribList which is used before CreateWindowSurface:




Jul 30, 2010 at 2:49 PM
Edited Jul 30, 2010 at 2:49 PM

Hi Tom,


It seems that this is something like a timing problem. If I set a breakpoint at CreateWindowSurface and wait some seconds before stepping over, the surface is succesfully created. The same occurs when I put a Thread.Sleep of some seconds between the changing of screen orientation and calling Screen.Initialize. Maybe I have to rethink my threading system, or do you think this is a general problem?




edit: typo