Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- import static org.lwjgl.opengl.GL11.*;
- import static org.lwjgl.util.glu.GLU.*;
- public class Main {
- public static int HEIGHT = 800;
- public static int WIDTH = 1000;
- public void start() {
- try {
- Display.setDisplayMode(new DisplayMode(WIDTH,HEIGHT));
- Display.create();
- } catch (LWJGLException e) {
- e.printStackTrace();
- System.exit(0);
- }
- // init OpenGL here
- /* Use depth buffering for hidden surface elimination. */
- glEnable(GL_DEPTH_TEST);
- /* Setup the view of the cube. */
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(45, (float)WIDTH/(float)HEIGHT, 1, 100);
- glMatrixMode(GL_MODELVIEW);
- int z = -50;
- while (!Display.isCloseRequested()) {
- //glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the background of our <a title="window" href="http://www.swiftless.com/tutorials/opengl/window.html">window</a> to red
- glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
- //glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations
- glColor3f(0f, 1f, 1f);
- glBegin(GL_QUADS);
- {
- glVertex3i(10, 10, z);
- glVertex3i(10+10, 10, z);
- glVertex3i(10+10, 10+10, z);
- glVertex3i(10, 10+10, z);
- }
- glEnd();
- glFlush(); // Flush the OpenGL buffers to the window
- Display.update();
- }
- Display.destroy();
- }
- public static void main(String[] argv) {
- Main m = new Main();
- m.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement