Results 1 to 2 of 2

Thread: Converting changeable bitmap to a "GLTexture" on Android

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1

    Converting changeable bitmap to a "GLTexture" on Android

    Hi,
    I've got a question about converting bitmaps into OpenGL-textures. I used following code for loading textures yet:
    Code :
    private int loadTexture()
    	{
    		final int[] textureHandle = new int[1];
     
    	    GLES20.glGenTextures(1, textureHandle, 0);
     
    	    if (textureHandle[0] != 0)
    	    {	 
    	        // Bind to the texture in OpenGL
    	        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
     
    	        // Set filtering
    	        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    	        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
     
    	        // Load the bitmap into the bound texture.
    	        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
    	    }
     
    	    if (textureHandle[0] == 0)
    	    {
    	        throw new RuntimeException("Error loading texture.");
    	    }
     
    	    return textureHandle[0];
    	}

    That works fine as long as I just have to load the texture once. But, in my case the bitmap is changed for every frame through drawing on it via a canvas. How can I update the texture efficiently, because loading the texture every time is really low-performance and crashs when the system is running out of memory.?

    Thx Vaio
    PS: Sorry for my english, I'm not a native speaker

  2. #2
    Member
    Join Date
    Jun 2012
    Location
    Texas
    Posts
    61

    Re: Converting changeable bitmap to a "GLTexture" on Android

    Hello,

    What you are trying to do is called texture streaming, which OpenGL ES does not support directly. But, I recently wrote some articles on OpenGL ES which will help. The first one shows how to use EGL Image extensions on Android to transfer images into OpenGL ES textures fast:

    http://software.intel.com/en-us/article ... cy-2d-guis

    And this article details the pitfalls of using the Android Bitmap class with OpenGL ES:

    http://software.intel.com/en-us/article ... ors-part-1

    Regards, Clay

Similar Threads

  1. "vgSetParameterfv" vs "vgSetColor"
    By gthm159 in forum OpenVG and VGU
    Replies: 1
    Last Post: 08-15-2008, 02:28 AM
  2. "required extension" and "core addition"
    By wycwang in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 09-19-2007, 02:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •