-8

我正在尝试修改 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);
    }
4

2 回答 2

0

尝试清理构建。有时这就是清理莫名其妙的语法错误所需要的一切。

于 2012-08-05T03:25:32.820 回答
-1

尝试

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

        // Draw triangle
        mTriangle.draw(mMVPMatrix);
    } 
}
于 2012-08-05T02:46:09.673 回答