Java Code Examples for com.jogamp.opengl.GL3#glBindFramebuffer()
The following examples show how to use
com.jogamp.opengl.GL3#glBindFramebuffer() .
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_multisample.java From jogl-samples with MIT License | 6 votes |
private void renderFBO(GL3 gl3, int framebuffer) { Mat4 perspective = glm.perspective_((float) Math.PI * 0.25f, (float) FRAMEBUFFER_SIZE.x / FRAMEBUFFER_SIZE.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f).scale(new Vec3(1.0f)); Mat4 mvp = perspective.mul(viewMat4()).mul(model); gl3.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl3.glViewport(0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); gl3.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.5f, 1.0f, 1.0f}, 0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1); }
Example 2
Source File: Gl_320_fbo_shadow.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(1, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(0), 0); gl3.glDrawBuffer(GL_NONE); if (!isFramebufferComplete(gl3, framebufferName.get(0))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glDrawBuffer(GL_BACK); if (!isFramebufferComplete(gl3, 0)) { return false; } return true; }
Example 3
Source File: Gl_320_fbo_depth_multisample.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { boolean validated = true; gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.DEPTH_MULTISAMPLE)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.MULTISAMPLE), 0); gl3.glDrawBuffer(GL_NONE); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.DEPTH_MULTISAMPLE))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return validated && checkError(gl3, "initFramebuffer"); }
Example 4
Source File: Gl_320_fbo_multisample_explicit.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(1, framebufferRenderName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferRenderName.get(0)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.MULTISAMPLE_COLORBUFFER), 0); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.MULTISAMPLE_DEPTHBUFFER), 0); if (!isFramebufferComplete(gl3, framebufferRenderName.get(0))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; }
Example 5
Source File: Gl_330_blend_rtt.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(1, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); for (int i = Texture.R; i <= Texture.B; ++i) { gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + (i - Texture.R), texture2dName.get(i), 0); } int[] drawBuffers = new int[3]; drawBuffers[0] = GL_COLOR_ATTACHMENT0; drawBuffers[1] = GL_COLOR_ATTACHMENT1; drawBuffers[2] = GL_COLOR_ATTACHMENT2; gl3.glDrawBuffers(3, drawBuffers, 0); if (!isFramebufferComplete(gl3, framebufferName.get(0))) { return false; } return checkError(gl3, "initFramebuffer"); }
Example 6
Source File: Gl_320_fbo_srgb.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(1, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0); if (!isFramebufferComplete(gl3, framebufferName.get(0))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); int encodingLinear = GL_LINEAR; int encodingSRGB = GL_SRGB; int[] encoding = {0}; gl3.glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK_LEFT, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, encoding, 0); return true; }
Example 7
Source File: Gl_320_fbo_rtt.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(1, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(0), 0); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, textureName.get(1), 0); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, textureName.get(2), 0); int[] drawBuffers = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2}; gl3.glDrawBuffers(3, drawBuffers, 0); if (!isFramebufferComplete(gl3, framebufferName.get(0))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); //GL_ARB_ES3_1_compability //GLenum const Buffers = GL_BACK; //glDrawBuffers(1, &Buffers); gl3.glDrawBuffer(GL_BACK); if (!isFramebufferComplete(gl3, 0)) { return false; } return checkError(gl3, "initFramebuffer"); }
Example 8
Source File: Gl_320_buffer_uniform.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean begin(GL gl) { boolean validated = true; GL3 gl3 = (GL3) gl; if (validated) { validated = initProgram(gl3); } if (validated) { validated = initBuffer(gl3); } if (validated) { validated = initVertexArray(gl3); } gl3.glEnable(GL_DEPTH_TEST); gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glDrawBuffer(GL_BACK); if (!isFramebufferComplete(gl, 0)) { return false; } return validated; }
Example 9
Source File: Gl_320_fbo_integer_blit.java From jogl-samples with MIT License | 6 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.RENDERBUFFER), 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.SPLASHBUFFER), 0); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return checkError(gl3, "initFramebuffer"); }
Example 10
Source File: Gl_320_fbo_shadow.java From jogl-samples with MIT License | 6 votes |
private void renderFramebuffer(GL3 gl3) { gl3.glEnable(GL_DEPTH_TEST); gl3.glDepthFunc(GL_LESS); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glClearBufferfv(GL_DEPTH, 0, clearDepth); gl3.glClearBufferfv(GL_COLOR, 0, clearColor); gl3.glUseProgram(programName[Program.RENDER]); gl3.glUniform1i(uniformShadow, 0); gl3.glUniformBlockBinding(programName[Program.RENDER], uniformTransform[Program.RENDER], Semantic.Uniform.TRANSFORM0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(Program.RENDER)); gl3.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0); gl3.glDisable(GL_DEPTH_TEST); checkError(gl3, "renderFramebuffer"); }
Example 11
Source File: Gl_320_fbo_multisample_explicit.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; // Clear the framebuffer gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.5f, 1.0f, 1.0f}, 0); // Pass 1 // Render the scene in a multisampled framebuffer gl3.glEnable(GL_MULTISAMPLE); renderFBO(gl3, framebufferRenderName.get(0)); gl3.glDisable(GL_MULTISAMPLE); // Pass 2 // Resolved and render the colorbuffer from the multisampled framebuffer resolveMultisampling(gl3); return true; }
Example 12
Source File: GLRenderer.java From constellation with Apache License 2.0 | 5 votes |
@Override public void init(final GLAutoDrawable drawable) { initialised = true; renderables.sort(Comparator.naturalOrder()); if (debugGl) { drawable.setGL(new DebugGL3(drawable.getGL().getGL3())); } final GL3 gl = drawable.getGL().getGL3(); //Look for Graphics cards that work with GL3, but not 3.3. //Graphics cards that don't work with GL3 will raise an exception. final String thisversion = gl.glGetString(GL.GL_VERSION); if (!VersionUtilities.doesVersionMeetMinimum(thisversion, GLInfo.MINIMUM_OPEN_GL_VERSION)) { GLInfo.respondToIncompatibleHardwareOrGL(drawable); } if (printGlCapabilities) { GLInfo.printGLCapabilities(gl); } gl.glEnable(GL3.GL_DEPTH_TEST); gl.glDepthFunc(GL3.GL_LEQUAL); gl.glEnable(GL3.GL_BLEND); gl.glBlendFunc(GL3.GL_SRC_ALPHA, GL3.GL_ONE_MINUS_SRC_ALPHA); gl.glEnable(GL3.GL_LINE_SMOOTH); gl.glHint(GL3.GL_LINE_SMOOTH_HINT, GL3.GL_NICEST); renderables.forEach(renderable -> { renderable.init(drawable); }); // Reset to the default framebuffer. gl.glBindFramebuffer(GL3.GL_DRAW_FRAMEBUFFER, 0); }
Example 13
Source File: Gl_320_fbo_layered.java From jogl-samples with MIT License | 5 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(1, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureColorbufferName.get(0), 0); if (!isFramebufferComplete(gl3, framebufferName.get(0))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; }
Example 14
Source File: Gl_320_fbo_srgb_decode_ext.java From jogl-samples with MIT License | 5 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(1, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0); if (!isFramebufferComplete(gl3, framebufferName.get(0))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; }
Example 15
Source File: Gl_320_fbo_multisample.java From jogl-samples with MIT License | 5 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName); int[] buffersRender = new int[]{GL_COLOR_ATTACHMENT0}; gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.MULTISAMPLE), 0); gl3.glDrawBuffers(1, buffersRender, 0); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) { return false; } int[] buffersResolve = new int[]{GL_COLOR_ATTACHMENT0}; gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE)); gl3.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLORBUFFER), 0); gl3.glDrawBuffers(1, buffersResolve, 0); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glDrawBuffer(GL_BACK); if (!isFramebufferComplete(gl3, 0)) { return false; } return checkError(gl3, "initFramebuffer"); }
Example 16
Source File: Gl_330_fbo_multisample_explicit_nv.java From jogl-samples with MIT License | 5 votes |
private void renderFBO(GL3 gl3) { Mat4 perspective = glm.perspective_((float) Math.PI * 0.25f, (float) FRAMEBUFFER_SIZE.x / FRAMEBUFFER_SIZE.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f).scale(new Vec3(1, -1, 1)); Mat4 mvp = perspective.mul(viewMat4()).mul(model); gl3.glEnable(GL_DEPTH_TEST); gl3.glUseProgram(programName[Program.THROUGH]); gl3.glUniform1i(uniformDiffuse[Program.THROUGH], 0); gl3.glUniformMatrix4fv(uniformMvp[Program.THROUGH], 1, false, mvp.toFa_(), 0); gl3.glViewport(0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl3.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0, 1)); gl3.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, .5f).put(2, 0).put(3, 1)); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glBindSampler(0, samplerName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 5); gl3.glDisable(GL_DEPTH_TEST); checkError(gl3, "renderFBO"); }
Example 17
Source File: Gl_320_primitive_line_msaa.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; { gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl3.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl3.glViewport(0, 0, windowSize.x >> framebufferScale, windowSize.y >> framebufferScale); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Texture.RENDERBUFFER)); gl3.glClearBufferfv(GL_COLOR, 0, clearColor); gl3.glUseProgram(programName[Program.TEXTURE]); gl3.glBindVertexArray(vertexArrayName.get(Program.TEXTURE)); gl3.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl3.glDrawArraysInstanced(GL_LINE_LOOP, 0, vertexCount, 1); gl3.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferName.get(Texture.RENDERBUFFER)); gl3.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferName.get(Texture.COLORBUFFER)); gl3.glBlitFramebuffer(0, 0, windowSize.x >> framebufferScale, windowSize.y >> framebufferScale, 0, 0, windowSize.x >> framebufferScale, windowSize.y >> framebufferScale, GL_COLOR_BUFFER_BIT, GL_NEAREST); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glUseProgram(programName[Program.SPLASH]); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindVertexArray(vertexArrayName.get(Program.SPLASH)); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1); return true; }
Example 18
Source File: Gl_320_fbo.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; { gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl3.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } { gl3.glEnable(GL_DEPTH_TEST); gl3.glDepthFunc(GL_LESS); gl3.glViewport(0, 0, windowSize.x * framebufferScale, windowSize.y * framebufferScale); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); //glEnable(GL_FRAMEBUFFER_SRGB); float[] depth = {1.0f}; gl3.glClearBufferfv(GL_DEPTH, 0, depth, 0); gl3.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0); gl3.glUseProgram(programName[Program.TEXTURE]); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glBindVertexArray(vertexArrayName.get(Program.TEXTURE)); gl3.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl3.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0); } { gl3.glDisable(GL_DEPTH_TEST); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); //glDisable(GL_FRAMEBUFFER_SRGB); gl3.glUseProgram(programName[Program.SPLASH]); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindVertexArray(vertexArrayName.get(Program.SPLASH)); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1); } return true; }
Example 19
Source File: Gl_320_fbo_depth.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; { gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl3.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.5f, 8.0f); Mat4 model = new Mat4(1.0f).scale(new Vec3(5.0f)); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl3.glEnable(GL_DEPTH_TEST); gl3.glDepthFunc(GL_LESS); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); float[] depth = {1.0f}; gl3.glClearBufferfv(GL_DEPTH, 0, depth, 0); // Bind rendering objects gl3.glUseProgram(programName[Program.TEXTURE]); gl3.glUniformBlockBinding(programName[Program.TEXTURE], uniformTransform, Semantic.Uniform.TRANSFORM0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glBindVertexArray(vertexArrayName.get(Program.TEXTURE)); gl3.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl3.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0); gl3.glDisable(GL_DEPTH_TEST); gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glUseProgram(programName[Program.SPLASH]); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindVertexArray(vertexArrayName.get(Program.SPLASH)); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RENDERBUFFER)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1); return true; }
Example 20
Source File: Gl_330_blend_rtt.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; // Pass 1 { gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0)); gl3.glViewport(0, 0, windowSize.x >> 1, windowSize.y >> 1); gl3.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 1).put(2, 1).put(3, 1)); gl3.glClearBufferfv(GL_COLOR, 1, clearColor); gl3.glClearBufferfv(GL_COLOR, 2, clearColor); gl3.glClearBufferfv(GL_COLOR, 3, clearColor); } // Pass 2 gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 0)); gl3.glUseProgram(programNameSingle); { Mat4 projection = glm.ortho_(-2.0f, 2.0f, -1.5f, 1.5f, -1.0f, 1.0f); Mat4 view = new Mat4(1.0f); Mat4 model = new Mat4(0.2f); Mat4 mvp = projection.mul(view).mul(model); gl3.glUniformMatrix4fv(uniformMvpSingle, 1, false, mvp.toFa_(), 0); gl3.glUniform1i(uniformDiffuseSingle, 0); } for (int i = 0; i < Texture.MAX; ++i) { gl3.glViewport(viewport[i].x, viewport[i].y, viewport[i].z, viewport[i].w); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(i)); gl3.glBindSampler(0, samplerName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1); } return true; }