List of usage examples for org.lwjgl.opengl GL20 glDrawBuffers
public static void glDrawBuffers(@NativeType("GLenum const *") int[] bufs)
From source file:org.terasology.logic.manager.DefaultRenderingProcess.java
License:Apache License
public FBO createFBO(String title, int width, int height, FBOType type, boolean depth, boolean normals) { // Make sure to delete the existing FBO before creating a new one deleteFBO(title);// w ww. java 2s . co m // Create a new FBO object FBO fbo = new FBO(); fbo.width = width; fbo.height = height; // Create the color target texture fbo.textureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.textureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (type != FBOType.NO_COLOR) { if (type == FBOType.HDR) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, ARBTextureFloat.GL_RGBA16F_ARB, width, height, 0, GL11.GL_RGBA, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (java.nio.ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); } } if (depth) { // Generate the depth texture fbo.depthTextureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.depthTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT24, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (java.nio.ByteBuffer) null); // Create depth render buffer object fbo.depthRboId = EXTFramebufferObject.glGenRenderbuffersEXT(); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, fbo.depthRboId); EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, width, height); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, 0); } if (normals) { // Generate the normals texture fbo.normalsTextureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.normalsTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); // Create the FBO fbo.fboId = EXTFramebufferObject.glGenFramebuffersEXT(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.fboId); if (type != FBOType.NO_COLOR) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, fbo.textureId, 0); } if (depth) { // Generate the depth render buffer and depth map texture EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, fbo.depthRboId); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, fbo.depthTextureId, 0); } if (normals) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT, GL11.GL_TEXTURE_2D, fbo.normalsTextureId, 0); } IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (type != FBOType.NO_COLOR) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT); } if (normals) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT); } bufferIds.flip(); GL20.glDrawBuffers(bufferIds); int checkFB = EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT); switch (checkFB) { case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT: break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: logger.error("FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception"); /* * On some graphics cards, FBOType.NO_COLOR can cause a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT. * Attempt to continue without this FBO. */ if (type == FBOType.NO_COLOR) { logger.error("FrameBuffer: " + title + ", ...but the FBOType was NO_COLOR, ignoring this error and continuing without this FBO."); taint("Got a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT because of FBOType.NO_COLOR."); return null; } default: throw new RuntimeException("Unexpected reply from glCheckFramebufferStatusEXT: " + checkFB); } EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); _FBOs.put(title, fbo); return fbo; }
From source file:org.terasology.logic.manager.PostProcessingRenderer.java
License:Apache License
public FBO createFBO(String title, int width, int height, boolean hdr, boolean depth, boolean normals) { // Make sure to delete the existing FBO before creating a new one deleteFBO(title);/*from www . ja v a 2 s. c om*/ // Create a new FBO object FBO fbo = new FBO(); fbo._width = width; fbo._height = height; // Create the color target texture fbo._textureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo._textureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (hdr) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, ARBTextureFloat.GL_RGBA16F_ARB, width, height, 0, GL11.GL_RGBA, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (java.nio.ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); } if (depth) { // Generate the depth texture fbo._depthTextureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo._depthTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT24, width, height, 0, GL11.GL_DEPTH_COMPONENT, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (java.nio.ByteBuffer) null); // Create depth render buffer object fbo._depthRboId = EXTFramebufferObject.glGenRenderbuffersEXT(); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, fbo._depthRboId); EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT16, width, height); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, 0); } if (normals) { // Generate the normals texture fbo._normalsTextureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo._normalsTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); // Create the FBO fbo._fboId = EXTFramebufferObject.glGenFramebuffersEXT(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo._fboId); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, fbo._textureId, 0); if (depth) { // Generate the depth render buffer and depth map texture EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, fbo._depthRboId); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, fbo._depthTextureId, 0); } if (normals) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT, GL11.GL_TEXTURE_2D, fbo._normalsTextureId, 0); } IntBuffer bufferIds = BufferUtils.createIntBuffer(3); bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT); if (normals) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT); } bufferIds.flip(); GL20.glDrawBuffers(bufferIds); int framebuffer = EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT); switch (framebuffer) { case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT: break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: logger.error("FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception"); case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception"); default: throw new RuntimeException("Unexpected reply from glCheckFramebufferStatusEXT: " + framebuffer); } EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); _FBOs.put(title, fbo); return fbo; }
From source file:org.terasology.rendering.opengl.DefaultRenderingProcess.java
License:Apache License
public FBO createFBO(String title, int width, int height, FBOType type, boolean depthBuffer, boolean normalBuffer, boolean lightBuffer, boolean stencilBuffer) { // Make sure to delete the existing FBO before creating a new one deleteFBO(title);//from w ww.j a va 2s . c o m // Create a new FBO object FBO fbo = new FBO(); fbo.width = width; fbo.height = height; // Create the FBO fbo.fboId = glGenFramebuffersEXT(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo.fboId); if (type != FBOType.NO_COLOR) { fbo.textureId = glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.textureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (type == FBOType.HDR) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); } glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, fbo.textureId, 0); } if (normalBuffer) { fbo.normalsTextureId = glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.normalsTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL11.GL_TEXTURE_2D, fbo.normalsTextureId, 0); } if (lightBuffer) { fbo.lightBufferTextureId = glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.lightBufferTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (type == FBOType.HDR) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, ARBTextureFloat.GL_RGBA16F_ARB, width, height, 0, GL11.GL_RGBA, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); } glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT, GL11.GL_TEXTURE_2D, fbo.lightBufferTextureId, 0); } if (depthBuffer) { fbo.depthStencilTextureId = glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.depthStencilTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (!stencilBuffer) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT24, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_UNSIGNED_INT, (ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, width, height, 0, EXTPackedDepthStencil.GL_DEPTH_STENCIL_EXT, EXTPackedDepthStencil.GL_UNSIGNED_INT_24_8_EXT, (ByteBuffer) null); } fbo.depthStencilRboId = glGenRenderbuffersEXT(); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo.depthStencilRboId); if (!stencilBuffer) { glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, width, height); } else { glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, width, height); } glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo.depthStencilRboId); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, fbo.depthStencilTextureId, 0); if (stencilBuffer) { glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, fbo.depthStencilTextureId, 0); } } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (type != FBOType.NO_COLOR) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT); } if (normalBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT1_EXT); } if (lightBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT2_EXT); } bufferIds.flip(); if (bufferIds.limit() == 0) { GL11.glReadBuffer(GL11.GL_NONE); GL20.glDrawBuffers(GL11.GL_NONE); } else { GL20.glDrawBuffers(bufferIds); } int checkFB = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); switch (checkFB) { case GL_FRAMEBUFFER_COMPLETE_EXT: break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception"); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: logger.error("FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception"); break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception"); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception"); break; case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception"); break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: logger.error("FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_UNSUPPORTED_EXT exception"); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception"); /* * On some graphics cards, FBOType.NO_COLOR can cause a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT. * Attempt to continue without this FBO. */ if (type == FBOType.NO_COLOR) { logger.error("FrameBuffer: " + title + ", ...but the FBOType was NO_COLOR, ignoring this error and continuing without this FBO."); return null; } break; default: logger.error("Unexpected reply from glCheckFramebufferStatusEXT: " + checkFB); break; } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); fboLookup.put(title, fbo); return fbo; }
From source file:org.terasology.rendering.opengl.DefaultRenderingProcess.java
License:Apache License
public void setRenderBufferMask(FBO fbo, boolean color, boolean normal, boolean lightBuffer) { if (fbo == null) { return;/*ww w . j a v a2s. c o m*/ } int attachmentId = 0; IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (fbo.textureId != 0) { if (color) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.normalsTextureId != 0) { if (normal) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.lightBufferTextureId != 0) { if (lightBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } bufferIds.flip(); GL20.glDrawBuffers(bufferIds); }
From source file:org.terasology.rendering.opengl.FBO.java
License:Apache License
/** * Once an FBO is bound, opengl commands will act on it, i.e. by drawing on it. * Meanwhile shaders might output not just colors but additional per-pixel data. This method establishes on which * of an FBOs attachments, subsequent opengl commands and shaders will draw on. * * @param renderToColorBuffer If True the color buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. * @param renderToNormalsBuffer If True the normal buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. * @param renderToLightBuffer If True the light buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. *///ww w . ja v a 2 s. c om public void setRenderBufferMask(boolean renderToColorBuffer, boolean renderToNormalsBuffer, boolean renderToLightBuffer) { if (this.writeToColorBuffer == renderToColorBuffer && this.writeToNormalsBuffer == renderToNormalsBuffer && this.writeToLightBuffer == renderToLightBuffer) { return; } this.writeToColorBuffer = renderToColorBuffer; this.writeToNormalsBuffer = renderToNormalsBuffer; this.writeToLightBuffer = renderToLightBuffer; int attachmentId = 0; IntBuffer bufferIds = BufferUtils.createIntBuffer(3); // TODO: change GL_COLOR_ATTACHMENT0_EXT + attachmentId into something like COLOR_BUFFER_ATTACHMENT, // TODO: in turn set within the class or method if (colorBufferTextureId != 0) { if (this.writeToColorBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (normalsBufferTextureId != 0) { if (this.writeToNormalsBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (lightBufferTextureId != 0 && this.writeToLightBuffer) { // compacted if block because Jenkins was complaining about it. bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } bufferIds.flip(); GL20.glDrawBuffers(bufferIds); }
From source file:org.terasology.rendering.opengl.FBO.java
License:Apache License
/** * Creates an FBO, allocating the underlying FrameBuffer and the desired attachments on the GPU. * * Also checks the resulting FBO for completeness and logs errors and their error codes as necessary. * Callers must check the returned FBO's status (see getStatus()). Only FBO with a Status.COMPLETE should be used. * * In what follows, the GL constants between parenthesis represent the (internal format, data type, filtering type) of a buffer. * * An FBO of Type.DEFAULT will have a 32 bit color buffer attached to it. (GL_RGBA, GL11.GL_UNSIGNED_BYTE, GL_LINEAR) * An FBO of Type.HDR will have a 64 bit color buffer attached to it. (GL_RGBA, GL_HALF_FLOAT_ARB, GL_LINEAR) * An FBO of Type.NO_COLOR will have -no- color buffer attached to it. * * If the creation process is successful (Status.COMPLETE) GPU memory has been allocated for the FrameBuffer and * its attachments. However, the content of the attachments is undefined. * * @param urn An identification string. It is currently used only to log creation errors and is not stored in the FBO. * @param dimensions A Dimensions object wrapping width and height of the FBO. * @param type Can be Type.DEFAULT, Type.HDR or Type.NO_COLOR * @param useDepthBuffer If true the FBO will have a 24 bit depth buffer attached to it. (GL_DEPTH_COMPONENT24, GL_UNSIGNED_INT, GL_NEAREST) * @param useNormalBuffer If true the FBO will have a 32 bit normals buffer attached to it. (GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR) * @param useLightBuffer If true the FBO will have 32/64 bit light buffer attached to it, depending if Type is DEFAULT/HDR. * (GL_RGBA/GL_RGBA16F_ARB, GL_UNSIGNED_BYTE/GL_HALF_FLOAT_ARB, GL_LINEAR) * @param useStencilBuffer If true the depth buffer will also have an 8 bit Stencil buffer associated with it. * (GL_DEPTH24_STENCIL8_EXT, GL_UNSIGNED_INT_24_8_EXT, GL_NEAREST) * @return The resuting FBO object wrapping a FrameBuffer and its attachments. Use getStatus() before use to verify completeness. */// w w w . j ava 2 s . co m public static FBO create(ResourceUrn urn, Dimensions dimensions, Type type, boolean useDepthBuffer, boolean useNormalBuffer, boolean useLightBuffer, boolean useStencilBuffer) { FBO fbo = new FBO(dimensions.width, dimensions.height); // Create the FBO on the GPU fbo.fboId = glGenFramebuffersEXT(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo.fboId); if (type != Type.NO_COLOR) { createColorBuffer(fbo, dimensions, type); } if (useNormalBuffer) { createNormalsBuffer(fbo, dimensions); } if (useLightBuffer) { createLightBuffer(fbo, dimensions, type); } if (useDepthBuffer) { createDepthBuffer(fbo, dimensions, useStencilBuffer); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (type != Type.NO_COLOR) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT); } if (useNormalBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT1_EXT); } if (useLightBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT2_EXT); } bufferIds.flip(); if (bufferIds.limit() == 0) { GL11.glReadBuffer(GL11.GL_NONE); GL20.glDrawBuffers(GL11.GL_NONE); } else { GL20.glDrawBuffers(bufferIds); } verifyCompleteness(urn, type, fbo); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); return fbo; }
From source file:org.terasology.rendering.opengl.GraphicState.java
License:Apache License
/** * Once an FBO is bound, opengl commands will act on it, i.e. by drawing on it. * Meanwhile shaders might output not just colors but additional per-pixel data. This method establishes on which * of an FBOs attachments, subsequent opengl commands and shaders will draw on. * * @param fbo The FBO holding the attachments to be set or unset for drawing. * @param color If True the color buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. * @param normal If True the normal buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. * @param lightBuffer If True the light buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. *//* w w w . j a va2 s . c om*/ // TODO: verify if this can become part of the FBO.bind() method. public void setRenderBufferMask(FBO fbo, boolean color, boolean normal, boolean lightBuffer) { if (fbo == null) { return; } int attachmentId = 0; IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (fbo.colorBufferTextureId != 0) { if (color) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.normalsBufferTextureId != 0) { if (normal) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.lightBufferTextureId != 0) { if (lightBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } } bufferIds.flip(); GL20.glDrawBuffers(bufferIds); }
From source file:org.terasology.rendering.opengl.OpenGLUtils.java
License:Apache License
/** * Once an FBO is bound, opengl commands will act on it, i.e. by drawing on it. * Meanwhile shaders might output not just colors but additional per-pixel data. This method establishes on which * of an FBOs attachments, subsequent opengl commands and shaders will draw on. * * @param fbo The FBO holding the attachments to be set or unset for drawing. * @param color If True the color buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. * @param normal If True the normal buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. * @param lightBuffer If True the light buffer is set as drawable. If false subsequent commands and shaders won't be able to draw on it. *//*from w ww . ja v a 2 s . com*/ // TODO: verify if this can become part of the FBO.bind() method. public static void setRenderBufferMask(FBO fbo, boolean color, boolean normal, boolean lightBuffer) { if (fbo == null) { return; } int attachmentId = 0; IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (fbo.colorBufferTextureId != 0) { if (color) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.normalsBufferTextureId != 0) { if (normal) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.lightBufferTextureId != 0 && lightBuffer) { bufferIds.put(GL_COLOR_ATTACHMENT0_EXT + attachmentId); } bufferIds.flip(); GL20.glDrawBuffers(bufferIds); }
From source file:org.terasology.rendering.renderingProcesses.DefaultRenderingProcess.java
License:Apache License
public FBO createFBO(String title, int width, int height, FBOType type, boolean depthBuffer, boolean normalBuffer, boolean lightBuffer, boolean stencilBuffer) { // Make sure to delete the existing FBO before creating a new one deleteFBO(title);//from w ww. j a va 2 s . c o m // Create a new FBO object FBO fbo = new FBO(); fbo.width = width; fbo.height = height; // Create the FBO fbo.fboId = EXTFramebufferObject.glGenFramebuffersEXT(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, fbo.fboId); if (type != FBOType.NO_COLOR) { fbo.textureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.textureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (type == FBOType.HDR) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, ARBTextureFloat.GL_RGBA16F_ARB, width, height, 0, GL11.GL_RGBA, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (java.nio.ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); } EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, fbo.textureId, 0); } if (normalBuffer) { fbo.normalsTextureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.normalsTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT, GL11.GL_TEXTURE_2D, fbo.normalsTextureId, 0); } if (lightBuffer) { fbo.lightBufferTextureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.lightBufferTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (type == FBOType.HDR) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, ARBTextureFloat.GL_RGBA16F_ARB, width, height, 0, GL11.GL_RGBA, ARBHalfFloatPixel.GL_HALF_FLOAT_ARB, (java.nio.ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer) null); } EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT2_EXT, GL11.GL_TEXTURE_2D, fbo.lightBufferTextureId, 0); } if (depthBuffer) { fbo.depthStencilTextureId = GL11.glGenTextures(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, fbo.depthStencilTextureId); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); if (!stencilBuffer) { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL14.GL_DEPTH_COMPONENT24, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_UNSIGNED_INT, (java.nio.ByteBuffer) null); } else { GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, width, height, 0, EXTPackedDepthStencil.GL_DEPTH_STENCIL_EXT, EXTPackedDepthStencil.GL_UNSIGNED_INT_24_8_EXT, (java.nio.ByteBuffer) null); } fbo.depthStencilRboId = EXTFramebufferObject.glGenRenderbuffersEXT(); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, fbo.depthStencilRboId); if (!stencilBuffer) { EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, width, height); } else { EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, EXTPackedDepthStencil.GL_DEPTH24_STENCIL8_EXT, width, height); } EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, 0); EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, fbo.depthStencilRboId); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, fbo.depthStencilTextureId, 0); if (stencilBuffer) { EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, GL11.GL_TEXTURE_2D, fbo.depthStencilTextureId, 0); } } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (type != FBOType.NO_COLOR) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT); } if (normalBuffer) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT1_EXT); } if (lightBuffer) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT2_EXT); } bufferIds.flip(); if (bufferIds.limit() == 0) { GL11.glReadBuffer(GL11.GL_NONE); GL20.glDrawBuffers(GL11.GL_NONE); } else { GL20.glDrawBuffers(bufferIds); } int checkFB = EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT); switch (checkFB) { case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT: break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT exception"); break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: logger.error("FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT exception"); break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT exception"); break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT exception"); break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT exception"); break; case EXTFramebufferObject.GL_FRAMEBUFFER_UNSUPPORTED_EXT: logger.error("FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_UNSUPPORTED_EXT exception"); break; case EXTFramebufferObject.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: logger.error( "FrameBuffer: " + title + ", has caused a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT exception"); /* * On some graphics cards, FBOType.NO_COLOR can cause a GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT. * Attempt to continue without this FBO. */ if (type == FBOType.NO_COLOR) { logger.error("FrameBuffer: " + title + ", ...but the FBOType was NO_COLOR, ignoring this error and continuing without this FBO."); return null; } break; default: logger.error("Unexpected reply from glCheckFramebufferStatusEXT: " + checkFB); break; } EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0); FBOs.put(title, fbo); return fbo; }
From source file:org.terasology.rendering.renderingProcesses.DefaultRenderingProcess.java
License:Apache License
public void setRenderBufferMask(FBO fbo, boolean color, boolean normal, boolean lightBuffer) { if (fbo == null) { return;//from w ww . ja v a 2s . co m } int attachmentId = 0; IntBuffer bufferIds = BufferUtils.createIntBuffer(3); if (fbo.textureId != 0) { if (color) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.normalsTextureId != 0) { if (normal) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } if (fbo.lightBufferTextureId != 0) { if (lightBuffer) { bufferIds.put(EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT + attachmentId); } attachmentId++; } bufferIds.flip(); GL20.glDrawBuffers(bufferIds); }