None of the examples compile anymore. The SDK v0.9 has made drastic
changes and I cannot get a single example to even compile out of the
box!
On Aug 7, 8:11 am, Hong <[EMAIL PROTECTED]> wrote:
> there's an opengl tutorial in android development samples, as well as a
> globaltime sample application from google that you can look into.
>
> On Thu, Aug 7, 2008 at 12:37 AM, CherryMM <[EMAIL PROTECTED]> wrote:
>
> > Hi,all:
> > I'm an Android beginner . I want to draw a suquare with opengl,
> > but there is nothing in the screen. The code is following:
>
> > public class GLTest2 extends Activity {
> > /** Called when the activity is first created. */
> > [EMAIL PROTECTED]
> > public void onCreate(Bundle icicle) {
> > super.onCreate(icicle);
> > GLTutorialTwo gv = new GLTutorialTwo(this);
> > setContentView(gv);
> > }
> > protected void onResume()
> > {
> > super.onResume();
> > //android.os.Debug.startMethodTracing("/tmp/trace/
> > GLView1.dmtrace",
> > // 8 * 1024 * 1024);
> > }
>
> > [EMAIL PROTECTED]
> > protected void onStop()
> > {
> > super.onStop();
> > //android.os.Debug.stopMethodTracing();
> > }
> > }
>
> > class GLTutorialTwo extends SurfaceView implements
> > SurfaceHolder.Callback{
> > private OpenGLContext glContext;
> > private SurfaceHolder holder;
> > private GL10 gl;
>
> > float[] square = new float[] { 0.25f, 0.25f, 0.0f,
>
> > 0.75f, 0.25f, 0.0f,
>
> > 0.25f, 0.75f, 0.0f,
>
> > 0.75f, 0.75f, 0.0f };
> > /*
> > byte[] indices = {
> > 0,1, 1,2, 2,3, 3,0
> > };
> > */
> > FloatBuffer squareBuff;
>
> > public GLTutorialTwo(Context c) {
> > super(c);
> > holder = getHolder();
> > holder.addCallback(this);
>
> > }
>
> > protected void onDraw(GL10 gl) {
>
> > gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
> > gl.glColor4f(1,1,1,1);
> > gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
> > GLU.gluOrtho2D(gl, 0.0f,1.2f,0.0f,1.0f);
> > gl.glVertexPointer(3, GL10.GL_FLOAT, 0, squareBuff);
> > glContext.post();
> > }
>
> > [EMAIL PROTECTED]
> > public void surfaceChanged(SurfaceHolder holder, int format, int
> > width,
> > int height) {
> > // TODO Auto-generated method stub
> > gl.glViewport(0,0,width,height);
>
> > }
>
> > [EMAIL PROTECTED]
> > public void surfaceCreated(SurfaceHolder holder) {
> > // TODO Auto-generated method stub
>
> > glContext = new OpenGLContext(0);
> > glContext.waitNative();
> > glContext.makeCurrent(holder);
>
> > gl = (GL10)glContext.getGL();
> > gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
> > GL10.GL_FASTEST);
> > gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
> > // gl.glTranslatef(0,0, -3.0f);
>
> > gl.glMatrixMode(GL10.GL_PROJECTION);
> > gl.glLoadIdentity();
>
> > gl.glEnable(GL10.GL_DITHER);
> > gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
> > gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
> > gl.glEnable(GL10.GL_CULL_FACE);
> > gl.glShadeModel(GL10.GL_SMOOTH);
>
> > ByteBuffer bb = ByteBuffer.allocateDirect(square.length*4);
> > bb.order(ByteOrder.nativeOrder());
> > squareBuff = bb.asFloatBuffer();
> > squareBuff.put(square);
> > squareBuff.position(0);
>
> > // gl.glDrawElements(GL10.GL_LINES, 8, GL10.GL_UNSIGNED_BYTE,
> > ib);
>
> > onDraw(gl);
> > }
>
> > [EMAIL PROTECTED]
> > public void surfaceDestroyed(SurfaceHolder arg0) {
> > // TODO Auto-generated method stub
>
> > }
> > }
>
> > Who knows the problem,please tell me,thanks very much!
--~--~---------~--~----~------------~-------~--~----~
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 Android 0.9 SDK beta!
http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---