LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Itun on April 05, 2011, 12:52:37

Title: LWJGL render
Post by: Itun on April 05, 2011, 12:52:37
I have a problem: when the object is removed from the camera center, it is stretched.
(http://img839.imageshack.us/img839/2982/capture1xs.jpg) (http://img839.imageshack.us/i/capture1xs.jpg/)
(http://img151.imageshack.us/img151/2992/capture2sh.jpg) (http://img151.imageshack.us/i/capture2sh.jpg/)
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);
    }
Title: Re: LWJGL render
Post by: CodeBunny on April 06, 2011, 10:50:33
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.