ImageRenderer.java 822 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package eu.tankernn.gameEngine.postProcessing;
  2. import org.lwjgl.opengl.Display;
  3. import org.lwjgl.opengl.GL11;
  4. import eu.tankernn.gameEngine.loader.textures.Texture;
  5. public class ImageRenderer {
  6. private Fbo fbo;
  7. public ImageRenderer(int width, int height) {
  8. this(new Fbo(width, height, Fbo.NONE));
  9. }
  10. public ImageRenderer() {
  11. this(Display.getWidth(), Display.getHeight());
  12. }
  13. public ImageRenderer(Fbo fbo) {
  14. this.fbo = fbo;
  15. }
  16. public void renderQuad() {
  17. if (fbo != null) {
  18. fbo.bindFrameBuffer();
  19. }
  20. GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
  21. GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
  22. if (fbo != null) {
  23. fbo.unbindFrameBuffer();
  24. }
  25. }
  26. public Texture getOutputTexture() {
  27. return fbo.getColourTexture();
  28. }
  29. public void cleanUp() {
  30. if (fbo != null) {
  31. fbo.cleanUp();
  32. }
  33. }
  34. }