Code example for GL10

Methods: glBindTexture, glGenTextures, glGetError, glTexEnvf, glTexParameterf

0
     * @return OpenGL texture entry id 
     */ 
    protected int loadBitmapIntoOpenGL(Context context, GL10 gl,  Bitmap bitmap, boolean useMipmaps) {
        int textureName = -1;
        if (context != null && gl != null) {
            gl.glGenTextures(1, mTextureNameWorkspace, 0);
 
            textureName = mTextureNameWorkspace[0];
            gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName);
             
            if (useMipmaps) {
            	if (mTextureFilter == FILTER_TRILINEAR) {
            		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR_MIPMAP_LINEAR);
            	} else { 
            		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR_MIPMAP_NEAREST);
            	} 
            } else { 
            	if (mTextureFilter == FILTER_NEAREST_NEIGHBOR) {
            		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
            	} else { 
            		gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
            	} 
            } 
             
            if (mTextureFilter == FILTER_NEAREST_NEIGHBOR) {
            	gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
            } else { 
            	gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
            } 
 
            gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
            gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
 
            gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_MODULATE);
 
            GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
 
            int error = gl.glGetError();
            if (error != GL10.GL_NO_ERROR) {
                Log.e("SimpleGLRenderer", "Texture Load GLError: " + error);
            } 
         
        }