令牌上的语法错误“(”,;预期

时间:2012-08-05 02:03:04

标签: java android eclipse

我正在尝试修改google的openGL示例,但我收到错误

syntax error on token "(" , ; expected

代码:

public class MyGLRenderer implements GLSurfaceView.Renderer 
{

    private static final String TAG = "MyGLRenderer";
    private Triangle mTriangle;
    private Square[] mSquare;

    private final float[] mMVPMatrix = new float[16];
    private final float[] mProjMatrix = new float[16];
    private final float[] mVMatrix = new float[16];
    private final float[] mRotationMatrix = new float[16];

    // Declare as volatile because we are updating it from another thread
    public volatile float mAngle;

    public void onSurfaceCreated(GL10 unused, EGLConfig config)
    {

        // Set the background frame color
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

        mTriangle = new Triangle();
        InitalizeSquares();
    }

    public void InitalizeSquares()
    {
         mSquare  = new Square[100];
         for(int i = 0; i < 10; i++)
         {
            for(int j = 0; j < 10; j++)
            {
                float[] pos = {j,i,0};
                mSquare[i*10 + j].SetPos(pos);
            }
         }
    }

    //Error here 
    public void onDrawFrame(GL10 unused){


        // Draw background color
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

        // Set the camera position (View matrix)
        Matrix.setLookAtM(mVMatrix, 0, 0, 0, -10, 0f, 0f, 0f, 0f, 1.0f, 0.0f);

        // Calculate the projection and view transformation
        Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);
        for(int i = 0; i < 10; i++)
        {
            for(int j = 0; j < 10; j++)
            {
                // Draw square
                mSquare[i*10 + j].draw(mMVPMatrix);
            }
        }

        // Create a rotation for the triangle
        //        long time = SystemClock.uptimeMillis() % 4000L;
        //        float angle = 0.090f * ((int) time);
        Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, -1.0f);

        // Combine the rotation matrix with the projection and camera view
        Matrix.multiplyMM(mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0);

        // Draw triangle
        mTriangle.draw(mMVPMatrix);
    }

2 个答案:

答案 0 :(得分:-1)

尝试

// Combine the rotation matrix with the projection and camera view
        Matrix.multiplyMM(mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0);

        // Draw triangle
        mTriangle.draw(mMVPMatrix);
    } 
}

答案 1 :(得分:-1)

尝试清理构建。有时,只需要清除无法解释的语法错误。