I use helixlauncher2 to rotate the desktop on n1. Le 7 avr. 2010 23:01, "Robert Green" <rbgrn....@gmail.com> a écrit :
That's strange.. First of all, how are you getting orientation changes on an N1? I never found a way to get it to do that. I tested my latest code on www.rbgrn.net on both the N1 and Droid and both seem to be working well now. It includes your wait-hack and my updates. On Apr 7, 3:57 pm, unixseb <unix...@gmail.com> wrote: > i'm currently using the code on your blog, i have an issue on N1, when > the orientation change, the surfacechanged function of the rendrerer > isn't called, so i can't reset the frustum to the correct window size. > i guess it's around the following code, i'm trying to fix it : > > if (needStart) { > tellRendererSurfaceCreated = true; > changed = true; > } > if (changed) { > gl = (GL10) mEglHelper.createSurface(mHolder); > tellRendererSurfaceChanged = true; > } > if (tellRendererSurfaceCreated) { > mRenderer.onSurfaceCreated(gl, mEglHelper.mEglConfig); > tellRendererSurfaceCreated = false; > } > if (tellRendererSurfaceChanged) { > mRenderer.onSurfaceChanged(gl, w, h); > tellRendererSurfaceChanged = false; > } > > On 7 avr, 22:32, unixseb <unix...@gmail.com> wrote: > > > > > i can't tell you if my code works for the droid (i dont own one) but > > it help fixing issues on the N1. > > anyway i still have issues, sometimes it looks like i have 2 opengl > > surfaces swapping from each other after a resume. > > i'm gonna implement your modifications and tell you the effect on the > > N1 > > Thanks a lot for everything, my work would have never exists without > > yours ! (and sorry for my poor english ;) ) > > > On 6 avr, 22:58, Robert Green <rbgrn....@gmail.com> wrote: > > > > That occasional lock-up started happening constantly to me. I messed > > > around with a few things and found that the Droid really doesn't like > > > to have its Display and Context destroyed all the time. > > > > I modified the code so that it would reuse the display and context as > > > much as possible. I looked through my GLES book and it doesn't say > > > explicitly that you should always destroy them when your surface > > > changes so I have to assume that it must be ok. Even if it's not - > > > this works and it wasn't working before, so I'm using it. > > > > Here are the code modifications: > > > > In EglHelper: > > > > public void start() { > > > Log.d("EglHelper" + instanceId, "start()"); > > > if (mEgl == null) { > > > Log.d("EglHelper" + instanceId, "getting new EGL"); > > > /* > > > * Get an EGL instance > > > */ > > > mEgl = (EGL10) EGLContext.getEGL(); > > > } else { > > > Log.d("EglHelper" + instanceId, "reusing EGL"); > > > } > > > > if (mEglDisplay == null) { > > > Log.d("EglHelper" + instanceId, "getting new display"); > > > /* > > > * Get to the default display. > > > */ > > > mEglDisplay = > > > mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); > > > } else { > > > Log.d("EglHelper" + instanceId, "reusing display"); > > > } > > > > if (mEglConfig == null) { > > > Log.d("EglHelper" + instanceId, "getting new config"); > > > /* > > > * We can now initialize EGL for that display > > > */ > > > int[] version = new int[2]; > > > mEgl.eglInitialize(mEglDisplay, version); > > > mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, > > > mEglDisplay); > > > } else { > > > Log.d("EglHelper" + instanceId, "reusing config"); > > > } > > > > if (mEglContext == null) { > > > Log.d("EglHelper" + instanceId, "creating new context"); > > > /* > > > * Create an OpenGL ES context. This must be done only > > > once, an OpenGL context is a somewhat heavy object. > > > */ > > > mEglContext = mEGLContextFactory.createContext(mEgl, > > > mEglDisplay, mEglConfig); > > > if (mEglContext == null || mEglContext == > > > EGL10.EGL_NO_CONTEXT) { > > > throw new RuntimeException("createContext failed"); > > > } > > > } else { > > > Log.d("EglHelper" + instanceId, "reusing context"); > > > } > > > > mEglSurface = null; > > > } > > > > In GLThread: > > > > private void stopEglLocked() { > > > if (mHaveEgl) { > > > mHaveEgl = false; > > > mEglHelper.destroySurface(); > > > sGLThreadManager.releaseEglSurface(this); > > > } > > > } > > > > Basically, you don't want a finish() in there. > > > > But we do need to finish somewhere so, > > > > At the end of guardedRun(): > > > > } finally { > > > /* > > > * clean-up everything... > > > */ > > > synchronized (sGLThreadManager) { > > > // Log.d("GLThread" + getId(), "Finishing."); > > > stopEglLocked(); > > > mEglHelper.finish(); > > > } > > > } > > > } > > > > Then Finally in GLWallpaperService: > > > > @Override > > > public void onDestroy() { > > > super.onDestroy(); > > > mGLThread.requestExitAndWait(); > > > } > > > > Of course you can remove any logging you don't want. > > > > The idea here is that we get to reuse the display and context on > > > orientation changes which seems to make the Droid happy. I haven't > > > had a single crash since I switched to that, and I've probably > > > reoriented 100 times since then in testing. > > > > I'll update the post on my blog to contain all the current code. > > > > On Apr 6, 2:57 pm, Robert Green <rbgrn....@gmail.com> wrote: > > > > > By the way - things seemed good but I'm still having the occasional > > > > lock-up. The last one caused the phone to lock up badly enough that I > > > > had to pull the battery :( > > > > > On Apr 6, 2:18 pm, Robert Green <rbgrn....@gmail.com> wrote: > > > > > > I'm in disbelief, but it works! Why does that hack work? Is it a > > > > > previous call to eglCreateWindowSurface which returns a bad value and > > > > > after that, cleaning up causes a bad state and the next call to create > > > > > window surface freezes? I don't quite understand but I guess I never > > > > > checked the return value of that call (because it wasn't returning > > > > > when I was having problems, but maybe it was too late then :)). > > > > > > I tested and tested and tested again and this held up against all the > > > > > orientation changes I could possibly make. Good work! I'll update > > > > > the code I posted. > > > > > > BTW - I'm still seeing the occasional: > > > > > E/libEGL ( 5769): eglChooseConfig:897 error 3005 (EGL_BAD_CONFIG) > > > > > W/dalvikvm( 5769): threadid=13: thread exiting with uncaught exception > > > > > (group=0x4001b180) > > > > > E/AndroidRuntime( 5769): Uncaught handler: thread GLThread 7 exiting > > > > > due to uncaught exception > > > > > E/AndroidRuntime( 5769): java.lang.IllegalArgumentException > > > > > E/AndroidRuntime( 5769): at > > > > > com.google.android.gles_jni.EGLImpl.eglGetConfigAttrib(Native Method) > > > > > E/AndroidRuntime( 5769): at android.opengl.EglHelper > > > > > $ComponentSizeChooser.findConfigAttrib(EglHelper.java:1007) > > > > > E/AndroidRuntime( 5769): at android.opengl.EglHelper > > > > > $ComponentSizeChooser.chooseConfig(EglHelper.java:987) > > > > > E/AndroidRuntime( 5769): at android.opengl.EglHelper > > > > > $BaseConfigChooser.chooseConfig(EglHelper.java:951) > > > > > E/AndroidRuntime( 5769): at > > > > > android.opengl.EglHelper.start(EglHelper.java:127) > > > > > E/AndroidRuntime( 5769): at android.opengl.EglHelper > > > > > $GLThread.guardedRun(EglHelper.java:421) > > > > > E/AndroidRuntime( 5769): at android.opengl.EglHelper > > > > > $GLThread.run(EglHelper.java:358) > > > > > > I'm trying to track that one down but it's very hard to recreate. It > > > > > likes to happen the first time you run a newly installed gl live > > > > > wallpaper but then it doesn't happen again for a while. > > > > > > Thanks guys for all your help! > > > > > > On Apr 6, 11:29 am, shaun <shashepp...@gmail.com> wrote: > > > > > > > Assuming I correctly identified the code that unixseb uses as the > > > > > > workaround/fix for orientation changes on Droid in Live Wallpaper with > > > > > > OpenGL, the following code is the same with the exception of > > > > > > recursion: > > > > > > > public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay > > > > > > display, EGLConfig config, Object nativeWindow) { > > > > > > EGLSurface eglSurface = null; > > > > > > while (eglSurface == null) { > > > > > > try { > > > > > > eglSurface = egl.eglCreateWindowSurface(display, > > > > > > config, nativeWindow, null); > > > > > > } catch (Throwable t) { > > > > > > } finally { > > > > > > if (eglSurface == null) { > > > > > > try { > > > > > > Thread.sleep(10); > > > > > > } catch (InterruptedException t) { > > > > > > } > > > > > > } > > > > > > } > > > > > > > } > > > > > > return eglSurface; > > > > > > } > > > > > > > I'd like to know if unixseb's fix works for others. I still cannot > > > > > > test. > > > > > > > On Apr 6, 11:00 am, Ralf Schneider <li...@gestaltgeber.com> wrote: > > > > > > > > I'm also interested in this topic. I got an 404 on the link: This seems to > > > > > > > work: > > > > > > > >http://code.google.com/p/earth-live-wallpaper/ > > > > > > > > Thank you for sharing your code! > > > > > > > > 2010/4/6 unixseb <unix...@gmail.com> > > > > > > > > > have a look at the svn repository on > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com> For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using "remove me" as the subject. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en