List of usage examples for org.lwjgl.opengl GL30 glGenFramebuffers
@NativeType("void") public static int glGenFramebuffers()
From source file:com.adavr.player.globjects.Framebuffer.java
License:Open Source License
public static Framebuffer create(int target) { int id = GL30.glGenFramebuffers(); return new Framebuffer(id, target); }
From source file:com.badlogic.gdx.backends.jglfw.JglfwGL30.java
License:Apache License
@Override public int glGenFramebuffer() { return GL30.glGenFramebuffers(); }
From source file:com.flowpowered.caustic.lwjgl.gl30.GL30FrameBuffer.java
License:MIT License
@Override public void create() { checkNotCreated();// w w w .j ava2s. c o m // Generate and bind the frame buffer id = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, id); // Disable input buffers GL11.glReadBuffer(GL11.GL_NONE); // Unbind the frame buffer GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); // Update the state super.create(); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.mtbs3d.minecrift.FBOParams.java
License:LGPL
public FBOParams(String fboName, int textureType, int internalFormat, int baseFormat, int bufferType, int fboWidth, int fboHeight) throws Exception { Minecraft mc = Minecraft.getMinecraft(); _textureType = textureType;// w w w . ja va 2 s .c om if (fboSupport == FBO_SUPPORT.USE_EXT_UNKNOWN) { // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer. try { _frameBufferId = GL30.glGenFramebuffers(); fboSupport = FBO_SUPPORT.USE_GL30; } catch (IllegalStateException ex) { System.out.println( "[Minecrift] FBO creation: GL30.glGenFramebuffers not supported. Attempting to use EXTFramebufferObject.glGenFramebuffersEXT"); fboSupport = FBO_SUPPORT.USE_EXT; try { _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT(); } catch (IllegalStateException ex1) { System.out.println( "[Minecrift] FBO creation: EXTFramebufferObject.glGenFramebuffersEXT not supported, FBO creation failed."); throw ex1; } } } else if (fboSupport == FBO_SUPPORT.USE_GL30) { _frameBufferId = GL30.glGenFramebuffers(); } else { _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT(); } if (fboSupport == FBO_SUPPORT.USE_GL30) { _colorTextureId = GL11.glGenTextures(); _depthRenderBufferId = GL30.glGenRenderbuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, _frameBufferId); checkGLError("FBO bind framebuffer"); GL11.glBindTexture(textureType, _colorTextureId); checkGLError("FBO bind texture"); GL11.glEnable(textureType); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType, (java.nio.ByteBuffer) null); System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, textureType, _colorTextureId, 0); checkGLError("FBO bind texture framebuffer"); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, _depthRenderBufferId); // bind the depth renderbuffer GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, _depthRenderBufferId); checkGLError("FBO bind depth framebuffer"); } else { _colorTextureId = GL11.glGenTextures(); _depthRenderBufferId = EXTFramebufferObject.glGenRenderbuffersEXT(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _frameBufferId); checkGLError("FBO bind framebuffer"); GL11.glBindTexture(textureType, _colorTextureId); checkGLError("FBO bind texture"); GL11.glEnable(textureType); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType, (java.nio.ByteBuffer) null); System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, textureType, _colorTextureId, 0); checkGLError("FBO bind texture framebuffer"); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRenderBufferId); // bind the depth renderbuffer EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRenderBufferId); checkGLError("FBO bind depth framebuffer"); } if (!checkFramebufferStatus()) { // OK, if we have an error here - then throw an exception System.out.println("[Minecrift] FAILED to create framebuffer!!"); throw new Exception("Failed to create framebuffer"); } }
From source file:com.mtbs3d.minecrift.render.FBOParams.java
License:LGPL
public FBOParams(String fboName, int textureType, int internalFormat, int baseFormat, int bufferType, int fboWidth, int fboHeight) throws Exception { Minecraft mc = Minecraft.getMinecraft(); _textureType = textureType;// w ww .j a v a 2s . c om if (fboSupport == FBO_SUPPORT.USE_EXT_UNKNOWN) { // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer. try { _frameBufferId = GL30.glGenFramebuffers(); fboSupport = FBO_SUPPORT.USE_GL30; } catch (IllegalStateException ex) { System.out.println( "[Minecrift] FBO creation: GL30.glGenFramebuffers not supported. Attempting to use EXTFramebufferObject.glGenFramebuffersEXT"); fboSupport = FBO_SUPPORT.USE_EXT; try { _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT(); } catch (IllegalStateException ex1) { System.out.println( "[Minecrift] FBO creation: EXTFramebufferObject.glGenFramebuffersEXT not supported, FBO creation failed."); throw ex1; } } } else if (fboSupport == FBO_SUPPORT.USE_GL30) { _frameBufferId = GL30.glGenFramebuffers(); } else { _frameBufferId = EXTFramebufferObject.glGenFramebuffersEXT(); } if (fboSupport == FBO_SUPPORT.USE_GL30) { _colorTextureId = GL11.glGenTextures(); _depthRenderBufferId = GL30.glGenRenderbuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, _frameBufferId); mc.checkGLError("FBO bind framebuffer"); GL11.glBindTexture(textureType, _colorTextureId); mc.checkGLError("FBO bind texture"); GL11.glEnable(textureType); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType, (java.nio.ByteBuffer) null); //System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight); GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, textureType, _colorTextureId, 0); mc.checkGLError("FBO bind texture framebuffer"); GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, _depthRenderBufferId); // bind the depth renderbuffer GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, _depthRenderBufferId); mc.checkGLError("FBO bind depth framebuffer"); } else { _colorTextureId = GL11.glGenTextures(); _depthRenderBufferId = EXTFramebufferObject.glGenRenderbuffersEXT(); EXTFramebufferObject.glBindFramebufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, _frameBufferId); mc.checkGLError("FBO bind framebuffer"); GL11.glBindTexture(textureType, _colorTextureId); mc.checkGLError("FBO bind texture"); GL11.glEnable(textureType); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameterf(textureType, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(textureType, 0, internalFormat, fboWidth, fboHeight, 0, baseFormat, bufferType, (java.nio.ByteBuffer) null); //System.out.println("[Minecrift] FBO '" + fboName + "': w: " + fboWidth + ", h: " + fboHeight); EXTFramebufferObject.glFramebufferTexture2DEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, textureType, _colorTextureId, 0); mc.checkGLError("FBO bind texture framebuffer"); EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRenderBufferId); // bind the depth renderbuffer EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, fboWidth, fboHeight); // get the data space for it EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, _depthRenderBufferId); mc.checkGLError("FBO bind depth framebuffer"); } if (!checkFramebufferStatus()) { // OK, if we have an error here - then throw an exception System.out.println("[Minecrift] FAILED to create framebuffer!!"); throw new Exception("Failed to create framebuffer"); } }
From source file:com.opengrave.og.light.Depth2DFramebuffer.java
License:Open Source License
public Depth2DFramebuffer(int size) { framebufferSize = size;//from w ww. j ava 2s . c o m framebuffer = GL30.glGenFramebuffers(); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); shadowMap = new Texture2DShadowMap(framebufferSize); shadowMap.bindToFrameBuffer(); // GL11.glDrawBuffer(GL30.GL_COLOR_ATTACHMENT0); GL11.glDrawBuffer(GL11.GL_NONE); Util.checkErr(); GL11.glReadBuffer(GL11.GL_NONE); int i = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); if (i != GL30.GL_FRAMEBUFFER_COMPLETE) { throw new RuntimeException("Framebuffer creation failed with code: " + i); } GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); // TESTING STUFF count = 2; FloatBuffer pos = BufferUtils.createFloatBuffer(3 * 3 * count); FloatBuffer tex = BufferUtils.createFloatBuffer(2 * 3 * count); pos.put(0.75f).put(0.75f).put(0f); pos.put(0.75f).put(0.25f).put(0f); pos.put(0.25f).put(0.75f).put(0f); pos.put(0.25f).put(0.25f).put(0f); pos.put(0.75f).put(0.25f).put(0f); pos.put(0.25f).put(0.75f).put(0f); pos.flip(); tex.put(1f).put(1f); tex.put(1f).put(0f); tex.put(0f).put(1f); tex.put(0f).put(0f); tex.put(1f).put(0f); tex.put(0f).put(1f); tex.flip(); vao_ID = GL30.glGenVertexArrays(); GL30.glBindVertexArray(vao_ID); int vbo_pos_ID = GL15.glGenBuffers(); int vbo_tex_ID = GL15.glGenBuffers(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_pos_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, pos, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo_tex_ID); GL15.glBufferData(GL15.GL_ARRAY_BUFFER, tex, GL15.GL_STATIC_DRAW); GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 0, 0); }
From source file:com.opengrave.og.light.DepthCubeFramebuffer.java
License:Open Source License
public DepthCubeFramebuffer(int size) { framebufferSize = size;/* w w w.ja va2 s .c o m*/ framebuffer = GL30.glGenFramebuffers(); // System.out.println("Creating Pointlight Framebuffer : " + // framebuffer); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer); shadowMap = new TextureCubeShadowMap(framebufferSize); // shadowMap.bindToFrameBuffer(); shadowMap.bindToFrameBuffer(0); // GL11.glDrawBuffer(GL30.GL_COLOR_ATTACHMENT0); GL11.glDrawBuffer(GL11.GL_NONE); Util.checkErr(); GL11.glReadBuffer(GL11.GL_NONE); int i = GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER); if (i != GL30.GL_FRAMEBUFFER_COMPLETE) { throw new RuntimeException("Framebuffer creation failed with code: " + i); } GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); Util.checkErr(); }
From source file:com.samrj.devil.gl.FBO.java
License:Open Source License
FBO() { DGL.checkState();/*www . j a v a 2 s .c o m*/ if (!DGL.getCapabilities().OpenGL30) throw new UnsupportedOperationException("Frame buffers unsupported in OpenGL < 3.0"); id = GL30.glGenFramebuffers(); }
From source file:com.xrbpowered.gl.res.buffers.MultisampleBuffers.java
License:Open Source License
public MultisampleBuffers(int w, int h, int samples, boolean hdr) { super(GL30.glGenFramebuffers(), w, h); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo); create(w, h, samples, true, hdr);/*from ww w . j a va2 s . co m*/ resolve = new OffscreenBuffers(w, h, false, hdr); }
From source file:com.xrbpowered.gl.res.buffers.OffscreenBuffers.java
License:Open Source License
public OffscreenBuffers(int w, int h, boolean depthBuffer, boolean depthTexture) { super(GL30.glGenFramebuffers(), w, h); GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fbo); create(w, h, depthBuffer, depthTexture); }