Android drawing texture with OpenGL ES 2.0 slow on some devices

drgr

In my Android 4.3 application, I would like to load a texture from a local png onto a TextureView. I do not know OpenGL and I am using the code from the GLTextureActivity hardware acceleration test. I am pasting also the loading texture part here:

    private int loadTexture(int resource) {
        int[] textures = new int[1];

        glActiveTexture(GL_TEXTURE0);
        glGenTextures(1, textures, 0);
        checkGlError();

        int texture = textures[0];
        glBindTexture(GL_TEXTURE_2D, texture);
        checkGlError();

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

        Bitmap bitmap = BitmapFactory.decodeResource(mResources, resource);

        GLUtils.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bitmap, GL_UNSIGNED_BYTE, 0);
        checkGlError();

        bitmap.recycle();

        return texture;
    }

I am running the code in two devices: Nexus 7 and Galaxy Nexus phone, and I notice a huge speed difference between the two. For Nexus 7, the drawing part takes about 170 ms, although for the Galaxy Nexus it takes 459 ms. The most time consuming operation is the loading of the texture and especially the texImage2D call. I have read that there are devices with chips that are slow on texImage2D-texSubImage2D functions but how can someone tell which are those devices and how can I avoid to use those functions to achieve the same result?

Thank you in advance.

// EDIT: the glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) call seems to also be significantly slower in the phone device. Why is this happening? How could I avoid it?

keaukraine

Are you loading textures on each frame redraw? That's just not right - you should load textures only once before main rendering loop. You won't get instant textures loading even on the fastest possible device - you load resource, decode bitmap from it and then load it to GPU. This takes some time.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android drawing texture with OpenGL ES 2.0 slow on some devices

From Dev

Android OpenGL.ES Texture/Image Drawing

From Dev

android opengl es 1.1 - drawing glitch on certain devices - screenshots inside

From Dev

Android OpenGL ES 2 Texture Quadrants Rotated

From Dev

Android OpenGL ES Not Drawing

From Dev

Android OpenGL ES 2.0 - Textures not showing on some devices

From Dev

Android OpenGL ES2.0, shader compile false on some devices

From Dev

Drawing a 2D texture in OpenGL

From Dev

How to add some pixels on the texture in OpenGL ES

From Dev

How to add some pixels on the texture in OpenGL ES

From Dev

Drawing a texture in opengl in C

From Dev

Android AudioTrack extremely slow on some devices

From Dev

Android AudioTrack extremely slow on some devices

From Dev

OpenGL ES 2.0 drawing more than one texture

From Dev

OpenGL drawing to an existing HDC using Texture2D

From Dev

How to render to a depth texture in OpenGL ES on Android

From Dev

Android: OpenGL drawing only on one quarter of screen on Exynos devices

From Dev

Drawing a texture in modern OpenGL with lwjgl

From Dev

Drawing OpenGL ES 2.0 Line with onTouch Android

From Dev

OpenGL ES single pixel drawing android

From Dev

Some Android devices extremely slow when rendering canvas elements

From Dev

OpenGL ES: Texture a plane

From Dev

Android OpenGL ES 2. 0 VBO Not Rendering

From Dev

OpenGL Textures have distorted colors on some android devices

From Dev

android opengl texture overlapping

From Dev

Android Opengl Circle Texture

From Dev

Texture compression strategy for Android OpenGL ES that caters for alphas

From Dev

how to load android camera frame into opengl es texture via ndk?

From Dev

Android OpenGL ES 2.0 Texture setting does not seem to work

Related Related

  1. 1

    Android drawing texture with OpenGL ES 2.0 slow on some devices

  2. 2

    Android OpenGL.ES Texture/Image Drawing

  3. 3

    android opengl es 1.1 - drawing glitch on certain devices - screenshots inside

  4. 4

    Android OpenGL ES 2 Texture Quadrants Rotated

  5. 5

    Android OpenGL ES Not Drawing

  6. 6

    Android OpenGL ES 2.0 - Textures not showing on some devices

  7. 7

    Android OpenGL ES2.0, shader compile false on some devices

  8. 8

    Drawing a 2D texture in OpenGL

  9. 9

    How to add some pixels on the texture in OpenGL ES

  10. 10

    How to add some pixels on the texture in OpenGL ES

  11. 11

    Drawing a texture in opengl in C

  12. 12

    Android AudioTrack extremely slow on some devices

  13. 13

    Android AudioTrack extremely slow on some devices

  14. 14

    OpenGL ES 2.0 drawing more than one texture

  15. 15

    OpenGL drawing to an existing HDC using Texture2D

  16. 16

    How to render to a depth texture in OpenGL ES on Android

  17. 17

    Android: OpenGL drawing only on one quarter of screen on Exynos devices

  18. 18

    Drawing a texture in modern OpenGL with lwjgl

  19. 19

    Drawing OpenGL ES 2.0 Line with onTouch Android

  20. 20

    OpenGL ES single pixel drawing android

  21. 21

    Some Android devices extremely slow when rendering canvas elements

  22. 22

    OpenGL ES: Texture a plane

  23. 23

    Android OpenGL ES 2. 0 VBO Not Rendering

  24. 24

    OpenGL Textures have distorted colors on some android devices

  25. 25

    android opengl texture overlapping

  26. 26

    Android Opengl Circle Texture

  27. 27

    Texture compression strategy for Android OpenGL ES that caters for alphas

  28. 28

    how to load android camera frame into opengl es texture via ndk?

  29. 29

    Android OpenGL ES 2.0 Texture setting does not seem to work

HotTag

Archive