Great! I'm glad you got it to work. I need to finish my submission to the platform. I actually worked out most everything including a few iterations of design and javadocs but never finished setting up my build environment so I can't do some of the final stuff to get it in. I'll try to get that done tonight and hopefully will make it in to 2.2 or the next API after that.
On Feb 14, 5:07 pm, joshbeck <[email protected]> wrote: > I can see that now and I thank you for the response. > Really, your directions were very clear and your GL service > is incredible. I hope to see it incorporated in the official 2.2 API. > You deserve it, and I thank you! > > Nancy, thanks also. --Your directions are what I was able > to follow in order to fix my setup. Very talented. > > I'm a hack at this stuff, and the information I gleaned from this > fix was just what I needed. --Great knowledge! > (Believe it or not, I'm actually trying to teach this stuff at the 8th > grade level) > > http://www.neisd.net/ComRel/News/Krueger_Smartphone_10.htm > (That's my class) > > I can fire off basic intents and work with the hardware on the phone > fairly competently, but OpenGL is new. Now I can do a couple things: > > 1.) Play with polygons > > 2.) Teach the students pictured in that article to play with polygons > based > on the template I now have. They'll love it! > > Thanks again! > Josh Beck > Northeast ISDhttp://www.linuxclassroom.com > > On Feb 14, 3:25 pm, Robert Green <[email protected]> wrote: > > > > > The problem that you were having is that you weren't creating the > > engine in the right spot and then in the engine, you need to be > > setting the renderer in the constructor. > > > The big difference between this and GLSurfaceView is that all of your > > traditional "Activity" or "View" code goes into your Engine, not into > > the Service. All the service really needs to do is create engines. > > Engines do everything else. Follow the structure I posted and you > > should be golden. > > > On Feb 14, 3:18 pm, Robert Green <[email protected]> wrote: > > > > I guess I really should have posted an example, huh? Here's the > > > structure that works: > > > > public class MyWallpaperService extends GLWallpaperService { > > > public MyWallpaperService() { > > > super(); > > > } > > > > public Engine onCreateEngine() { > > > MyEngine engine = new MyEngine(); > > > return engine; > > > } > > > > // prefs and sensor interface is optional, just showing that this is > > > where you do all of that - everything that would normally be in an > > > activity is in here. > > > class MyEngine extends GLEngine implements > > > SharedPreferences.OnSharedPreferenceChangeListener, > > > SensorEventListener { > > > MyRenderer renderer; > > > public MyEngine() { > > > super(); > > > // handle prefs, other initialization > > > renderer = new MyRenderer(); > > > setRenderer(renderer); > > > setRenderMode(RENDERMODE_WHEN_DIRTY); > > > } > > > > public void onDestroy() { > > > super.onDestroy(); > > > if (renderer != null) { > > > renderer.release(); // assuming yours has this method - it > > > should! > > > } > > > renderer = null; > > > > } > > > > On Feb 14, 11:52 am, Lance Nanek <[email protected]> wrote: > > > > > >public GLSurfaceView mGLSurfaceView; > > > > ... > > > > >mGLSurfaceView = new GLSurfaceView(this); > > > > ... > > > > >mGLSurfaceView = new GLSurfaceView(MyLiveWallpaper.this); > > > > > Remove the lines above. Any use of GLSurfaceView in this is wrong. > > > > > >public Engine onCreateEngine() { > > > > >return new GLEngine(); > > > > >} > > > > > You are supposed to return an instance of your subclass of GLEngine > > > > here, "new CubeEngine()" in your case. > > > > > >public class OpenGLRenderer implements GLSurfaceView.Renderer { > > > > > You should be implementing GLWallpaperService.Renderer, not > > > > GLSurfaceView.Renderer. > > > > > >private final Runnable mDrawCube = new Runnable() { > > > > >public void run() { > > > > >drawFrame(); > > > > >// CHECK OUT drawFrame() --Am I doing things correctly there? > > > > >} > > > > >}; > > > > > Remove all of the above. > > > > > >mGLSurfaceView.setRenderer(new OpenGLRenderer()); > > > > >mGLSurfaceView.setRenderMode(RENDERMODE_CONTINUOUSLY); > > > > > These should be called on GLEngine, which you are subclassing. They > > > > should look like this: > > > > setRenderer(new OpenGLRenderer()); > > > > setRenderMode(RENDERMODE_CONTINUOUSLY); > > > > > >void drawFrame() { > > > > >final SurfaceHolder holder = getSurfaceHolder(); > > > > > >Canvas c = null; > > > > >try { > > > > >c = holder.lockCanvas(); > > > > >if (c != null) { > > > > >// draw something > > > > >} > > > > >} finally { > > > > >if (c != null) > > > > >holder.unlockCanvasAndPost(c); > > > > >} > > > > > >// Reschedule the next redraw > > > > >mHandler.removeCallbacks(mDrawCube); > > > > >if (mVisible) { > > > > >mHandler.postDelayed(mDrawCube, 1000 / 25); > > > > >} > > > > >} > > > > > Remove all of the above. > > > > > On Feb 14, 10:47 am, joshbeck <[email protected]> wrote: > > > > > > I'm going to post my entire source code as it stands right now in the > > > > > hope that someone with more experience than I can > > > > > get me pointed in the right direction. I've been trying lots of > > > > > different things. Feel free to use caps lock when expressing > > > > > discontent > > > > > with my code :') > > > > > > /* > > > > > * Copyright (C) 2009 The Android Open Source Project > > > > > * > > > > > * Licensed under the Apache License, Version 2.0 (the "License"); > > > > > * you may not use this file except in compliance with the License. > > > > > * You may obtain a copy of the License at > > > > > * > > > > > * http://www.apache.org/licenses/LICENSE-2.0 > > > > > * > > > > > * Unless required by applicable law or agreed to in writing, software > > > > > * distributed under the License is distributed on an "AS IS" BASIS, > > > > > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or > > > > > implied. > > > > > * See the License for the specific language governing permissions and > > > > > * limitations under the License. > > > > > */ > > > > > > package com.MyLiveWallpaper; > > > > > > imports are all square. --Not included: > > > > > > public class MyLiveWallpaper extends GLWallpaperService implements > > > > > SensorEventListener { > > > > > > private final Handler mHandler = new Handler(); > > > > > SensorManager sm = null; > > > > > > private static final String TAG = "Compass"; > > > > > > private final Paint mPaint = new Paint(); > > > > > private float mTouchX = -1; > > > > > private float mTouchY = -1; > > > > > > public GLSurfaceView mGLSurfaceView; > > > > > > private float mOffset; > > > > > > @Override > > > > > public void onCreate() { > > > > > super.onCreate(); > > > > > sm = (SensorManager) getSystemService(SENSOR_SERVICE); > > > > > sm.registerListener(this, > > > > > sm.getDefaultSensor(Sensor.TYPE_ORIENTATION) , > > > > > SensorManager.SENSOR_DELAY_GAME); > > > > > mGLSurfaceView = new GLSurfaceView(this); > > > > > //Do I need this here? > > > > > > } > > > > > > @Override > > > > > public void onDestroy() { > > > > > super.onDestroy(); > > > > > } > > > > > > @Override > > > > > public Engine onCreateEngine() { > > > > > return new GLEngine(); > > > > > } > > > > > // THE CLASS BELOW THIS WORKS IN AN ACTIVITY > > > > > public class OpenGLRenderer implements GLSurfaceView.Renderer { > > > > > private Square square; > > > > > private float angle = 45f; > > > > > public OpenGLRenderer() { > > > > > // Initialize our square. > > > > > square = new Square(); > > > > > } > > > > > /* > > > > > * (non-Javadoc) > > > > > * > > > > > * @see > > > > > * > > > > > android.opengl.GLSurfaceView.Renderer#onSurfaceCreated(javax.microedition > > > > > * .khronos.opengles.GL10, > > > > > javax.microedition.khronos.egl.EGLConfig) > > > > > */ > > > > > public void onSurfaceCreated(GL10 gl, EGLConfig config) { > > > > > > gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f); > > > > > > gl.glShadeModel(GL10.GL_SMOOTH); > > > > > > gl.glClearDepthf(1.0f); > > > > > > gl.glEnable(GL10.GL_DEPTH_TEST); > > > > > > gl.glDepthFunc(GL10.GL_LEQUAL); > > > > > > gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, > > > > > GL10.GL_NICEST); > > > > > > } > > > > > > /* > > > > > * (non-Javadoc) > > > > > * > > > > > * @see > > > > > * > > > > > android.opengl.GLSurfaceView.Renderer#onDrawFrame(javax.microedition. > > > > > * khronos.opengles.GL10) > > > > > */ > > > > > public void onDrawFrame(GL10 gl) { > > > > > > gl.glClear(GL10.GL_COLOR_BUFFER_BIT | > > > > > GL10.GL_DEPTH_BUFFER_BIT); > > > > > > gl.glLoadIdentity(); > > > > > > // Translates 4 units into the screen. > > > > > gl.glTranslatef(0, 0, -4); > > > > > // > > > > > > gl.glPushMatrix(); > > > > > gl.glRotatef(angle, 0.0f, 0.0f, 1.0f); > > > > > > gl.glColor4f(0.5f, 0.5f, 1.0f, 1.0f); > > > > > > square.draw(gl); > > > > > gl.glPopMatrix(); > > > > > > angle++; > > > > > } > > > > > > /* > > > > > * (non-Javadoc) > > > > > * > > > > > * @see > > > > > * > > > > > android.opengl.GLSurfaceView.Renderer#onSurfaceChanged(javax.microedition > > > > > * .khronos.opengles.GL10, int, int) > > > > > */ > > > > > public void onSurfaceChanged(GL10 gl, int width, int height) { > > > > > > gl.glViewport(0, 0, width, height); > > > > > > gl.glMatrixMode(GL10.GL_PROJECTION); > > > > > > gl.glLoadIdentity(); > > > > > > GLU.gluPerspective(gl, 45.0f, (float) width / (float) > > > > > height, > > > > > 0.1f, > > > > > 100.0f); > > ... > > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

