0

I have Nexsus 4 and several HTCs and my game works fine.

When I launch on Samsung 4 I see white rectangles (empty textures),

no errors,

Further, my game uses sensors but I see on Samsung 4 it doesn't work too,

but Samsung 3 - works,

please help,

[EDIT]

on Samsung 3 works!

I heard that they did a lot of changes with S4

[EDIT 2]

This is how I load textures:

public void loadTextures(GL10 gl, Context context){

    //Log.e(LOG_TAG, "DevQuestSprites :: loadTextures");  

    InputStream is;
    Bitmap bitmap;
    is = context.getResources().openRawResource(R.drawable.fly_a1_sprite);


    bitmap = BitmapFactory.decodeStream(is);
    try {
        is.close();
        is = null;
    } catch (IOException e) {
    }

    gl.glGenTextures(textureCount, textures, 0);

    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

    bitmap.recycle(); 

}

For me most impotent row is:

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

Here actually I put texture.

And this is draw method:

    public void draw(GL10 gl,
        ...
                    ...
        )
{   

     ...

    //gl.glMatrixMode(GL10.GL_MODELVIEW);

    gl.glTranslatef(transx, transy, 0.0f);

    gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);

    gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, floatBufferArray[mFrame]);

    gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 3);
    //gl.glDrawElements(GL10.GL_TRIANGLES, 1, GL10.GL_UNSIGNED_SHORT, vertexBuffer);
    gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
}

[EDIT 3]

I added to draw, onDrawFrame and main loop, no errors:

int error = gl.glGetError();
    if (error != 0)
        Log.e("main loop", "Draw " + error); 

After debugging I found only one new error for Samsung 4:

08-07 12:57:53.356: E/ViewRootImpl(29124): sendUserActionEvent() mView == null

[EDIT 4]

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig confid) {
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glShadeModel(GL10.GL_SMOOTH);        
    gl.glClearColor(0,0,0,0);
    gl.glClearDepthf(1.0f);
    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    gl.glEnable(GL10.GL_BLEND);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
}
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
  • Which version of GL ES are you trying to support? Looks like 1.x, but better to ask. –  Aug 07 '13 at 10:17
  • Are your textures have power-of-two dimensions? For NPOT ones you need to explicitly specify `CLAMP_TO_EDGE` mode. But because you get error which tells that view is null, you should check your OpenGL context init code first. – keaukraine Aug 07 '13 at 10:21
  • Thank for answer, how do I check `NPOT Texture`? I use `vertices = new float[12];` z=0. BTW, I added `onSurfaceCreated` – Maxim Shoustin Aug 07 '13 at 10:29

2 Answers2

1

One issue is that you have enabled alpha blending, but you can't use GLUtils.texImage2D() to load alpha textures on Android. This is a common problem that Google really should document better. The problem is that the Bitmap class converts all images into pre-multiplied format, but that does not work with OpenGL ES unless the image is completely opaque. The best solution is to use native code. This article gives more detail on this:

http://software.intel.com/en-us/articles/porting-opengl-games-to-android-on-intel-atom-processors-part-1

ClayMontgomery
  • 2,786
  • 1
  • 15
  • 14
  • If I don't use glBlendFunc, all my game seems messy , many items start to be static without animation. It works on some devices. – Maxim Shoustin Aug 07 '13 at 17:43
  • That sounds like an OpenGL ES driver bug. Does it work in an AVD? If you don't really need alpha blending, make your textures fully opaque, then using GLUtils.texImage2D() is not an issue. Also, you should use GL11 instead of GL10. GL10 is obsolete. – ClayMontgomery Aug 07 '13 at 18:59
0

What is the size of your image? if you are using opnel GL It depends on which driver have the mobile but you need the size image to be power of two to work fine in all devices, 2,4,8,16,32...etc

D4rWiNS
  • 2,585
  • 5
  • 32
  • 54