Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL when turning Android Phone

What is it called ( what term should i google) when flipping/tilting the phone, so that the view rotates when running android?

My (OpenGL) application crashes when I do this, are there some certain steps you should do when handling OpenGL when this occures?

Is there something else I might want to think about?

like image 778
Marcus Johansson Avatar asked Sep 13 '10 23:09

Marcus Johansson


2 Answers

if you don't set the AndroidManifest.xml 's attributes for activities that handle their own rotations, your activity will be restarted, the GL context will be recreated, and at least, any surfaces and buffers that you were using will be invalid.

in my gles 1.1 application, I have the following in my AndroidManifest.xml, which specifies that my application activity wants to live on through keyboard and orientation configuration changes, and that the application supports any orientation, but doesn't want it to change -because I don't want to deal with reloading textures or redoing the game layout (yet)

<application android:label="@string/app_name" 
             android:icon="@drawable/icon" 
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
             android:debuggable="true">
    <activity android:name="MainActivity"
              android:configChanges="keyboard|keyboardHidden|orientation"
              android:screenOrientation="nosensor"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
like image 126
forksandhope Avatar answered Sep 21 '22 00:09

forksandhope


The problem is like the configuration change that occurs when the screen orientation change occurs. See Configuration Changes. You might want to tell Android that you will handle the orientation change yourself, via the configChanges attribute.

like image 43
Cheryl Simon Avatar answered Sep 20 '22 00:09

Cheryl Simon