OpenGL LWJGL3 object in scene won't rotate

I am trying to find out how to use OpenGL with LWJGL3, however, I have failed with an early obstacle. I created the scene to display half an octegrad, with each face varying in color. I have this code to create a form:

    private void drawOctohedron() {
    glPushMatrix();
    glRotatef((float)glfwGetTime() * 60,0f,1f,0f);
    System.out.println(glfwGetTime());
    glBegin(GL_TRIANGLES); {
        glColor4f(1.0F, 0.0F, 0.0F, 1.0F);
        glVertex3i(0, 1, 0);
        glVertex3i(-1, 0, 0);
        glVertex3i(0, 0, 1);
        glNormal3i(-1, 1, 1);

        glColor4f(0.0F, 1.0F, 0.0F, 1.0F);
        glVertex3i(0, 1, 0);
        glVertex3i(0, 0, 1);
        glVertex3i(1, 0, 0);
        glNormal3i(1, 1, 1);

        glColor4f(0.0F, 0.0F, 1.0F, 1.0F);
        glVertex3i(0, 1, 0);
        glVertex3i(1, 0, 0);
        glVertex3i(0, 0, -1);
        glNormal3i(1, 1, -1);

        glColor4f(1.0F, 0.0F, 1.0F, 1.0F);
        glVertex3i(0, 1, 0);
        glVertex3i(0, 0, -1);
        glVertex3i(-1, 0, 0);
        glNormal3i(-1, 1, -1);
    }
    glPopMatrix();
}

      

and this is the loop:

    private void loop() {
    // This line is critical for LWJGL interoperation with GLFW's
    // OpenGL context, or any context that is managed externally.
    // LWJGL detects the context that is current in the current thread,
    // creates the ContextCapabilities instance and makes the OpenGL
    // bindings available for use.
    GLContext.createFromCurrent();

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    while ( glfwWindowShouldClose(window) == GL_FALSE ) {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glfwPollEvents();

        glMatrixMode(GL_MODELVIEW);

        glLoadIdentity();

        camera.lookThrough();

        drawOctohedron();

        glFlush();

        System.out.println("UPS: " + 1/(glfwGetTime() - lastTime));

        lastTime = glfwGetTime();

        glfwSwapBuffers(window);
    }

    System.out.println("Closing");

}

      

The form renders the display perfectly, but the rotation only happens once. The method is called every tick, and the System.out line prints a different value for every tick. My question is, why does the rotation only happen once and is not updated on the next method call? I'm probably just really stupid about one little thing.

+3


source to share





All Articles