Hi robi,
the api changed a bit. Check out the Android samples.
You have to use a SurfaceView instead of a View,
something like this:
public class OpenGLAUActivity extends Activity {
public OpenGLAUActivity() {
}
/**
* Called with the activity is first created.
*/
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(new GLSurfaceView(this));
}
public class GLSurfaceView extends SurfaceView implements Callback {
public GLSurfaceView(Context c) {
super(c);
SurfaceHolder holder = this.getHolder();
holder.addCallback(this);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
OpenGLContext glContext = new OpenGLContext(0);
glContext.makeCurrent(holder);
GL10 gl = (GL10) glContext.getGL();
// set the color for the window to green
gl.glClearColor(0.0f, 0.8f, 0.0f, 0.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
glContext.waitGL();
glContext.post();
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int
arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
// TODO Auto-generated method stub
}
}
}
Have fun,
Dirk
On 24 Mrz., 03:53, robi <[EMAIL PROTECTED]> wrote:
> List,
>
> I am trying to get some of the Android-GL (http://code.google.com/p/
> android-gl/) examples to work in m5 by breaking them out into separate
> Android projects then updating the code. I thought I had fixed all
> the errors in the first tutorial but when I try to run the application
> Android does not seem to run it and goes right into the default
> Android startup screen instead of showing me a blank window.
>
> Here is the code
>
> OpenGLAUActivity.java
>
> //some package
>
> import android.app.Activity;
> import android.os.Bundle;
>
> public class OpenGLAUActivity extends Activity {
>
> private GLSurfaceView mGLSurfaceView;
>
> /** Called when the activity is first created. */
> @Override
> public void onCreate(Bundle icicle) {
> super.onCreate(icicle);
> setContentView(R.layout.main);
> // Create our Preview view and set it as the content of our
> // Activity
> mGLSurfaceView = new GLSurfaceView(this);
> setContentView(mGLSurfaceView);
> }
>
> @Override
> protected void onResume() {
> // Ideally a game should implement onResume() and onPause()
> // to take appropriate action when the activity looses focus
> super.onResume();
> }
>
> @Override
> protected void onPause() {
> // Ideally a game should implement onResume() and onPause()
> // to take appropriate action when the activity looses focus
> super.onPause();
>
> }
>
> }
>
> GLSurfaceView.java
>
> some package
>
> import android.content.Context;
> import android.graphics.OpenGLContext;
> import android.graphics.Canvas;
> import android.view.View;
>
> import javax.microedition.khronos.opengles.GL10;
>
> public class GLSurfaceView extends View {
> private OpenGLContext glContext;
>
> public GLSurfaceView(Context c) {
> super(c);
> glContext = new OpenGLContext(0);
> GL10 gl = (GL10)glContext.getGL();
> // set the color for the window to black
> gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
> }
>
> protected void onDraw(Canvas canvas) {
> GL10 gl = (GL10)glContext.getGL();
>
> glContext.waitNative();
> // clear the color buffer
> gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
> }
>
> }
>
> Any help would be greatly appreciated.
>
> Thanks,
>
> R
--~--~---------~--~----~------------~-------~--~----~
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]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---