2013-01-11 15 views
0

你好,我的渲染是非常糟糕的Tegra 3設備..任何想法這可能嗎? 這裏有兩個屏幕。第一個是從華碩A510平板電腦出問題的一個,第二個是我的Galaxy Nexus正確的渲染meshobjects是毛病,但只在Tegra 3設備

glitchy Tegra 3

correct rendering on gnex

這裏是我的呈現類的代碼:

public class ShowCaseRenderer { 

GLGraphics glGraphics; 
LookAtCamera camera; 

AmbientLight ambientLight; 
DirectionalLight directionalLight; 
public float rotation = 0; 
public static float rotationCamera = 0; 

private Vector2 camDirection; 

public static final int SWIPE_LEFT = -1; 
public static final int SWIPE_RIGHT = 1; 

public ShowCaseRenderer(GLGraphics glGraphics) { 

    camDirection = new Vector2(); 

    this.glGraphics = glGraphics; 
    camera = new LookAtCamera(67, glGraphics.getWidth() 
      /(float) glGraphics.getHeight(), 0.1f, 100); 

    ambientLight = new AmbientLight(); 
    ambientLight.setColor(0.2f, 0.2f, 0.2f, 1.0f); 
    directionalLight = new DirectionalLight(); 
    directionalLight.setDirection(-1, -0.5f, 0); 

    GL10 gl = glGraphics.getGL(); 
    gl.glViewport(0, 0, glGraphics.getWidth(), glGraphics.getHeight()); 
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); 
    gl.glMatrixMode(GL10.GL_PROJECTION); 
    gl.glLoadIdentity(); 
    GLU.gluPerspective(gl, 67, 
      glGraphics.getWidth()/(float) glGraphics.getHeight(), 0.1f, 
      10.0f); 

} 

public void render(int swipe, float deltaTime) { 

    GL10 gl = glGraphics.getGL(); 



    camDirection.set((float) Math.cos(rotationCamera * Vector2.TO_RADIANS), 
      (float) Math.sin(rotationCamera * Vector2.TO_RADIANS)).nor(); 

    camera.getPosition().set(0, 0, 0) 
      .sub(camDirection.x * 2.55f, -0.4f, camDirection.y * 2.5f); 

    camera.getLookAt().set(0, 0, 0); 

    camera.setMatrices(gl); 

    gl.glEnable(GL10.GL_DEPTH_TEST); 
    gl.glEnable(GL10.GL_TEXTURE_2D); 
    gl.glEnable(GL10.GL_LIGHTING); 
    gl.glEnable(GL10.GL_COLOR_MATERIAL); 
    gl.glEnable(GL10.GL_BLEND); 

    ambientLight.enable(gl); 
    directionalLight.enable(gl, GL10.GL_LIGHT0); 

    if (swipe == SWIPE_LEFT && rotationCamera % 90 != 0) { 

     rotationCamera = rotationCamera -= 1.5f; 

    } 

    if (swipe == SWIPE_RIGHT && rotationCamera % 90 != 0) { 

     rotationCamera = rotationCamera += 1.5f; 

    } 

    if (rotationCamera == 360) 
     rotationCamera = 0; 
    if (rotationCamera < 0) 
     rotationCamera = rotationCamera + 360; 

    //eigenRotation der Autos 
    rotation = rotation += deltaTime * 25; 
    if (rotation > 360) { 
     rotation = rotation - 360; 
    } 

    renderShowCase(gl); 



    gl.glDisable(GL10.GL_TEXTURE_2D); 

    gl.glDisable(GL10.GL_COLOR_MATERIAL); 
    gl.glDisable(GL10.GL_LIGHTING); 
    gl.glDisable(GL10.GL_DEPTH_TEST); 
    gl.glDisable(GL10.GL_BLEND); 
} 

private void renderShowCase(GL10 gl) { 

    Assets.ectoMobileTexture.bind(); 
    Assets.ectoMobileModel.bind(); 

    gl.glPushMatrix(); 

    gl.glTranslatef(0, 0.01f, -1.5f); 

    gl.glRotatef(-rotation, 0, 1, 0); 

    Assets.ectoMobileModel.draw(GL10.GL_TRIANGLES, 0, 
      Assets.ectoMobileModel.getNumVertices()); 
    gl.glPopMatrix(); 

    Assets.ectoMobileModel.unbind(); 

    Assets.batMobileTexture.bind(); 
    Assets.batMobileModel.bind(); 

    gl.glPushMatrix(); 

    gl.glTranslatef(0, 0.01f, 1.5f); 

    gl.glRotatef(-rotation, 0, 1, 0); 

    Assets.batMobileModel.draw(GL10.GL_TRIANGLES, 0, 
      Assets.batMobileModel.getNumVertices()); 
    gl.glPopMatrix(); 

    Assets.batMobileModel.unbind(); 

    Assets.mysteryMachineTexture.bind(); 
    Assets.mysteryMachineModel.bind(); 

    gl.glPushMatrix(); 

    gl.glTranslatef(-1.5f, 0.01f, 0); 

    gl.glRotatef(-rotation, 0, 1, 0); 

    Assets.mysteryMachineModel.draw(GL10.GL_TRIANGLES, 0, 
      Assets.mysteryMachineModel.getNumVertices()); 
    gl.glPopMatrix(); 

    Assets.mysteryMachineModel.unbind(); 

    Assets.podRacerTexture.bind(); 
    Assets.podRacerModel.bind(); 

    gl.glPushMatrix(); 

    gl.glTranslatef(1.5f, 0.01f, 0); 

    gl.glRotatef(-rotation, 0, 1, 0); 

    Assets.podRacerModel.draw(GL10.GL_TRIANGLES, 0, 
      Assets.podRacerModel.getNumVertices()); 
    gl.glPopMatrix(); 

    Assets.podRacerModel.unbind(); 

} 

    } 

謝謝你...

回答

1

好的解決了這個問題。小故障導致了一個guiElement,這有一個奇怪的混合配置...