本文整理汇总了Java中com.jogamp.opengl.GL4.glBindBufferRange方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glBindBufferRange方法的具体用法?Java GL4.glBindBufferRange怎么用?Java GL4.glBindBufferRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL4
的用法示例。
在下文中一共展示了GL4.glBindBufferRange方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderFBO
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFBO(GL4 gl4) {
//glEnable(GL_SAMPLE_MASK);
//glSampleMaski(0, 0xFF);
gl4.glEnable(GL_MULTISAMPLE);
gl4.glEnable(GL_SAMPLE_SHADING);
gl4.glMinSampleShading(4 / 4.0f);
gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1.0f).put(1, 1.0f).put(2, 1.0f).put(3, 1.0f));
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
uniformBlockSize);
gl4.glBindSampler(0, samplerName.get(0));
gl4.glBindTextureUnit(0, textureName.get(Texture.TEXTURE));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);
gl4.glDisable(GL_MULTISAMPLE);
}
示例2: renderFBO
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFBO(GL4 gl4) {
gl4.glEnable(GL_MULTISAMPLE);
gl4.glEnable(GL_SAMPLE_SHADING);
gl4.glMinSampleShading(4 / 4.0f);
gl4.glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);
gl4.glClearNamedFramebufferfv(framebufferName.get(Framebuffer.RENDER), GL_COLOR, 0, clearColor);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
uniformBlockSize);
gl4.glBindSamplers(0, 1, samplerName);
gl4.glBindTextureUnit(0, textureName.get(Texture.TEXTURE));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);
gl4.glDisable(GL_MULTISAMPLE);
}
示例3: 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);
}
示例4: renderFBO
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFBO(GL4 gl4) {
gl4.glEnable(GL_MULTISAMPLE);
gl4.glEnable(GL_SAMPLE_SHADING);
gl4.glMinSampleShading(4.0f);
gl4.glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
gl4.glViewportIndexedf(0, 0, 0, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y);
FloatBuffer clear = GLBuffers.newDirectFloatBuffer(new float[]{0.0f, 0.5f, 1.0f, 1.0f});
gl4.glClearNamedFramebufferfv(framebufferName.get(Framebuffer.RENDER), GL_COLOR, 0, clear);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
uniformBlockSize);
gl4.glBindSamplers(0, 1, samplerName);
gl4.glBindTextureUnit(0, textureName.get(Texture.TEXTURE));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);
gl4.glDisable(GL_MULTISAMPLE);
}
示例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, (float) windowSize.x / windowSize.y,
0.1f, 100.0f);
viewMat4().print("view");
uniformPointer.asFloatBuffer().put(viewMat4().toFa_());
//uniformPointer.asFloatBuffer().put(new Mat4().toFa_());
}
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glUseProgram(programName);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor);
gl4.glBindBufferRange(GL_UNIFORM_BUFFER,
Semantic.Uniform.TRANSFORM0,
bufferName.get(Buffer.TRANSFORM),
0,
Mat4.SIZE);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawArrays(GL_TRIANGLES, 0, 3);
return true;
}
示例6: renderFB
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFB(GL4 gl4) {
gl4.glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);
gl4.glClearNamedFramebufferfv(0, GL_COLOR, 0, new float[]{0.0f, 0.5f, 1.0f, 1.0f}, 0);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM),
uniformBlockSize, uniformBlockSize);
gl4.glBindTextureUnit(0, textureName.get(Texture.COLORBUFFER));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);
}
示例7: 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);
}
示例8: renderFB
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFB(GL4 gl4) {
gl4.glClipControl(GL_LOWER_LEFT, GL_NEGATIVE_ONE_TO_ONE);
gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);
FloatBuffer clear = GLBuffers.newDirectFloatBuffer(new float[]{0.0f, 0.5f, 1.0f, 1.0f});
gl4.glClearNamedFramebufferfv(0, GL_COLOR, 0, clear);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM),
uniformBlockSize, uniformBlockSize);
gl4.glBindTextureUnit(0, textureName.get(Texture.COLORBUFFER));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);
}
示例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;
int uniformBufferOffset = Math.max(uniformBufferAlignment.get(0), Mat4.SIZE);
int uniformBufferRange = uniformBufferOffset * 2;
{
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
ByteBuffer pointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER,
0, uniformBufferRange, 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 model0 = new Mat4(1.0f).translate(new Vec3(+1, 0, 0));
Mat4 model1 = new Mat4(1.0f).translate(new Vec3(-1, 0, 0));
pointer.position(uniformBufferOffset * 0);
pointer.asFloatBuffer().put(projection.mul_(viewMat4()).mul(model0).toFa_());
pointer.position(uniformBufferOffset * 1);
pointer.asFloatBuffer().put(projection.mul_(viewMat4()).mul(model1).toFa_());
// Make sure the uniform buffer is uploaded
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 1).put(2, 1).put(3, 1));
gl4.glUseProgram(programName);
// Attach the buffer to UBO binding point semantic::uniform::TRANSFORM0
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
Mat4.SIZE);
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM1, bufferName.get(Buffer.TRANSFORM),
uniformBufferOffset, Mat4.SIZE);
// Attach the buffer to UBO binding point semantic::uniform::MATERIAL
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.MATERIAL, bufferName.get(Buffer.MATERIAL));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0);
return true;
}
示例11: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
int uniformBufferOffset = Math.max(uniformBufferAlignment.get(0), Mat4.SIZE);
int uniformBufferRange = uniformBufferOffset * 2;
{
gl4.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM));
ByteBuffer pointer = gl4.glMapBufferRange(GL_UNIFORM_BUFFER, 0,
uniformBufferRange, 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 model0 = new Mat4(1.0f).translate(new Vec3(+1, 0, 0));
Mat4 model1 = new Mat4(1.0f).translate(new Vec3(-1, 0, 0));
pointer.position(uniformBufferOffset * 0);
pointer.asFloatBuffer().put(projection.mul_(viewMat4()).mul(model0).toFa_());
pointer.position(uniformBufferOffset * 1);
pointer.asFloatBuffer().put(projection.mul_(viewMat4()).mul(model1).toFa_());
pointer.rewind();
// Make sure the uniform buffer is uploaded
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
gl4.glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, 1).put(2, 1).put(3, 1));
gl4.glUseProgram(programName);
// Attach the buffer to UBO binding point semantic::uniform::MATERIAL
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.MATERIAL, bufferName.get(Buffer.MATERIAL));
gl4.glBindVertexArray(vertexArrayName.get(0));
// Attach the buffer to UBO binding point semantic::uniform::TRANSFORM0
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM), 0,
Mat4.SIZE);
gl4.glBindBufferRange(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM1, bufferName.get(Buffer.TRANSFORM),
uniformBufferOffset, Mat4.SIZE);
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 1);
return true;
}