为什么我的Opengl es android测试床应用程序除了呈现红色屏幕外没有呈现任何内容?

为什么我的Opengl es android测试床应用程序除了呈现红色屏幕外没有呈现任何内容?,android,opengl-es,Android,Opengl Es,出于某种原因,我这里的代码除了红色屏幕外,实际上没有呈现任何东西。。谁能告诉我为什么 package com.ntu.way2fungames.earth.testbed; import java.nio.FloatBuffer; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; import android.app.Activity; impo

出于某种原因,我这里的代码除了红色屏幕外,实际上没有呈现任何东西。。谁能告诉我为什么

package com.ntu.way2fungames.earth.testbed;

import java.nio.FloatBuffer;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
import android.os.Bundle;

public class projectiles extends Activity {
    GLSurfaceView lGLView;
    Renderer lGLRenderer;
    float projectilesX[]= new float[5001];
    float projectilesY[]= new float[5001];
    float projectilesXa[]= new float[5001];
    float projectilesYa[]= new float[5001];
    float projectilesTheta[]= new float[5001];
    float projectilesSpeed[]= new float[5001];
    private static FloatBuffer drawBuffer;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        SetupProjectiles();

        Context mContext = this.getWindow().getContext();
        lGLView= new MyView(mContext);
        lGLRenderer= new MyRenderer();
        lGLView.setRenderer(lGLRenderer);
        setContentView(lGLView);
    }

    private void SetupProjectiles() {
        int i=0;
        for (i=5000;i>0;i=i-1){
            projectilesX[i] = 240;
            projectilesY[i] = 427;

            float theta = (float) ((i/5000)*Math.PI*2);
            projectilesXa[i] = (float) Math.cos(theta);
            projectilesYa[i] = (float) Math.sin(theta);
            projectilesTheta[i]= theta;
            projectilesSpeed[i]= (float) (Math.random()+1);
        }

    }

    public class MyView extends GLSurfaceView{

        public MyView(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
        }

    }

    public class MyRenderer implements Renderer{

        private float[] projectilecords = new float[] {
               .0f, .5f, 0,
              -.5f,  0f, 0,
               .5f,  0f, 0,
                 0, -5f, 0,

        };


        @Override
        public void onDrawFrame(GL10 gl) {

            gl.glClear(GL10.GL_COLOR_BUFFER_BIT);                
            gl.glMatrixMode(GL10.GL_MODELVIEW);
            //gl.glLoadIdentity();
            gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
            for (int i=5000;i>4500;i=i-1){

                //drawing section
                gl.glLoadIdentity();
                gl.glColor4f(.9f, .9f,.9f,.9f);
                gl.glTranslatef(projectilesY[i], projectilesX[i],1);    
                gl.glVertexPointer(3, GL10.GL_FLOAT, 0, drawBuffer); 
                gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 12);


                //physics section
                projectilesX[i]=projectilesX[i]+projectilesXa[i];
                projectilesY[i]=projectilesY[i]+projectilesYa[i];


            }
            gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        }

        @Override
        public void onSurfaceChanged(GL10 gl, int width, int height) {
             if (height == 0) height = 1;
             // draw on the entire screen
             gl.glViewport(0, 0, width, height);
             // setup projection matrix
             gl.glMatrixMode(GL10.GL_PROJECTION);
             gl.glLoadIdentity();
             gl.glOrthof(0,width,height,0, -100, 100);

        }

        @Override
        public void onSurfaceCreated(GL10 gl, EGLConfig arg1) {
            gl.glShadeModel(GL10.GL_SMOOTH);
            gl.glClearColor(1f, .01f, .01f, 1f);

            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);

            drawBuffer = FloatBuffer.wrap(projectilecords);         
        }


    }
}

结果是弹丸初始化代码被破坏了

 int i=0;
        for (i=5000;i>0;i=i-1){
            projectilesX[i] = 240;
            projectilesY[i] = 427;

            float theta = (float) ((i/5000)*Math.PI*2);
            projectilesXa[i] = (float) Math.cos(theta);
            projectilesYa[i] = (float) Math.sin(theta);
            projectilesTheta[i]= theta;
            projectilesSpeed[i]= (float) (Math.random()+1);
        }
不知道确切的原因,但当我用

int i=0;
        float pi2=(float)(Math.PI *2);
        for (i=5000;i>0;i=i-1){
            projectilesX[i] = 160;
            projectilesY[i] = 320;

            float theta = (float)(Math.random());
            projectilesSpeed[i]= (float) (Math.random()+1);
            projectilesXa[i] = (float) Math.cos(theta*pi2)*projectilesSpeed[i];
            projectilesYa[i] = (float) Math.sin(theta*pi2)*projectilesSpeed[i];
            projectilesTheta[i]= (float) (theta*360);

        }
事情开始起作用了