LWJGL/Java OpenGL投影矩阵-什么都不会发生

LWJGL/Java OpenGL投影矩阵-什么都不会发生,java,opengl,matrix,lwjgl,projection,Java,Opengl,Matrix,Lwjgl,Projection,我对opengl中的投影矩阵有一个问题。 我使用LWJGL 2.9.3和java 7,当我在没有投影矩阵的情况下绘制四边形时,它可以工作,但当我使用投影矩阵绘制时,什么都不会发生 这是我的密码: 对于创建投影矩阵: private void createProjectionMatrix() { float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight(); float y_scale =

我对opengl中的投影矩阵有一个问题。 我使用LWJGL 2.9.3和java 7,当我在没有投影矩阵的情况下绘制四边形时,它可以工作,但当我使用投影矩阵绘制时,什么都不会发生

这是我的密码: 对于创建投影矩阵:

private void createProjectionMatrix()
{
    float aspectRatio = (float) Display.getWidth() / (float) Display.getHeight();
    float y_scale = (float) ((1f / Math.tan(Math.toRadians(FOV / 2f))) * aspectRatio);
    float x_scale = y_scale / aspectRatio;
    float frustum_length = FAR_PLANE - NEAR_PLANE;

    projectionMatrix = new Matrix4f();
    projectionMatrix.m00 = x_scale;
    projectionMatrix.m11 = y_scale;
    projectionMatrix.m22 = -((FAR_PLANE + NEAR_PLANE) / frustum_length);
    projectionMatrix.m23 = -1;
    projectionMatrix.m32 = -((2 * NEAR_PLANE * FAR_PLANE) / frustum_length);
    projectionMatrix.m33 = 0;
}
对于渲染四边形:

public void renderVAOObject(VAOObject object)
{       
    GL30.glBindVertexArray(object.getVaoID());
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, object.getIndexBufferId());

    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);
    GL20.glEnableVertexAttribArray(2);

    GL11.glDrawElements(drawMode, object.getVerticesCount(), GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
    GL20.glDisableVertexAttribArray(2);

    GL30.glBindVertexArray(0);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}

public void render(GameObject object, BasicShader shader)
{
    shader.bind();

    TexturedModel model = object.getModel();
    VAOObject vao = model.getVAOObject();

    model.getTexture().bind();

    Matrix4f transform = MatrixUtils.createTransformationMatrix(object.getPosition(), object.getRotation(), object.getScale());
    shader.loadTransformationMatrix(transform);

    renderVAOObject(vao);
    model.getTexture().unbind();

    shader.unbind();
}
(VaooObject只是顶点数组缓冲区的一个类)

和我的顶点着色器:

#version 330

layout(location = 0) in vec3 position;
layout(location = 1) in vec4 color;
layout(location = 2) in vec2 textureCoords;

out vec4 vColor;
out vec2 vTextureCoords;

uniform mat4 transform;
uniform mat4 projectionMatrix;

void main()
{
    vColor = color;
    vTextureCoords = textureCoords;
    gl_Position = projectionMatrix * transform * vec4(position, 1);
}

如果您需要更多代码或精度,请说出来。

尝试将四边形放置在远离您的位置+。另外,如果您试图将四边形渲染为GL_四边形,则只需将其变慢,您现在可能感觉不到,但三角形是最快的。@Arthur:您的对象在iObject空间中的位置是什么?
transform
设置为什么?您正在使用投影矩阵的哪些参数?确保对象不是简单地从平截头体中变换出来。变换矩阵:平移:0,0,10,缩放:1,旋转:0,0,0/投影矩阵:FOV:70,近平面:0.1,远平面:1000/drawMode=GL_三角形将四边形从您的位置向外移动+。另外,如果您试图将四边形渲染为GL_四边形,则只需将其变慢,您现在可能感觉不到,但三角形是最快的。@Arthur:您的对象在iObject空间中的位置是什么?
transform
设置为什么?您正在使用投影矩阵的哪些参数?确保对象不是简单地从平截头体中变换出来。变换矩阵:平移:0,0,10,比例:1,旋转:0,0,0/投影矩阵:FOV:70,近平面:0.1,远平面:1000/drawMode=GL_三角形