Advertisement
GinjaNinja32

TestPureLWJGL.java v2

May 10th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. package test;
  2.  
  3. import java.nio.ByteBuffer;
  4. import org.lwjgl.BufferUtils;
  5. import org.lwjgl.LWJGLException;
  6. import org.lwjgl.opengl.Display;
  7. import org.lwjgl.opengl.DisplayMode;
  8.  
  9. import static org.lwjgl.input.Keyboard.*;
  10. import static org.lwjgl.opengl.GL11.*;
  11.  
  12. /**
  13.  *
  14.  * @author GinjaNinja32
  15.  */
  16. public class TestPureLWJGL {
  17.  
  18.     /**
  19.      * @param args the command line arguments
  20.      */
  21.     public static void main(String[] args) throws LWJGLException {
  22.         Display.setTitle("Test");
  23.         Display.setDisplayMode(new DisplayMode(800, 600));
  24.         Display.create();
  25.        
  26.         int texID = glGenTextures();
  27.        
  28.         ByteBuffer bb = BufferUtils.createByteBuffer(4);
  29.         bb.put((byte)255).put((byte)255).put((byte)255).put((byte)255);
  30.         bb.flip();
  31.        
  32.         glBindTexture(GL_TEXTURE_2D, texID);
  33.     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, bb);
  34.        
  35.         while(!Display.isCloseRequested()) {
  36.             if(Display.wasResized()) {
  37.                 glViewport(0, 0, Display.getWidth(), Display.getHeight());
  38.             }
  39.            
  40.             if(isKeyDown(KEY_O)) {
  41.                 Display.setResizable(true);
  42.             } else if(isKeyDown(KEY_L)) {
  43.                 Display.setResizable(false);
  44.             }
  45.            
  46.             glClear(GL_COLOR_BUFFER_BIT);
  47.            
  48.             glBindTexture(GL_TEXTURE_2D, texID);
  49.             glBegin(GL_QUADS);
  50.                 glTexCoord2f(0, 0);
  51.                 glVertex2f(-0.9F, -0.9F);
  52.  
  53.                 glTexCoord2f(0, 1);
  54.                 glVertex2f(-0.9F, 0.9F);
  55.  
  56.                 glTexCoord2f(1, 1);
  57.                 glVertex2f(0.9F, 0.9F);
  58.  
  59.                 glTexCoord2f(1, 0);
  60.                 glVertex2f(0.9F, -0.9F);
  61.             glEnd();
  62.            
  63.            
  64.             Display.update();
  65.             Display.sync(60);
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement