Java Code Examples for com.jogamp.opengl.GL3#glDrawBuffer()
The following examples show how to use
com.jogamp.opengl.GL3#glDrawBuffer() .
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_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 2
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 3
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 4
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 5
Source File: Gl_320_fbo_depth.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_DEPTH_ATTACHMENT, textureName.get(Texture.RENDERBUFFER), 0); gl3.glDrawBuffer(GL_NONE); if (!isFramebufferComplete(gl3, framebufferName.get(0))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return true; }
Example 6
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 7
Source File: Gl_320_texture_2d.java From jogl-samples with MIT License | 5 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.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl3.glDrawBuffer(GL_BACK); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glDisable(GL_FRAMEBUFFER_SRGB); clearColor.put(new float[]{1.0f, 0.5f, 0.0f, 1.0f}).rewind(); gl3.glClearBufferfv(GL_COLOR, 0, clearColor); gl3.glUseProgram(programName); gl3.glDisable(GL_FRAMEBUFFER_SRGB); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0); return true; }
Example 8
Source File: Gl_300_fbo_multisample.java From jogl-samples with MIT License | 5 votes |
@Override public boolean render(GL gl) { GL3 gl3 = (GL3) gl; // Clear the framebuffer gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0); gl3.glUseProgram(programName); gl3.glUniform1i(uniformDiffuse, 0); // Pass 1 // Render the scene in a multisampled framebuffer gl3.glEnable(GL_MULTISAMPLE); renderFBO(gl3, framebufferName.get(Framebuffer.RENDER)); gl3.glDisable(GL_MULTISAMPLE); // Resolved multisampling gl3.glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER)); gl3.glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE)); gl3.glDrawBuffer(GL_COLOR_ATTACHMENT0); gl3.glBlitFramebuffer( 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, GL_COLOR_BUFFER_BIT, GL_LINEAR); gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); // Pass 2 // Render the colorbuffer from the multisampled framebuffer gl3.glViewport(0, 0, windowSize.x, windowSize.y); renderFB(gl3, textureName.get(Texture.RESOLVE)); return true; }