Java Code Examples for com.jogamp.opengl.GL3#glClearColor()
The following examples show how to use
com.jogamp.opengl.GL3#glClearColor() .
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: JCudaDriverSimpleJOGL.java From jcuda-samples with MIT License | 6 votes |
@Override public void init(GLAutoDrawable drawable) { // Perform the default GL initialization GL3 gl = drawable.getGL().getGL3(); gl.setSwapInterval(0); gl.glEnable(GL_DEPTH_TEST); gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); setupView(drawable); // Initialize the shaders initShaders(gl); // Initialize JCuda initJCuda(); // Create the VBO containing the vertex data initVBO(gl); }
Example 2
Source File: Gl_320_glsl_discard.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glClearColor(1.0f, 0.5f, 0.0f, 1.0f); gl3.glClear(GL_COLOR_BUFFER_BIT); gl3.glUseProgram(programName); gl3.glUniform1i(uniformDiffuse, 0); gl3.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1); return true; }
Example 3
Source File: Gl_300_fbo_multisample.java From jogl-samples with MIT License | 6 votes |
private void renderFBO(GL3 gl3, int framebuffer) { gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); gl3.glClearColor(0.0f, 0.5f, 1.0f, 1.0f); gl3.glClear(GL_COLOR_BUFFER_BIT); 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); 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.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArrays(GL_TRIANGLES, 0, vertexCount); checkError(gl3, "renderFBO"); }
Example 4
Source File: Gl_300_test_alpha.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glClearColor(1.0f, 0.5f, 0.0f, 1.0f); gl3.glClear(GL_COLOR_BUFFER_BIT); gl3.glUseProgram(programName); gl3.glUniform1i(uniformDiffuse, 0); gl3.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArrays(GL_TRIANGLES, 0, vertexCount); return true; }
Example 5
Source File: Gl_320_transform_feedback_separated.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); // Set the display viewport gl3.glViewport(0, 0, windowSize.x, windowSize.y); // Clear color buffer with black gl3.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); gl3.glClear(GL_COLOR_BUFFER_BIT); // First draw, capture the attributes { // Disable rasterisation, vertices processing only! gl3.glEnable(GL_RASTERIZER_DISCARD); gl3.glUseProgram(programName[Program.TRANSFORM]); gl3.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl3.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackOutput.POSITION, bufferName.get(Buffer.POSITION)); gl3.glBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, feedbackOutput.COLOR, bufferName.get(Buffer.COLOR)); gl3.glBindVertexArray(vertexArrayName.get(Program.TRANSFORM)); gl3.glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queryName.get(0)); gl3.glBeginTransformFeedback(GL_TRIANGLES); { gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1); } gl3.glEndTransformFeedback(); gl3.glEndQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN); gl3.glDisable(GL_RASTERIZER_DISCARD); } // Second draw, reuse the captured attributes { gl3.glUseProgram(programName[Program.FEEDBACK]); IntBuffer primitivesWritten = GLBuffers.newDirectIntBuffer(1); gl3.glGetQueryObjectuiv(queryName.get(0), GL_QUERY_RESULT, primitivesWritten); gl3.glBindVertexArray(vertexArrayName.get(Program.FEEDBACK)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, primitivesWritten.get(0) * 3, 1); BufferUtils.destroyDirectBuffer(primitivesWritten); } return true; }