LWJGL render

Started by Itun, April 05, 2011, 12:52:37

Previous topic - Next topic

Itun

I have a problem: when the object is removed from the camera center, it is stretched.


I have made this example in jogamp jogl it is correct.
    public void initSphere() {
        SphereVBOs = ByteBuffer.allocateDirect(8).order(ByteOrder.nativeOrder()).asIntBuffer();
        glGenBuffers(SphereVBOs);
        glBindBuffer(GL_ARRAY_BUFFER, SphereVBOs.get(0));
        glBufferData(GL_ARRAY_BUFFER, vertexBuffer, GL_STREAM_READ);
        glBindBuffer(GL_ARRAY_BUFFER, SphereVBOs.get(1));
        glBufferData(GL_ARRAY_BUFFER, normalBuffer, GL_STREAM_READ);
    }

    public void renderSphere() {
        glPolygonMode(GL_FRONT, GL_FILL);

        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_NORMAL_ARRAY);

        glBindBuffer(GL_ARRAY_BUFFER, SphereVBOs.get(0));
        glVertexPointer(3, GL_FLOAT, 0, 0L);
        glBindBuffer(GL_ARRAY_BUFFER, SphereVBOs.get(1));
        glNormalPointer(GL_FLOAT, 0, 0L);
        glColor3f(1.0f, 0.0f, 0.0f);
        glDrawArrays(GL_QUAD_STRIP, 0, (int) (vertexBuffer.limit() / 3));
        glBindBuffer(GL_ARRAY_BUFFER, 0);

        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_NORMAL_ARRAY);
    }

CodeBunny

That looks like a normal - albeit turned very high - perspective effect. Ever play Half Life 2? Same effect happens.

If you want to keep a "3D" look in your game, you'll probably want to mess around with your Frustum to get that to a more manageable level.

If you want it off, and don't want any sense of perspective, use glOrtho.