Java Code Examples for com.jogamp.opengl.GL3#glGenRenderbuffers()
The following examples show how to use
com.jogamp.opengl.GL3#glGenRenderbuffers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Gl_320_fbo_blit.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName); gl3.glGenRenderbuffers(1, colorRenderbufferName); gl3.glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbufferName.get(0)); gl3.glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER)); gl3.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbufferName.get(0)); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return checkError(gl3, "initFramebuffer"); }
Example 2
Source File: HitTester.java From constellation with Apache License 2.0 | 5 votes |
@Override public void init(final GLAutoDrawable drawable) { final GL3 gl = drawable.getGL().getGL3(); // Hit testing. // Create an FBO name and bind a new FBO. gl.glGenFramebuffers(1, hitTestFboName, 0); gl.glBindFramebuffer(GL3.GL_DRAW_FRAMEBUFFER, hitTestFboName[0]); // Create a depth buffer object and attach it. gl.glGenRenderbuffers(1, hitTestDepthBufferName, 0); gl.glBindRenderbuffer(GL3.GL_RENDERBUFFER, hitTestDepthBufferName[0]); gl.glRenderbufferStorage(GL3.GL_RENDERBUFFER, GL3.GL_DEPTH_COMPONENT32F, width, height); // Create an RBO and bind it. gl.glGenRenderbuffers(1, hitTestRboName, 0); gl.glBindRenderbuffer(GL3.GL_RENDERBUFFER, hitTestRboName[0]); // Allocate memory to back the RBO. // Using R32F gives us plenty of unique values (2**22 in the mantissa without // worrying about floating point stuff). gl.glRenderbufferStorage(GL3.GL_RENDERBUFFER, GL3.GL_R32F, width, height); // Attach the render buffers. gl.glFramebufferRenderbuffer(GL3.GL_DRAW_FRAMEBUFFER, GL3.GL_DEPTH_ATTACHMENT, GL3.GL_RENDERBUFFER, hitTestDepthBufferName[0]); gl.glFramebufferRenderbuffer(GL3.GL_DRAW_FRAMEBUFFER, GL3.GL_COLOR_ATTACHMENT0, GL3.GL_RENDERBUFFER, hitTestRboName[0]); GLTools.checkFramebufferStatus(gl, "ht-check"); parent.setHitTestFboName(hitTestFboName[0]); }
Example 3
Source File: Gl_330_fbo_multisample_explicit_nv.java From jogl-samples with MIT License | 5 votes |
private boolean initRenderbuffer(GL3 gl3) { gl3.glGenRenderbuffers(Renderbuffer.MAX, renderbufferName); gl3.glBindRenderbuffer(GL_RENDERBUFFER, renderbufferName.get(Renderbuffer.COLOR)); gl3.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl3.glBindRenderbuffer(GL_RENDERBUFFER, renderbufferName.get(Renderbuffer.DEPTH)); gl3.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT24, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl3.glBindRenderbuffer(GL_RENDERBUFFER, 0); return checkError(gl3, "initRenderbuffer"); }
Example 4
Source File: Gl_300_fbo_multisample.java From jogl-samples with MIT License | 5 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenRenderbuffers(1, colorRenderbufferName); gl3.glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbufferName.get(0)); // The second parameter is the number of samples. gl3.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 8, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER)); gl3.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbufferName.get(0)); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RESOLVE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE)); gl3.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureName.get(Texture.RESOLVE), 0); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return checkError(gl3, "initFramebuffer"); }
Example 5
Source File: Renderer.java From jaamsim with Apache License 2.0 | 4 votes |
/** * Create the resources for an OffscreenTarget */ private void populateOffscreenTarget(OffscreenTarget target) { int width = target.getWidth(); int height = target.getHeight(); sharedContext.makeCurrent(); GL3 gl = sharedContext.getGL().getGL3(); // Just to clean up the code below // This does not support opengl 3, so for now we don't support off screen rendering if (gl == null) { sharedContext.release(); return; } // Create a new frame buffer for this draw operation int[] temp = new int[2]; gl.glGenFramebuffers(2, temp, 0); int drawFBO = temp[0]; int blitFBO = temp[1]; gl.glGenTextures(2, temp, 0); int drawTex = temp[0]; int blitTex = temp[1]; gl.glGenRenderbuffers(1, temp, 0); int depthBuf = temp[0]; gl.glBindTexture(GL3.GL_TEXTURE_2D_MULTISAMPLE, drawTex); gl.glTexImage2DMultisample(GL3.GL_TEXTURE_2D_MULTISAMPLE, 4, GL2GL3.GL_RGBA8, width, height, true); gl.glBindRenderbuffer(GL2GL3.GL_RENDERBUFFER, depthBuf); gl.glRenderbufferStorageMultisample(GL2GL3.GL_RENDERBUFFER, 4, GL2GL3.GL_DEPTH_COMPONENT, width, height); gl.glBindFramebuffer(GL2GL3.GL_FRAMEBUFFER, drawFBO); gl.glFramebufferTexture2D(GL2GL3.GL_FRAMEBUFFER, GL2GL3.GL_COLOR_ATTACHMENT0, GL3.GL_TEXTURE_2D_MULTISAMPLE, drawTex, 0); gl.glFramebufferRenderbuffer(GL2GL3.GL_FRAMEBUFFER, GL2GL3.GL_DEPTH_ATTACHMENT, GL2GL3.GL_RENDERBUFFER, depthBuf); int fbStatus = gl.glCheckFramebufferStatus(GL2GL3.GL_FRAMEBUFFER); assert(fbStatus == GL2GL3.GL_FRAMEBUFFER_COMPLETE); gl.glBindTexture(GL2GL3.GL_TEXTURE_2D, blitTex); gl.glTexImage2D(GL2GL3.GL_TEXTURE_2D, 0, GL2GL3.GL_RGBA8, width, height, 0, GL2GL3.GL_RGBA, GL2GL3.GL_BYTE, null); gl.glBindFramebuffer(GL2GL3.GL_FRAMEBUFFER, blitFBO); gl.glFramebufferTexture2D(GL2GL3.GL_FRAMEBUFFER, GL2GL3.GL_COLOR_ATTACHMENT0, GL2GL3.GL_TEXTURE_2D, blitTex, 0); gl.glBindFramebuffer(GL2GL3.GL_FRAMEBUFFER, 0); target.load(drawFBO, drawTex, depthBuf, blitFBO, blitTex); sharedContext.release(); }