create And Set On OpenGL Buffer Object - Android android.opengl

Android examples for android.opengl:OpenGL Buffer

Description

create And Set On OpenGL Buffer Object

Demo Code


//package com.java2s;

import java.nio.FloatBuffer;

import android.opengl.GLES20;

public class Main {

    private static final int FSIZE = Float.SIZE / Byte.SIZE;

    private static int ma_Position;

    private static FloatBuffer vertexBuffer;

    private static void createAndSetOnBufferObject() {

        int[] vertexTexCoord = new int[1];
        GLES20.glGenBuffers(1, vertexTexCoord, 0);

        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vertexTexCoord[0]);
        GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER,
                FSIZE * vertexBuffer.limit(), vertexBuffer,
                GLES20.GL_DYNAMIC_DRAW);

        GLES20.glVertexAttribPointer(ma_Position, 2, GLES20.GL_FLOAT,
                false, 0, 0);//from  w w  w  . j a  v a  2 s. co m
        GLES20.glEnableVertexAttribArray(ma_Position);
    }
}

Related Tutorials