generate opengl Texture - Android android.opengl

Android examples for android.opengl:OpenGL Texture

Description

generate opengl Texture

Demo Code

/*//from   w  w w  .j a v  a2  s. c o  m
 * Created by Zahari Pastarmadjiev.
 * Copyright (c) 2013 Wacom. All rights reserved.
 */
//package com.java2s;

import android.opengl.GLES20;

public class Main {
    /**
     * Constant: no OpenGl texture
     */
    public static int NO_TEXTURE_ID = 0;

    public static int generateTexture(boolean bBindTexture) {
        return generateTexture(NO_TEXTURE_ID, bBindTexture);
    }

    public static int generateTexture(int textureId, boolean bBindTexture) {
        int textures[] = new int[1];
        if (textureId == NO_TEXTURE_ID) {
            GLES20.glGenTextures(1, textures, 0);
            textureId = textures[0];
        }
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
        return textureId;
    }
}

Related Tutorials