upload Buffer to OpenGL - Android android.opengl

Android examples for android.opengl:OpenGL Buffer

Description

upload Buffer to OpenGL

Demo Code


//package com.book2s;
import java.nio.Buffer;

import android.opengl.GLES20;

public class Main {

    public static int upload(Buffer bufferToUpload, int iTarget,
            int iBytesPerElement, int iUsage) {
        int buff[] = new int[1];
        GLES20.glGenBuffers(1, buff, 0);
        int handle = buff[0];

        GLES20.glBindBuffer(iTarget, handle);
        GLES20.glBufferData(iTarget, bufferToUpload.limit()
                * iBytesPerElement, bufferToUpload, iUsage);
        GLES20.glBindBuffer(iTarget, 0);
        return handle;
    }//  www  . java 2  s.  co m
}

Related Tutorials