Alchitry
Alchitry

Reputation: 1549

glGenerateMipmap IMGSRV error

In my app I am trying to use textures but I am getting the errors

:0: SGXQueueTransfer: all paths failed
:0: HardwareMipGen: Failed to generate texture mipmap levels (error=3)

on my Galaxy Nexus. I don't get these errors on my EVO 4G.

Here is the relevant loading code.

private static int load(Context context, int resID) {
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),
            resID);

    int[] texts = new int[1];
    GLES20.glGenTextures(1, texts, 0);
    int texID = texts[0];

    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texID);

    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);

    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
            GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
            GLES20.GL_REPEAT);

    GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

    return texID;
}

private static int loadWithMipmap(Context context, int resID) {
    int texID = load(context, resID);

    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST);
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
            GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR_MIPMAP_NEAREST);

    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    return texID;
}

Any ideas what is going on and how I can fix it?

EDIT: There is only one image causing the error and it is a 1024x2048 png.

Upvotes: 2

Views: 3283

Answers (3)

Learn OpenGL ES
Learn OpenGL ES

Reputation: 4960

I saw this, and it worked once I squashed the image to be square. OpenGL doesn't give an error.

Upvotes: 1

Robin Davies
Robin Davies

Reputation: 7832

Frickin' scary. Tested on a Galaxy Nexus 7.

You need to do the following:

    GLES20.glTexParameterf(
        GLES20.GL_TEXTURE_2D,
        GLES20.GL_TEXTURE_MIN_FILTER,
    GLES20.GL_LINEAR_MIPMAP_NEAREST);
    this.context.checkError("GL_TEXTURE_MIN_FILTER");
    GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
        GLES20.GL_TEXTURE_MAG_FILTER,
    GLES20.GL_LINEAR);

Strictly speaking, I guess GL_LINEAR_MIPMAP_NEAREST isn't a valid MAG_FILTER. Nexus 7 thinks so anyway. And it mipmaps beautifully with the change made.

Upvotes: 1

rotoglup
rotoglup

Reputation: 5283

Wild guess, as I don't have any access to the hardware you're mentioning, but does the error occur with a texture that has non power of two dimensions ?

Upvotes: 0

Related Questions