Guest User

Untitled

a guest
Apr 13th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. package Functions;
  2.  
  3. import static org.lwjgl.opengl.GL11.*;
  4.  
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7.  
  8.  
  9. import org.newdawn.slick.opengl.Texture;
  10. import org.newdawn.slick.opengl.TextureLoader;
  11. import org.newdawn.slick.util.ResourceLoader;
  12.  
  13. public class renderer {
  14.  
  15.  
  16.  
  17. public static final int WIDTH = 1600, HEIGHT = 832;
  18.  
  19.  
  20.  
  21. public static void drawQuad(float x, float y, float quadWidth, float quadHeight){
  22. glBegin(GL_QUADS);
  23. glVertex2f(x,y);
  24. glVertex2f(x+quadWidth,y);
  25. glVertex2f(x+quadWidth,y+quadHeight);
  26. glVertex2f(x,y+quadHeight);
  27. glEnd();
  28. }
  29.  
  30. public static void drawQuadTex(Texture tex, float x, float y, float quadWidth, float quadHeight){
  31. tex.bind();
  32. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  33. glTranslatef(x, y, 0);
  34. glBegin(GL_QUADS);
  35.  
  36.  
  37. glTexCoord2f(0, 0);
  38. glVertex2f(0, 0);
  39.  
  40. glTexCoord2f(1, 0);
  41. glVertex2f(quadWidth, 0);
  42.  
  43. glTexCoord2f(1, 1);
  44. glVertex2f(quadWidth, quadHeight);
  45.  
  46. glTexCoord2f(0, 1);
  47. glVertex2f(0, quadHeight);
  48.  
  49. glEnd();
  50. glLoadIdentity();
  51.  
  52. }
  53.  
  54. public static Texture loadTexture(String path, String fileType){
  55. Texture tex = null;
  56. InputStream in = ResourceLoader.getResourceAsStream(path);
  57. try {
  58. tex = TextureLoader.getTexture(fileType, in);
  59. } catch (IOException e) {
  60. e.printStackTrace();
  61. }
  62. return tex;
  63. }
  64.  
  65. public static Texture quickLoad(String name){
  66. Texture tex = null;
  67. tex = loadTexture("res/img/" + name + ".png", "PNG");
  68. return tex;
  69. }
  70.  
  71.  
  72.  
  73. }
Add Comment
Please, Sign In to add comment