Question

I am running an app that displays many bitmaps and a single translation animation. On the emulator, this works all the time with the rare exception that the width and height (derived from the device) are switched. However, on a friend's Galaxy SIII, none of textures are showing, neither are the quads. After trying to see if the animation ran, it didn't, yet the glClear function draws the correct color for the background. Therefore the program is still rendering. I'm using an orthographic view with the following renderer.

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import android.opengl.GLSurfaceView.Renderer;


public class GLrenderer implements Renderer {

private Context context;
long startTime; 
public GLrenderer(Context context) {
    this.context = context;

}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {       
    //Load the texture for the cube once during Surface creation

    MenuGameLoop.button.now.position_x=0;
    MenuGameLoop.button.past.position_x=0;
    MenuGameLoop.button.loadGLTexture(gl, this.context);
    MenuGameLoop.overlay.loadGLTexture(gl, this.context);
    for(int i=0;i<Splash.cubes.size();i++){
    Block ice=Splash.cubes.get(i);
    ice.loadGLTexture(gl, this.context, ice.width, ice.height,ice.overall,ice.subWidth, ice.subHeight);
    }
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glEnable(GL10.GL_TEXTURE_2D);            
    gl.glShadeModel(GL10.GL_SMOOTH);            
    gl.glClearColor(0.0f, 0.666f, 0.831f, 1f); 
    gl.glClearDepthf(1.0f);                     
    gl.glEnable(GL10.GL_DEPTH_TEST);        
    gl.glDepthFunc(GL10.GL_LEQUAL);             

    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST); 
}


public void onDrawFrame(GL10 gl) {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);    
    gl.glLoadIdentity();
    MenuGameLoop.overlay.draw(gl);      
    gl.glPushMatrix();
    gl.glTranslatef( (float)MenuGameLoop.button.mid.position_x,(float)MenuGameLoop.button.mid.position_y+(Splash.sizeY/2), 0);  
    MenuGameLoop.button.draw(gl);

    gl.glPopMatrix();
    for(int i=0;i<Splash.cubes.size();i++){
        gl.glPushMatrix();
        Block ice=Splash.cubes.get(i);
        gl.glTranslatef (ice.posX,ice.posY, 0); 
        ice.draw(gl);
        gl.glPopMatrix();
        }

}

public void onSurfaceChanged(GL10 gl, int width, int height) {

    if(height == 0) {                   
        height = 1;                         
    }

    gl.glViewport(0, 0, width, height);     
    gl.glMatrixMode(GL10.GL_PROJECTION);    
    gl.glLoadIdentity();                    

    gl.glOrthof(0f, (float)width, (float)height, 0f, 0.1f, 100.0f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);     
    gl.glLoadIdentity();                    
    }
}

If a problem can not be deduced from the above, are there any specific things I should avoid/add into other sections of code?

Was it helpful?

Solution

Please ensure that you're using power-of-two textures.

Also, you might pick incompatible OpenGL ES config which works on emulator but not on device.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top