1

我正在运行一个显示许多位图和单个翻译动画的应用程序。在模拟器上,这一直有效,除了宽度和高度(来自设备)被切换的罕见例外。然而,在朋友的 Galaxy SIII 上,没有显示任何纹理,也没有显示四边形。在尝试查看动画是否运行后,它没有运行,但 glClear 函数为背景绘制了正确的颜色。因此程序仍在渲染中。我正在使用带有以下渲染器的正交视图。

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();                    
    }
}

如果不能从上面推断出问题,是否有任何具体的事情我应该避免/添加到其他代码部分?

4

1 回答 1

0

请确保您使用的是二次幂纹理。

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

于 2012-11-28T08:37:55.467 回答