Guest User

Code

a guest
Dec 3rd, 2013
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. package spark;
  2.  
  3. import org.lwjgl.openal.AL;
  4. import org.lwjgl.opengl.Display;
  5. import org.lwjgl.opengl.DisplayMode;
  6. import org.lwjgl.LWJGLException;
  7. import org.lwjgl.opengl.GL11;
  8. import org.lwjgl.util.WaveData;
  9. import org.newdawn.slick.Color;
  10. import org.newdawn.slick.opengl.Texture;
  11. import org.newdawn.slick.opengl.TextureLoader;
  12.  
  13. import java.io.File;
  14. import java.io.FileInputStream;
  15. import java.io.FileNotFoundException;
  16. import java.io.IOException;
  17. import java.util.ArrayList;
  18. import static org.lwjgl.opengl.GL11.*;
  19.  
  20.  
  21. public class Main {
  22.  
  23.  
  24. private Texture sky;
  25.  
  26. public Main() {
  27.  
  28.  
  29. try {
  30. Display.setDisplayMode(new DisplayMode(640, 480));
  31. Display.setTitle("Spark");
  32. Display.create();
  33.  
  34. sky = TextureLoader.getTexture("PNG", new FileInputStream(new File("resources/textures/sky.png")));
  35.  
  36.  
  37.  
  38. while(!Display.isCloseRequested()) {
  39.  
  40. setCamera();
  41.  
  42. sky.bind();
  43. glEnable(GL_TEXTURE_2D);
  44. glBegin(GL_QUADS);
  45. glColor3d(1, 1, 1);
  46.  
  47. glTexCoord2f(1, 0);
  48. glVertex2i(640, 0);
  49. glTexCoord2f(0, 0);
  50. glVertex2i(0, 0);
  51. glTexCoord2f(0, 1);
  52. glVertex2i(0, 480);
  53.  
  54. glTexCoord2f(0, 1);
  55. glVertex2i(0, 480);
  56. glTexCoord2f(1, 1);
  57. glVertex2i(640, 640);
  58. glTexCoord2f(1, 0);
  59. glVertex2i(640, 0);
  60.  
  61. glEnd();
  62. glDisable(GL_TEXTURE_2D);
  63.  
  64. Display.update();
  65. Display.sync(60);
  66. }
  67. sky.release();
  68. Display.destroy();
  69. } catch (LWJGLException e) {
  70. e.printStackTrace();
  71. } catch(IOException e) {
  72. e.printStackTrace();
  73. }
  74. }
  75.  
  76. public static void main(String[] args) {
  77. new Main();
  78. }
  79.  
  80.  
  81. public static void setCamera() {
  82.  
  83. //Clear Screen
  84. glClear(GL_COLOR_BUFFER_BIT);
  85. //Modifying the projection matrix
  86. glMatrixMode(GL_PROJECTION);
  87. glLoadIdentity();
  88. glOrtho(0, 640, 0, 480, -1, 1);
  89. //Modify modelviewing matrix
  90. glMatrixMode(GL_MODELVIEW);
  91. glLoadIdentity();
  92.  
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment