Im porting an iOS game to Android.
Im using as template the GL2JNI example from the latest NDK, and have added inside GL2JNIActivity.java/onCreate mView.setPreserveEGLContextOnPause( true ); to preserve the EGL context but it as soon the device orientation change the screen is all black.
I've research on this and some suggests to reload all textures, shaders, geometry etc... But that is not an option for me (too slow to reload).
Is there any way to handle like on iOS multiple devices orientation using on OpenGLES2 view on Android? If yes how can it be done without reloading everything. I've seen like Unity games doing it... so it must be possible right?
TIA!
Related
I created Android live wallpaper using canvas but it seems to be quite slow in performance. I was thinking of shifting towards OpenGLES 2.0 but it is very difficult to code from scratch because there are a lot of animations. I want a sincere opinion which one is the best for making live wallpapers Unity or OpenGLES 2.0, also give a basic idea whether unity slows down the wallpaper or not.
Thanks in advance.
I'd suggest using Unity.
Unity engine is pretty good for highly-visual stuff, with its visual editor, good asset import pipeline and tons of stuff on Asset Store that would help to boost your development. It'd be very hard to beat it performance-wise. There are other game engines that you could use for live wallpapers, but it'd be a much more tedious task.
The negative side of using Unity is that it might be somewhat heavy - it's expected to have an minimal APK of around 9 MB in size This doesn't really matters if you have a resource-heavy live wallpaper, though.
What makes it possible, is that recently I've released uLiveWallpaper - a Unity asset that makes it possible to create live wallpapers for Android using Unity 5. It is well-tested and reliable, creates projects for Android Studio, complete with placeholder code to get you started.
Check it out:
http://forum.unity3d.com/threads/ulivewallpaper-develop-android-live-wallpapers-with-unity-5.375255/
I don't think you can create a live wallpaper using Unity. At least not easily, Unity is not intended for this. Usually a live wallpaper consists of a service, a Settings activity, and some sort of resource which defines your live wallpaper. Everything you create in Unity will be compiled packaged magically transformed into an activity with a launcher. This means your Unity "game" will not be in the wallpapers list, but in the apps list. Also, by default it will run in the front, not in the back of a home screen like a live wallpaper would do.
To make it work as a wallpaper would require a lot of altering to what Unity outputs when building, because Unity does not offer any live wallpaper settings. That seems like a lot of work. Also, it seems a bit overkill to use a game engine or OpenGL for a live wallpaper.
Keep in mind that you should not try to create a >30 fps live wallpaper, because that would drain an Android device's battery pretty fast. If I were you I would try to make the wallpaper look good with <30 fps. Try not to have fast animations, pre-render 3D stuff and optimize what you already have.
I'm starting to develop a game for Android using libGDX.
I noticed that some sample games for this library all have fixed screen orientation. I want my game to be landscape all the time, but I want to rotate the camera 180 degrees when the device is turned upside down (most well behaved Android apps do this automatically).
I'm looking at the docs and Googling, but can't find anything about it.
Basically, I'd like to know what to add to base libGDX app. that shows libGDX logo, to just react when phone is turned upside down?
The Android docs, list this functionality in getRotation function here:
http://developer.android.com/reference/android/view/Display.html#getRotation%28%29
This allows you to get 0/180 or 90/270 for rotation and thus detect how the device is turned.
But I don't see this exposed in libGDX?
Nevermind, I just found it. You need to change:
android:screenOrientation="landscape"
to:
android:screenOrientation="sensorLandscape"
and it works automagically. Maybe libGDX devs should make this the default.
I am looking for a better way to respond to orientation changes using native AS (non-flex) Air for mobile. The current implementation using stage.autoOrients = true is pretty crappy and doesn't look polished the way a native orientation change looks in professional apps.
How are you dealing with orientation change and smooth re-layout on mobile for android (I haven't yet tested on iOS)? Do you live with the automatic re-orientation animation, with its truncated display and the delay before you re-layout your view? Is there a funky workaround that allows you to draw stuff off-screen or in some other way make that user experience feel less broken and more like a native app behaves?
You may set autoOrients to false and listen to Accelerometer Events.
This way you can guess device orientation and, if needed, perform your own stage rotation with your own transitions and animations.
I am wondering if it possible to use Android renderscript to manipulate activity windows. For example if it is possible to implement something like 3dCarousel, with activity running in every window?
I was researching for a long time, and all the examples I found are for manipulating bitmaps on the screen. If it is true, and renderscript is only meant for images, than what is used in SPB Shell 3d, or these panels aren't actual acitivites?
It does not appear to me that those are activities. To answer your question directly, to the best of my knowledge there is no way to do what you want with renderscript as the nature of how it works prevents it from controlling activities. The control actually works the other way around... You could however build a series of fragments containing renderscript surface views, however the processing load of this would be horrific to say the least. I am unsure of how to take those fragments or activities and then draw a carousel.
What I *think * they are doing is using render script or open gl to draw a carousel and then placing the icon images where they need to be. But I have never made a home screen app so I could be and likely am mistaken in that regard.
I am almost done creating a game for android using a port of irrlicht 3d engine to android.
All code except a minimal frame work to make the native calls and play sounds is written in C++.
Even the opengles display is created in c++ code using eglGetDisplay and eglCreateWindowSurface
The problem I need to solve is that when home is pressed then relaunch the game the screen is all white.
From other answers I have found that the opengl context is lost then recreated when onSurfaceCreated is called. I thought that I could just reload textures but that seams to work for only some textures. Also the background color is changed which is not a resource.
It seams I would have to completely restart the game but this could be really annoying to a user.
the port of quake 3 has notes about this problem be has no solution.
Is there a example anywhere of a game written in native code which correctly handles this situation?
The way I handled the situation is to recreate everything. I made sure that all generated stuff like textures and buffers where deleted before recreating everything as if it happened for the first time.