libgdx: SpriteBatch не отображается в PerspectiveCamera

Хотя у меня есть базовые знания OpenGL, я только начинаю с libgdx.

Мой вопрос: почему наличие точно такого же кода, но только переключение с OrthographicCamera на PerspectiveCamera приводит к тому, что ни один из моих SpriteBatches больше не отображается?

Вот код, который я использую:

метод create():

public void create() {
    textureMesh = new Texture(Gdx.files.internal("data/texMeshTest.png"));
    textureSpriteBatch = new Texture(Gdx.files.internal("data/texSpriteBatchTest.png"));

    squareMesh = new Mesh(true, 4, 4, 
            new VertexAttribute(Usage.Position, 3, "a_position")
            ,new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords")

    );

    squareMesh.setVertices(new float[] {
            squareXInitial, squareYInitial, squareZInitial,             0,1,    //lower left
            squareXInitial+squareSize, squareYInitial, squareZInitial,  1,1,    //lower right
            squareXInitial, squareYInitial+squareSize, squareZInitial,  0,0,    //upper left
            squareXInitial+squareSize, squareYInitial+squareSize, squareZInitial,1,0});  //upper right 

    squareMesh.setIndices(new short[] { 0, 1, 2, 3});

    spriteBatch = new SpriteBatch();        
}

и метод render():

public void render() {
    GLCommon gl = Gdx.gl;

    camera.update();
    camera.apply(Gdx.gl10);
    spriteBatch.setProjectionMatrix(camera.combined);

    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    gl.glEnable(GL10.GL_DEPTH_TEST);

    gl.glEnable(GL10.GL_TEXTURE_2D);
    textureMesh.bind();
    squareMesh.render(GL10.GL_TRIANGLE_STRIP, 0, 4);

    spriteBatch.begin();
    spriteBatch.draw(textureSpriteBatch, -10, 0);
    spriteBatch.end();        
}

Теперь, если в моем методе resize(int width, int height) я настраиваю камеру как Итак:

   public void resize(int width, int height) {
        float aspectRatio = (float) width / (float) height;
        camera = new OrthographicCamera(cameraViewHeight * aspectRatio, cameraViewHeight);

Я получаю это:

enter image description here

Но если я изменю тип камеры:

public void resize(int width, int height) {
    float aspectRatio = (float) width / (float) height;
    camera = new PerspectiveCamera(64, cameraViewHeight * aspectRatio, cameraViewHeight);
}       

Я получаю это:

enter image description here

Причина, по которой я спрашиваю, заключается в том, что мне очень понравилась встроенная в libgdx способность рисовать текст (шрифт ) в OpenGL. Но в своих примерах они используют SpriteBatch, путь к экземпляру Font, а также всегда используют Ortho Camera. Тогда я хотел бы знать, работают ли функции рисования SpriteBatch и Font с PerspectiveCamera.

6
задан Lestat 18 December 2013 в 00:16
поделиться