我编写了在屏幕上绘制矩形的应用程序。我想在 z 轴上移动这个矩形,但它不起作用。它消失了。我不知道如何修复它。
代码:
package game;
import org.lwjgl.opengl.GL;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;
public class Main {
public static void main(String[] args) {
glfwInit();
System.out.println("Hello World!");
long window = glfwCreateWindow(1280 ,720,"Title",0,0);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
GL.createCapabilities();
///////////////////////////////
glTranslatef(0,0,5);
///////////////////////////////
while(!glfwWindowShouldClose(window)){
glfwPollEvents();
glBegin(GL_QUADS);
glVertex2f(-0.5f,0.5f);
glVertex2f(-0.5f,-0.5f);
glVertex2f(0.5f,-0.5f);
glVertex2f(0.5f,0.5f);
glEnd();
System.out.println(z);
glfwSwapBuffers(window);
}
System.exit(0 );
}
}
Helenr
相关分类