本文整理汇总了Java中com.jogamp.opengl.GL4.glDrawArraysInstanced方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glDrawArraysInstanced方法的具体用法?Java GL4.glDrawArraysInstanced怎么用?Java GL4.glDrawArraysInstanced使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL4
的用法示例。
在下文中一共展示了GL4.glDrawArraysInstanced方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderFBO
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFBO(GL4 gl4, int framebuffer) {
gl4.glEnable(GL_DEPTH_TEST);
gl4.glBindProgramPipeline(pipelineName.get(Program.THROUGH));
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
uniformBlockSize);
gl4.glViewport(0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
float[] depth = {1.0f};
gl4.glClearBufferfv(GL_DEPTH, 0, depth, 0);
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0);
textureName.position(Texture.DIFFUSE);
gl4.glBindTextures(0, 1, textureName);
textureName.rewind();
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 5);
gl4.glDisable(GL_DEPTH_TEST);
}
示例2: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
gl4.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
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);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 0));
gl4.glUseProgram(programName);
gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glPatchParameteri(GL_PATCH_VERTICES, vertexCount);
gl4.glPatchParameterfv(GL_PATCH_DEFAULT_INNER_LEVEL, patch.put(0, 16).put(1, 16));
gl4.glPatchParameterfv(GL_PATCH_DEFAULT_OUTER_LEVEL, patch.put(0, 16).put(1, 16).put(2, 16).put(3, 16));
gl4.glDrawArraysInstanced(GL_PATCHES, 0, vertexCount, 1);
return true;
}
示例3: resolveMultisampling
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void resolveMultisampling(GL4 gl4) {
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
textureName.position(Texture.MULTISAMPLE_COLORBUFFER);
gl4.glBindTextures(0, 1, textureName);
textureName.rewind();
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM),
uniformBlockSize, uniformBlockSize);
gl4.glEnable(GL_SCISSOR_TEST);
// Box
{
gl4.glScissor(1, 1, windowSize.x / 2 - 2, windowSize.y - 2);
gl4.glBindProgramPipeline(pipelineName.get(Program.RESOLVE_BOX));
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 5);
}
// Near
{
gl4.glScissor(windowSize.x / 2 + 1, 1, windowSize.x / 2 - 2, windowSize.y - 2);
gl4.glBindProgramPipeline(pipelineName.get(Program.RESOLVE_NEAR));
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 5);
}
gl4.glDisable(GL_SCISSOR_TEST);
}
示例4: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
Vec2i framebufferSize = new Vec2i(windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE);
// Pass 1
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
gl4.glViewport(0, 0, framebufferSize.x, framebufferSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 0).put(2, 0).put(3, 1));
gl4.glClearBufferfv(GL_COLOR, 1, clearColor.put(0, 0).put(1, 1).put(2, 0).put(3, 1));
gl4.glClearBufferfv(GL_COLOR, 2, clearColor.put(0, 0).put(1, 0).put(2, 1).put(3, 1));
gl4.glClearBufferfv(GL_COLOR, 3, clearColor.put(0, 1).put(1, 1).put(2, 0).put(3, 1));
// Pass 2
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, .5f).put(2, 0).put(3, 1));
gl4.glUseProgram(programName);
gl4.glUniform1i(uniformDiffuse, 0);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(0));
gl4.glBindVertexArray(vertexArrayName.get(0));
for (int i = 0; i < Texture.MAX; ++i) {
gl4.glViewport((int) viewport[i].x, (int) viewport[i].y, (int) viewport[i].z, (int) viewport[i].w);
gl4.glUniform1i(uniformLayer, i);
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
}
return true;
}
示例5: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, windowSize.x * 0.5f / windowSize.y, 0.1f, 100.0f);
Mat4 model = new Mat4(1.0f);
Mat4 mvp = projection.mul(viewMat4()).mul(model);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 1));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferName.get(Buffer.ELEMENT));
gl4.glViewport(0, 0, (int) (windowSize.x * 0.5f), windowSize.y);
gl4.glUseProgram(programName[Program.TESS]);
gl4.glUniformMatrix4fv(uniformMvp[Program.TESS], 1, false, mvp.toFa_(), 0);
gl4.glPatchParameteri(GL_PATCH_VERTICES, vertexCount);
gl4.glDrawArraysInstanced(GL_PATCHES, 0, vertexCount, 1);
gl4.glViewport((int) (windowSize.x * 0.5f), 0, (int) (windowSize.x * 0.5f), windowSize.y);
gl4.glUseProgram(programName[Program.SMOOTH]);
gl4.glUniformMatrix4fv(uniformMvp[Program.SMOOTH], 1, false, mvp.toFa_(), 0);
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);
return true;
}
示例6: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
{
float aspect = (windowSize.x * 0.33f) / (windowSize.y * 0.50f);
Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, aspect, 0.1f, 100.0f);
Mat4 mvp = projection.mul(viewMat4()).mul(new Mat4(1.0f));
uniformPointer.asFloatBuffer().put(mvp.toFa_());
}
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0);
gl4.glBindProgramPipeline(pipelineName.get(0));
bufferName.position(Buffer.TRANSFORM);
gl4.glBindBuffersBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, 1, bufferName);
gl4.glBindTextures(Semantic.Sampler.DIFFUSE, 1, textureName);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindVertexBuffer(Semantic.Buffer.STATIC, bufferName.get(Buffer.VERTEX), 0, Vertex_v2fv2f.SIZE);
for (int index = 0; index < Viewport.MAX; ++index) {
gl4.glViewportIndexedf(0,
viewport[index].x,
viewport[index].y,
viewport[index].z,
viewport[index].w);
samplerName.position(index);
gl4.glBindSamplers(0, 1, samplerName);
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
}
return true;
}
示例7: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
{
// Compute the MVP (Model View Projection matrix)
float aspect = (windowSize.x * 0.33f) / (windowSize.y * 0.50f);
Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, aspect, 0.1f, 100.0f);
Mat4 mvp = projection.mul(viewMat4()).mul(new Mat4(1.0f));
uniformPointer.asFloatBuffer().put(mvp.toFa_());
}
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 1.0f, 1.0f, 1.0f}, 0);
gl4.glBindProgramPipeline(pipelineName.get(0));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
for (int index = 0; index < Viewport.MAX; ++index) {
gl4.glViewportIndexedf(0,
viewport[index].viewport.x,
viewport[index].viewport.y,
viewport[index].viewport.z,
viewport[index].viewport.w);
gl4.glBindVertexArray(vertexArrayName.get(viewport[index].vertexFormat));
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
}
return true;
}
示例8: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
{
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
ByteBuffer pointer = gl4.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);
projection.mul(viewMat4()).toDbb(pointer);
// Make sure the uniform buffer is uploaded
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
}
{
gl4.glEnable(GL_DEPTH_TEST);
gl4.glDepthFunc(GL_LESS);
gl4.glViewport(0, 0, windowSize.x * framebufferScale, windowSize.y * framebufferScale);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
// Convert linear clear color to sRGB color space, FramebufferName is a sRGB FBO
gl4.glEnable(GL_FRAMEBUFFER_SRGB);
gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0, 1.0f));
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1.0f).put(1, 0.5f).put(2, 0.0f).put(3, 1.0f));
// TextureName[texture::DIFFUSE] is a sRGB texture which sRGB conversion on fetch has been disabled
// Hence in the shader, the value is stored as sRGB so we should not convert it to sRGB.
gl4.glDisable(GL_FRAMEBUFFER_SRGB);
gl4.glUseProgram(programName[Program.TEXTURE]);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.DIFFUSE_RGB));
gl4.glBindVertexArray(vertexArrayName.get(Program.TEXTURE));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);
}
{
gl4.glDisable(GL_DEPTH_TEST);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glUseProgram(programName[Program.SPLASH]);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindVertexArray(vertexArrayName.get(Program.SPLASH));
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1);
}
return true;
}
示例9: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
{
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
ByteBuffer pointer = gl4.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_());
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
}
// Set the display viewport
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
// Clear color buffer with black
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.0f, 0.0f, 1.0f}, 0);
gl4.glBindProgramPipeline(pipelineName.get(0));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.MATERIAL, bufferName.get(Buffer.MATERIAL), 0, Vec4.SIZE);
// The first orange quad is not written in the framebuffer.
// gl4.glColorMaski(0, false, false, false, false);
// Beginning of the samples count query
gl4.glBeginQuery(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, queryName.get(0));
{
if (toggle) {
// To test the condional rendering, comment this line, the next draw call won't happen.
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
}
}// End of the samples count query
gl4.glEndQuery(GL_ANY_SAMPLES_PASSED_CONSERVATIVE);
// The second blue quad is written in the framebuffer only if a sample pass the occlusion query.
gl4.glColorMaski(0, true, true, true, true);
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.MATERIAL, bufferName.get(Buffer.MATERIAL),
uniformMaterialOffset, Vec4.SIZE);
// Draw only if one sample went through the tests,
// we don't need to get the query result which prevent the rendering pipeline to stall.
gl4.glBeginConditionalRender(queryName.get(0), GL_QUERY_WAIT);
{
// Clear color buffer with white
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 1.0f, 1.0f, 1.0f}, 0);
// gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
}
gl4.glEndConditionalRender();
toggle = !toggle;
return true;
}
示例10: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
{
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
ByteBuffer pointer = gl4.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_());
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
}
// Set the display viewport
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
// Clear color buffer with black
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.0f, 0.0f, 1.0f}, 0);
gl4.glBindProgramPipeline(pipelineName.get(0));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
// Samples count query
gl4.glBeginQuery(GL_ANY_SAMPLES_PASSED_CONSERVATIVE, queryName.get(0));
{
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
}
gl4.glEndQuery(GL_ANY_SAMPLES_PASSED_CONSERVATIVE);
// Get the count of samples.
// If the result of the query isn't here yet, we wait here...
int[] samplesCount = {0};
gl4.glGetQueryObjectuiv(queryName.get(0), GL_QUERY_RESULT, samplesCount, 0);
System.out.println("Samples count: " + (samplesCount[0] == GL_TRUE));
return true;
}
示例11: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
{
Mat4 model = new Mat4(1.0f);
Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f);
Mat4 mvp = projection.mul(viewMat4()).mul(model);
uniformPointer.asFloatBuffer().put(mvp.toFa_());
}
// Set the display viewport
gl4.glViewportIndexedf(0, 0.0f, 0.0f, windowSize.x, windowSize.y);
// Clear color buffer
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{0.0f, 0.0f, 0.0f, 1.0f}, 0);
// First draw, capture the attributes
// Disable rasterisation, vertices processing only!
gl4.glEnable(GL_RASTERIZER_DISCARD);
gl4.glBindProgramPipeline(pipelineName.get(Program.TRANSFORM));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
gl4.glBindVertexArray(vertexArrayName.get(Program.TRANSFORM));
gl4.glBindVertexBuffer(Semantic.Buffer.STATIC, bufferName.get(Buffer.VERTEX), 0, Vec4.SIZE);
gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedbackName.get(0));
gl4.glBeginQueryIndexed(GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, 0, queryName.get(0));
gl4.glBeginTransformFeedback(GL_TRIANGLES);
{
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
}
gl4.glEndTransformFeedback();
gl4.glEndQueryIndexed(GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB, 0);
gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
gl4.glDisable(GL_RASTERIZER_DISCARD);
IntBuffer streamOverflow = GLBuffers.newDirectIntBuffer(1);
gl4.glGetQueryObjectuiv(queryName.get(0), GL_QUERY_RESULT, streamOverflow);
if (streamOverflow.get(0) == 0) {
// Second draw, reuse the captured attributes
gl4.glBindProgramPipeline(pipelineName.get(Program.FEEDBACK));
gl4.glBindVertexArray(vertexArrayName.get(Program.FEEDBACK));
gl4.glBindVertexBuffer(Semantic.Buffer.STATIC, bufferName.get(Buffer.FEEDBACK), 0, glf.Vertex_v4fc4f.SIZE);
gl4.glDrawTransformFeedback(GL_TRIANGLES, feedbackName.get(0));
}
BufferUtils.destroyDirectBuffer(streamOverflow);
return true;
}
示例12: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
gl4.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
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);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 0));
gl4.glUseProgram(programName);
gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glPatchParameteri(GL_PATCH_VERTICES, vertexCount);
gl4.glDrawArraysInstanced(GL_PATCHES, 0, vertexCount, 1);
return true;
}
示例13: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
// Compute the MVP (Model View Projection matrix)
{
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM0));
ByteBuffer pointer = gl4.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_());
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
}
// Set the display viewport
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
// Clear color buffer
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 1));
// First draw, capture the attributes
// Disable rasterisation, vertices processing only!
gl4.glEnable(GL_RASTERIZER_DISCARD);
gl4.glUseProgram(transformProgramName);
gl4.glBindVertexArray(vertexArrayName.get(VertexArray.TRANSFORM_FEEDBACK));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM0));
gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, feedbackName.get(0));
gl4.glBeginTransformFeedback(GL_TRIANGLES);
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1);
gl4.glEndTransformFeedback();
gl4.glBindTransformFeedback(GL_TRANSFORM_FEEDBACK, 0);
gl4.glDisable(GL_RASTERIZER_DISCARD);
// Second draw, reuse the captured attributes
gl4.glUseProgram(feedbackProgramName);
gl4.glBindVertexArray(vertexArrayName.get(VertexArray.FEEDBACK));
gl4.glDrawTransformFeedback(GL_TRIANGLES, feedbackName.get(0));
return true;
}
示例14: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
Vec2i framebufferSize = new Vec2i(windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE);
// Update of the uniform buffer
{
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
ByteBuffer pointer = gl4.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_());
// Make sure the uniform buffer is uploaded
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
}
gl4.glEnable(GL_DEPTH_TEST);
gl4.glDepthFunc(GL_LESS);
gl4.glViewport(0, 0, framebufferSize.x, framebufferSize.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0,1));
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 1));
gl4.glUseProgram(programName[Program.TEXTURE]);
gl4.glUniform1i(uniformDiffuse[Program.TEXTURE], 0);
gl4.glUniformBlockBinding(programName[Program.TEXTURE], uniformTransform,
Semantic.Uniform.TRANSFORM0);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glBindVertexArray(vertexArrayName.get(Program.TEXTURE));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
gl4.glEnable(GL_SCISSOR_TEST);
{
gl4.glScissor(0, 0, framebufferSize.x / 2, framebufferSize.y);
gl4.glUniform1i(uniformUseGrad, 1);
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);
gl4.glScissor(framebufferSize.x / 2, 0, framebufferSize.x / 2, framebufferSize.y);
gl4.glUniform1i(uniformUseGrad, 0);
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);
}
gl4.glDisable(GL_SCISSOR_TEST);
gl4.glDisable(GL_DEPTH_TEST);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glUseProgram(programName[Program.SPLASH]);
gl4.glUniform1i(uniformDiffuse[Program.SPLASH], 0);
gl4.glUniform1f(uniformFramebufferSize, FRAMEBUFFER_SIZE);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindVertexArray(vertexArrayName.get(Program.SPLASH));
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
gl4.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1);
return true;
}
示例15: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
gl4.glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
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);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 0));
gl4.glUseProgram(programName);
gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glPatchParameteri(GL_PATCH_VERTICES, vertexCount);
gl4.glDrawArraysInstanced(GL_PATCHES, 0, vertexCount, 1);
return true;
}