如果我将 GL_QUADS 切换到 GL_TRIANGLES 并删除最后一个点,三角形渲染得很好。但是,将其更改回 GL_QUADS 并添加另一个点只会让我出现黑屏。那我该怎么办?
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;
public class Main {
public Main() {
this.start();
}
private void start() {
try {
Display.setDisplayMode(new DisplayMode(640,640));
Display.setTitle("FPSTest");
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(-10, 10, -10, 10, -1000, 1000);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
while (!Display.isCloseRequested()) {
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT|GL11.GL_COLOR_BUFFER_BIT);
GL11.glRotatef(0, 1, 1, 1);
GL11.glBegin(GL11.GL_QUADS);
// GL11.glBegin(GL11.GL_TRIANGLES);
{
GL11.glColor3f(1.0f, 0.0f, 0.0f);
GL11.glVertex3f(0.0f, 3.0f, 0.0f);
GL11.glColor3f(0.0f, 1.0f, 0.0f);
GL11.glVertex3f(0.0f, 0.0f, -3.0f);
GL11.glColor3f(0.0f, 0.0f, 1.0f);
GL11.glVertex3f(3.0f, 0.0f, 0.0f);
GL11.glColor3f(0.0f, 1.0f, 0.0f);
GL11.glVertex3f(0.0f, 0.0f, 3.0f);
}
GL11.glEnd();
GL11.glLoadIdentity();
Display.update();
}
Display.destroy();
}
public static void main(String[] argv) {
new Main();
}
}