// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java
// public static void checkGlError(String label) {
//     int error;
//     while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
//         Log.e(TAG, label + ": glError " + error);
//         throw new RuntimeException(label + ": glError " + error);
//     }
// }


import android.content.Context;
import android.opengl.GLES20;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import static com.martin.ads.vrlib.utils.ShaderUtils.checkGlError;

        // initialize vertex byte buffer for shape coordinates
        ByteBuffer cc = ByteBuffer.allocateDirect(
                texcoords.length * 4);
        cc.order(ByteOrder.nativeOrder());
        FloatBuffer texBuffer = cc.asFloatBuffer();
        texBuffer.put(texcoords);
        texBuffer.position(0);

        // initialize byte buffer for the draw list
        ByteBuffer dlb = ByteBuffer.allocateDirect(
                // (# of coordinate values * 2 bytes per short)
                indices.length * 2);
        dlb.order(ByteOrder.nativeOrder());
        indexBuffer = dlb.asShortBuffer();
        indexBuffer.put(indices);
        indexBuffer.position(0);

        mTexCoordinateBuffer=texBuffer;
        mVerticesBuffer=vertexBuffer;
        mNumIndices=indices.length;
    }


    public void uploadVerticesBuffer(int positionHandle){
        FloatBuffer vertexBuffer = getVerticesBuffer();
        if (vertexBuffer == null) return;
        vertexBuffer.position(0);

        GLES20.glVertexAttribPointer(positionHandle, sPositionDataSize, GLES20.GL_FLOAT, false, 0, vertexBuffer);
// Path: vrlib/src/main/java/com/martin/ads/vrlib/utils/ShaderUtils.java
// public static void checkGlError(String label) {
//     int error;
//     while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR) {
//         Log.e(TAG, label + ": glError " + error);
//         throw new RuntimeException(label + ": glError " + error);
//     }
// }


// Path: vrlib/src/main/java/com/martin/ads/vrlib/object/Sphere.java
import android.content.Context;
import android.opengl.GLES20;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import static com.martin.ads.vrlib.utils.ShaderUtils.checkGlError;


        // initialize vertex byte buffer for shape coordinates
        ByteBuffer cc = ByteBuffer.allocateDirect(
                texcoords.length * 4);
        cc.order(ByteOrder.nativeOrder());
        FloatBuffer texBuffer = cc.asFloatBuffer();
        texBuffer.put(texcoords);
        texBuffer.position(0);

        // initialize byte buffer for the draw list
        ByteBuffer dlb = ByteBuffer.allocateDirect(
                // (# of coordinate values * 2 bytes per short)
                indices.length * 2);
        dlb.order(ByteOrder.nativeOrder());
        indexBuffer = dlb.asShortBuffer();
        indexBuffer.put(indices);
        indexBuffer.position(0);

        mTexCoordinateBuffer=texBuffer;
        mVerticesBuffer=vertexBuffer;
        mNumIndices=indices.length;
    }


    public void uploadVerticesBuffer(int positionHandle){
        FloatBuffer vertexBuffer = getVerticesBuffer();
        if (vertexBuffer == null) return;
        vertexBuffer.position(0);

        GLES20.glVertexAttribPointer(positionHandle, sPositionDataSize, GLES20.GL_FLOAT, false, 0, vertexBuffer);
        checkGlError("glVertexAttribPointer maPosition");