本文整理汇总了Java中com.jogamp.opengl.GL4.glDepthFunc方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glDepthFunc方法的具体用法?Java GL4.glDepthFunc怎么用?Java GL4.glDepthFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL4
的用法示例。
在下文中一共展示了GL4.glDepthFunc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderFramebuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderFramebuffer(GL4 gl4) {
gl4.glEnable(GL_DEPTH_TEST);
gl4.glDepthFunc(GL_LESS);
gl4.glViewport(0, 0, windowSize.x, windowSize.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth);
gl4.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 0).put(1, 0).put(2, 0).put(3, 1));
gl4.glUseProgram(programName[Program.RENDER]);
gl4.glUniform1i(uniformShadow, 0);
gl4.glUniformBlockBinding(programName[Program.RENDER], uniformTransform[Program.RENDER],
Semantic.Uniform.TRANSFORM0);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.SHADOWMAP));
gl4.glBindVertexArray(vertexArrayName.get(Program.RENDER));
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);
gl4.glDisable(GL_DEPTH_TEST);
checkError(gl4, "renderFramebuffer");
}
示例2: 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;
}
示例3: 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;
}
示例4: renderShadow
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void renderShadow(GL4 gl4) {
gl4.glEnable(GL_DEPTH_TEST);
gl4.glDepthFunc(GL_LESS);
gl4.glViewport(0, 0, shadowSize.x, shadowSize.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.SHADOW));
gl4.glClearBufferfv(GL_DEPTH, 0, clearDepth.put(0, 1));
// Bind rendering objects
gl4.glUseProgram(programName[Program.DEPTH]);
gl4.glUniformBlockBinding(programName[Program.DEPTH], uniformTransform[Program.DEPTH],
Semantic.Uniform.TRANSFORM0);
gl4.glBindVertexArray(vertexArrayName.get(Program.RENDER));
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);
gl4.glDisable(GL_DEPTH_TEST);
checkError(gl4, "renderShadow");
}
示例5: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
{
ByteBuffer pointer = gl4.glMapNamedBufferRange(bufferName.get(Buffer.TRANSFORM),
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
gl4.glUnmapNamedBuffer(bufferName.get(Buffer.TRANSFORM));
}
gl4.glEnable(GL_DEPTH_TEST);
gl4.glDepthFunc(GL_LESS);
gl4.glClearTexImage(textureName.get(Texture.COLORBUFFER), 0, GL_RGBA, GL_UNSIGNED_BYTE, clearColorBuffer);
gl4.glClearTexImage(textureName.get(Texture.RENDERBUFFER), 0, GL_DEPTH_COMPONENT, GL_FLOAT, clearRenderBuffer);
gl4.glClearTexImage(textureName.get(Texture.INVOCATION_COUNT), 0, GL_RED_INTEGER, GL_UNSIGNED_INT,
clearInvocationCount);
gl4.glViewportIndexedf(0, 0, 0, windowSize.x * FRAMEBUFFER_SCALE, windowSize.y * FRAMEBUFFER_SCALE);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
gl4.glBindProgramPipeline(pipelineName.get(Pipeline.TEXTURE));
gl4.glBindVertexArray(vertexArrayName.get(Pipeline.TEXTURE));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
gl4.glBindImageTexture(0, textureName.get(Texture.INVOCATION_COUNT), 0, false, 0, GL_WRITE_ONLY, GL_R32UI);
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 5, 0, 0);
gl4.glDisable(GL_DEPTH_TEST);
gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH));
gl4.glBindVertexArray(vertexArrayName.get(Pipeline.SPLASH));
gl4.glBindImageTexture(0, textureName.get(Texture.INVOCATION_COUNT), 0, false, 0, GL_READ_ONLY, GL_R32UI);
gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0);
return true;
}
示例6: 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);
//glm::mat4 Projection = glm::perspectiveFov(glm::pi<float>() * 0.25f, 640.f, 480.f, 0.1f, 100.0f);
Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f);
Mat4 model = new Mat4(1.0f);
projection.mul(viewMat4()).mul(model).toDbb(pointer);
// Make sure the uniform buffer is uploaded
gl4.glUnmapBuffer(GL_UNIFORM_BUFFER);
}
gl4.glEnable(GL_DEPTH_TEST);
gl4.glDepthFunc(GL_LESS);
gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.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, 1).put(1, 0.5f).put(2, 0).put(3, 1));
// Bind rendering objects
gl4.glBindProgramPipeline(pipelineName.get(Pipeline.TEXTURE));
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glBindVertexArray(vertexArrayName.get(Pipeline.TEXTURE));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0, 0);
gl4.glDisable(GL_DEPTH_TEST);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH));
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindVertexArray(vertexArrayName.get(Pipeline.SPLASH));
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0);
return true;
}