Guest User

Untitled

a guest
Mar 25th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1.  
  2. import org.lwjgl.opengl.GL11;
  3. import org.lwjgl.opengl.Display;
  4. import org.lwjgl.opengl.DisplayMode;
  5. import org.lwjgl.util.glu.GLU;
  6.  
  7.  
  8.  
  9.  
  10. /*
  11. * Sets up the Display, the GL context, and runs the main game
  12. loop.
  13. *
  14. * @author Stephen Jones
  15. */
  16. public class a{
  17.  
  18. private boolean done=false; //game runs until done is set to true
  19. private Box box = new Box();
  20.  
  21. public a(){
  22. init();
  23.  
  24. while(!done){
  25. if(Display.isCloseRequested())
  26. done=true;
  27. render();
  28. Display.update();
  29. }
  30.  
  31. Display.destroy();
  32. }
  33.  
  34. private void render(){
  35. GL11.glClear(GL11.GL_COLOR_BUFFER_BIT |
  36. GL11.GL_DEPTH_BUFFER_BIT);
  37. GL11.glLoadIdentity();
  38. box.draw();
  39. }
  40.  
  41. private void init(){
  42. int w=1024;
  43. int h=768;
  44.  
  45. try{
  46. Display.setDisplayMode(new DisplayMode(w, h));
  47. Display.setVSyncEnabled(true);
  48. Display.setTitle("Shader Setup");
  49. Display.create();
  50. }catch(Exception e){
  51. System.out.println("Error setting up display");
  52. System.exit(0);
  53. }
  54.  
  55. GL11.glViewport(0,0,w,h);
  56. GL11.glMatrixMode(GL11.GL_PROJECTION);
  57. GL11.glLoadIdentity();
  58. GLU.gluPerspective(45.0f, ((float)w/(float)h),0.1f,100.0f);
  59. GL11.glMatrixMode(GL11.GL_MODELVIEW);
  60. GL11.glLoadIdentity();
  61. GL11.glShadeModel(GL11.GL_SMOOTH);
  62. GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  63. GL11.glClearDepth(1.0f);
  64. GL11.glEnable(GL11.GL_DEPTH_TEST);
  65. GL11.glDepthFunc(GL11.GL_LEQUAL);
  66. GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT,
  67. GL11.GL_NICEST);
  68. }
  69.  
  70. public static void main(String[] args){
  71. new a();
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment