List of usage examples for org.lwjgl.opengl GL30 glCheckFramebufferStatus
@NativeType("GLenum") public static int glCheckFramebufferStatus(@NativeType("GLenum") int target)
From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30FrameBuffer.java
License:Open Source License
@Override public void attachTexture(int point, Texture texture) { // Bind the frame buffer GL30.glBindFramebuffer(GL_FRAMEBUFFER, fbo); // Bind the texture to the frame buffer GL30.glFramebufferTexture2D(GL_FRAMEBUFFER, point, GL_TEXTURE_2D, texture.getId(), 0); // Add the attachment to the outputs if it is a colour type if (isColourAttachment(point)) { this.outputBuffers.add(point); }// w w w .j av a2 s . c o m // Update the output buffers updateOutputBuffers(); // Check to see if the frame buffer is complete if (GL30.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new IllegalStateException("Unable to complete frame buffer!"); } // Unbind the frame buffer GL30.glBindFramebuffer(GL_FRAMEBUFFER, 0); // Check for errors RenderUtil.checkGLError(); }
From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30FrameBuffer.java
License:Open Source License
@Override public void attachBuffer(int point, RenderBuffer buffer) { // Bind the frame buffer GL30.glBindFramebuffer(GL_FRAMEBUFFER, fbo); // Attach the render buffer to the frame buffer GL30.glFramebufferRenderbuffer(GL_FRAMEBUFFER, point, GL_RENDERBUFFER, buffer.getId()); RenderUtil.checkGLError();// www .j av a 2 s. c o m // Add the attachment to the outputs if it is a colour type if (isColourAttachment(point)) { this.outputBuffers.add(point); } // Update the output buffers updateOutputBuffers(); // Check to see if the frame buffer is complete if (GL30.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new IllegalStateException("Unable to complete frame buffer!"); } // Unbind the frame buffer GL30.glBindFramebuffer(GL_FRAMEBUFFER, 0); // Check for errors RenderUtil.checkGLError(); }
From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30FrameBuffer.java
License:Open Source License
@Override public void detach(int point) { // Bind the frame buffer GL30.glBindFramebuffer(GL_FRAMEBUFFER, fbo); // Detach the render buffer from the frame buffer GL30.glFramebufferRenderbuffer(GL_FRAMEBUFFER, point, GL_RENDERBUFFER, 0); // Remove the attachment from the outputs if it is a colour type if (isColourAttachment(point)) { this.outputBuffers.remove(point); }/*from w w w.ja v a 2 s . c o m*/ // Update the output buffers updateOutputBuffers(); // Check to see if the frame buffer is complete if (GL30.glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { throw new IllegalStateException("Unable to complete frame buffer!"); } // Unbind the frame buffer GL30.glBindFramebuffer(GL_FRAMEBUFFER, 0); // Check for errors RenderUtil.checkGLError(); }
From source file:net.smert.frameworkgl.opengl.helpers.FrameBufferObjectHelper.java
License:Apache License
public int checkStatus() { return GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); }
From source file:org.spout.engine.filesystem.resource.ClientRenderTexture.java
License:Open Source License
@Override public void writeGPU() { if (framebuffer != INVALID_BUFFER) { throw new IllegalStateException("Framebuffer already created!"); }//from www.jav a 2 s. com int buffers = 1; //Create the color buffer for this renderTexture textureID = GL11.glGenTextures(); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_INT, (ByteBuffer) null); // Create the texture data SpoutRenderer.checkGLError(); if (useNormalBuffer) { //Create the color buffer for this renderTexture normalTarget = GL11.glGenTextures(); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalTarget); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); // Create the texture data SpoutRenderer.checkGLError(); buffers++; } if (useDepthBuffer) { //Create the color buffer for this renderTexture depthTarget = GL11.glGenTextures(); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTarget); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); SpoutRenderer.checkGLError(); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null); // Create the texture data SpoutRenderer.checkGLError(); buffers++; } if (useEXT) { framebuffer = EXTFramebufferObject.glGenFramebuffersEXT(); SpoutRenderer.checkGLError(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); SpoutRenderer.checkGLError(); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, textureID, 0); SpoutRenderer.checkGLError(); if (useDepthBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTarget); SpoutRenderer.checkGLError(); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, depthTarget, 0); SpoutRenderer.checkGLError(); } if (useNormalBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalTarget); SpoutRenderer.checkGLError(); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT, GL11.GL_TEXTURE_2D, normalTarget, 0); SpoutRenderer.checkGLError(); } if (EXTFramebufferObject.glCheckFramebufferStatusEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT) != EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT) { System.out.println("ERROR: Framebuffer not complete"); throw new ComputerIsPotatoException("Framebuffer not complete"); } SpoutRenderer.checkGLError(); } else { framebuffer = GL30.glGenFramebuffers(); SpoutRenderer.checkGLError(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); SpoutRenderer.checkGLError(); IntBuffer drawBuffers = BufferUtils.createIntBuffer(buffers); drawBuffers.put(GL30.GL_COLOR_ATTACHMENT0); if (useNormalBuffer) { drawBuffers.put(GL30.GL_COLOR_ATTACHMENT1); } drawBuffers.flip(); GL20.glDrawBuffers(drawBuffers); SpoutRenderer.checkGLError(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); SpoutRenderer.checkGLError(); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, textureID, 0); SpoutRenderer.checkGLError(); if (useDepthBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthTarget); SpoutRenderer.checkGLError(); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthTarget, 0); SpoutRenderer.checkGLError(); } if (useNormalBuffer) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, normalTarget); SpoutRenderer.checkGLError(); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT1, GL11.GL_TEXTURE_2D, normalTarget, 0); SpoutRenderer.checkGLError(); } int status = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); if (status != GL30.GL_FRAMEBUFFER_COMPLETE) { System.out.println("ERROR: Framebuffer not complete. Status: " + status); throw new ComputerIsPotatoException("Framebuffer not complete"); } SpoutRenderer.checkGLError(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER); SpoutRenderer.checkGLError(); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); SpoutRenderer.checkGLError(); }
From source file:org.spout.engine.resources.ClientRenderTexture.java
License:Open Source License
@Override public void writeGPU() { if (framebuffer != INVALID_BUFFER) throw new IllegalStateException("Framebuffer already created!"); //Create the color buffer for this renderTexture textureID = GL11.glGenTextures();//from w ww .j av a 2 s . co m GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_INT, (java.nio.ByteBuffer) null); // Create the texture data if (useEXT) { framebuffer = EXTFramebufferObject.glGenFramebuffersEXT(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, framebuffer); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, textureID, 0); if (useDepthBuffer) { depthTarget = GL30.glGenRenderbuffers(); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthTarget); EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL11.GL_DEPTH_COMPONENT, this.getWidth(), this.getHeight()); EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, GL30.GL_DEPTH_ATTACHMENT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, depthTarget); } if (EXTFramebufferObject.glCheckFramebufferStatusEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT) != EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT) { System.out.println("ERROR: Framebuffer not complete"); throw new ComputerIsPotatoException("Framebuffer not complete"); } } else { framebuffer = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, textureID, 0); if (useDepthBuffer) { depthTarget = GL30.glGenRenderbuffers(); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthTarget); GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, this.getWidth(), this.getHeight()); GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthTarget); } GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, SCREEN_BUFFER); if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE) { System.out.println("ERROR: Framebuffer not complete"); throw new ComputerIsPotatoException("Framebuffer not complete"); } } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); }
From source file:org.terasology.rendering.opengl.LwjglFrameBufferObject.java
License:Apache License
public LwjglFrameBufferObject(AssetUri uri, Vector2i size) { this.size = size; IntBuffer fboId = BufferUtils.createIntBuffer(1); GL30.glGenFramebuffers(fboId);/* w ww . ja va 2 s . c o m*/ frame = fboId.get(0); Texture texture = generateTexture(uri); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frame); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture.getId(), 0); int result = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); if (result != GL30.GL_FRAMEBUFFER_COMPLETE) { throw new IllegalStateException("Something went wrong with framebuffer! " + result); } GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); }
From source file:processing.lwjgl.PGL.java
License:Open Source License
public int checkFramebufferStatus(int target) { return GL30.glCheckFramebufferStatus(target); }
From source file:processing.opengl.PLWJGL.java
License:Open Source License
@Override public int checkFramebufferStatus(int target) { return GL30.glCheckFramebufferStatus(target); }
From source file:se.angergard.engine.graphics.FrameBuffer.java
License:Apache License
public FrameBuffer(int width, int height, boolean hasDepth, boolean hasStencil) { this.width = width; this.height = height; if ((width + height) % 4 != 0.0) { new Exception("Width + Height must be divisible by 4"); }/* www. j ava2s . c o m*/ frameBufferID = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, frameBufferID); if (hasDepth && hasStencil) { depthAndStencilBufferID = GL30.glGenRenderbuffers(); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthAndStencilBufferID); GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_DEPTH24_STENCIL8, width, height); GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_STENCIL_ATTACHMENT, GL30.GL_RENDERBUFFER, depthAndStencilBufferID); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0); } else if (hasDepth) { depthBufferID = GL30.glGenRenderbuffers(); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthBufferID); GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_DEPTH_COMPONENT32F, width, height); GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthBufferID); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0); } else if (hasStencil) { stencilBufferID = GL30.glGenRenderbuffers(); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, stencilBufferID); GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL30.GL_STENCIL_INDEX16, width, height); GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_STENCIL_ATTACHMENT, GL30.GL_RENDERBUFFER, stencilBufferID); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, 0); } colorTexture = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, colorTexture); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, colorTexture, 0); int result = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); if (result != GL30.GL_FRAMEBUFFER_COMPLETE) { if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT) { new Exception("Frame Buffer Error: incomplete attachment").printStackTrace(); } if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER) { new Exception("Frame Buffer Error: incomplete draw buffer").printStackTrace(); } if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT) { new Exception("Frame Buffer Error: missing attachment").printStackTrace(); } if (result == GL30.GL_FRAMEBUFFER_UNSUPPORTED) { new Exception("Frame Buffer Error: unsupported combination of formats").printStackTrace(); } if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE) { new Exception("Frame Buffer Error: incomplete multisample").printStackTrace(); } if (result == GL30.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER) { new Exception("Frame Buffer Error: incomplete read buffer").printStackTrace(); } new Exception("frame buffer couldn't be constructed: unknown error " + result).printStackTrace(); } RenderUtil.unbindFrameBuffer(); RenderUtil.unbindTexture(); frameBufferShader = new ShaderProgram().createDefault2DShader(); }