GLHelper.java 904 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package me.hammerle.snuviengine.api;
  2. import org.lwjgl.opengl.GL11;
  3. import org.lwjgl.opengl.GL15;
  4. import org.lwjgl.opengl.GL30;
  5. public class GLHelper
  6. {
  7. private static int currentVao = -1;
  8. private static int currentVbo = -1;
  9. private static int currentTexture = -1;
  10. protected static void glBindVertexArray(int vao)
  11. {
  12. if(vao != currentVao)
  13. {
  14. currentVao = vao;
  15. GL30.glBindVertexArray(vao);
  16. }
  17. }
  18. protected static void glBindBuffer(int vbo)
  19. {
  20. if(vbo != currentVbo)
  21. {
  22. currentVbo = vbo;
  23. GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
  24. }
  25. }
  26. protected static void glBindTexture(int texture)
  27. {
  28. if(texture != currentTexture)
  29. {
  30. currentTexture = texture;
  31. GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
  32. }
  33. }
  34. }