本文整理汇总了Java中com.jogamp.opengl.GL4.glBindTexture方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glBindTexture方法的具体用法?Java GL4.glBindTexture怎么用?Java GL4.glBindTexture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL4
的用法示例。
在下文中一共展示了GL4.glBindTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
public void render(GL4 gl4, Application app) {
gl4.glDisable(GL_DEPTH_TEST);
gl4.glViewport(0, 0, app.windowSize.x, app.windowSize.y);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glUseProgram(program.name);
for (int eye = 0; eye < VR.EVREye.Max; eye++) {
gl4.glBindTexture(GL_TEXTURE_2D, app.eyeDesc[eye].textureName.get(FramebufferDesc.Target.RESOLVE));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
// left lens (first half of index array ), right lens (second half of index array )
gl4.glDrawElements(GL_TRIANGLES, indexSize / 2, GL_UNSIGNED_SHORT,
eye == VR.EVREye.EYE_Left ? 0 : indexSize); // indexSize / 2 * Short.Bytes = indexSize
}
gl4.glBindVertexArray(0);
gl4.glUseProgram(0);
}
示例2: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
gl4.glGenTextures(1, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, windowSize.x, windowSize.y);
gl4.glBindTexture(GL_TEXTURE_2D, 0);
return true;
}
示例3: 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);
Mat4 mvp = projection.mul(viewMat4()).mul(new Mat4(1.0f));
uniformPointer.asFloatBuffer().put(mvp.toFa_());
}
gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 1.0f, 1.0f, 1.0f}, 0);
gl4.glBindProgramPipeline(pipelineName.get(0));
gl4.glActiveTexture(GL_TEXTURE0 + Semantic.Sampler.DIFFUSE);
gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(0));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
gl4.glBindBufferBase(GL_SHADER_STORAGE_BUFFER, Semantic.Storage.VERTEX, bufferName.get(Buffer.VERTEX));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0, 0);
return true;
}
示例4: FramebufferDesc
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
public FramebufferDesc(GL4 gl4, Vec2i size) {
gl4.glGenFramebuffers(Target.MAX, framebufferName);
gl4.glGenRenderbuffers(1, depthBufferName);
gl4.glGenTextures(Target.MAX, textureName);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Target.RENDER));
gl4.glBindRenderbuffer(GL_RENDERBUFFER, depthBufferName.get(0));
gl4.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT, size.x, size.y);
gl4.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBufferName.get(0));
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Target.RENDER));
gl4.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, size.x, size.y, true);
gl4.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
textureName.get(Target.RENDER), 0);
if (!checkFramebufferStatus(gl4)) {
return;
}
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Target.RESOLVE));
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Target.RESOLVE));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size.x, size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
gl4.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
textureName.get(Target.RESOLVE), 0);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
if (!checkFramebufferStatus(gl4)) {
return;
}
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
示例5: initTextureMaps
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTextureMaps(GL4 gl4) {
try {
BufferedImage bufferedImage = ImageIO.read(new File(TEXTURE_PATH));
byte[] dataBytes = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
ByteBuffer bufferedImageBuffer = GLBuffers.newDirectByteBuffer(dataBytes);
gl4.glGenTextures(1, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, bufferedImage.getWidth(), bufferedImage.getHeight(), 0,
GL_RGB, GL_UNSIGNED_BYTE, bufferedImageBuffer);
gl4.glGenerateMipmap(GL_TEXTURE_2D);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
FloatBuffer maxAnis = GLBuffers.newDirectFloatBuffer(1);
gl4.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, maxAnis);
gl4.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnis.get(0));
gl4.glBindTexture(GL_TEXTURE_2D, 0);
BufferUtils.destroyDirectBuffer(maxAnis);
BufferUtils.destroyDirectBuffer(bufferedImageBuffer);
} catch (IOException ex) {
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
}
return true;
}
示例6: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private void initTexture(GL4 gl4, RenderModel_TextureMap_t diffuseTexture) {
// create and populate the texture
gl4.glGenTextures(1, textureName);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
ByteBuffer buffer = GLBuffers.newDirectByteBuffer(diffuseTexture.dataSize());
byte[] data = diffuseTexture.rubTextureMapData.getByteArray(0, diffuseTexture.dataSize());
IntStreamEx.range(diffuseTexture.dataSize()).forEach(i -> buffer.put(i, data[i]));
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, diffuseTexture.unWidth, diffuseTexture.unHeight,
0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
// If this renders black ask McJohn what's wrong.
gl4.glGenerateMipmap(GL_TEXTURE_2D);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
FloatBuffer largest = GLBuffers.newDirectFloatBuffer(1);
gl4.glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, largest);
gl4.glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest.get(0));
gl4.glBindTexture(GL_TEXTURE_2D, 0);
BufferUtils.destroyDirectBuffer(buffer);
BufferUtils.destroyDirectBuffer(largest);
}
示例7: render
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
@Override
protected boolean render(GL gl) {
GL4 gl4 = (GL4) gl;
gl4.glViewportIndexedf(0, 0, 0, windowSize.x, windowSize.y);
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindSampler(0, samplerName.get(0));
// Render
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(0));
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 0.0f, 1.0f}, 0);
gl4.glBindProgramPipeline(pipelineName.get(Pipeline.RENDER));
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glBindImageTexture(Semantic.Image.DIFFUSE, textureName.get(Texture.COLORBUFFER), 0, false, 0, GL_WRITE_ONLY,
GL_RGBA8);
gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0);
// Splash
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glBindProgramPipeline(pipelineName.get(Pipeline.SPLASH));
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
gl4.glDrawArraysInstancedBaseInstance(GL_TRIANGLES, 0, 3, 1, 0);
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, 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.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);
gl4.glUniform1i(uniformDiffuse, 0);
gl4.glUniformBlockBinding(programName, uniformTransform, Semantic.Uniform.TRANSFORM0);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM));
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0);
return true;
}
示例9: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
try {
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glGenTextures(1, textureName);
gl4.glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, textureName.get(0));
gl4.glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MAX_LEVEL, 0);
jgli.Texture texture = jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE_DDS);
assert (!texture.empty());
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
jgli.Gl.Target target = jgli.Gl.translate(texture.target());
gl4.glTexImage3D(
target.value, 0,
format.internal.value,
texture.dimensions()[0], texture.dimensions()[1], texture.faces(),
0,
format.external.value, format.type.value,
texture.data());
} catch (IOException ex) {
Logger.getLogger(Gl_400_texture_cube.class.getName()).log(Level.SEVERE, null, ex);
}
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);
//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, windowSize.x * 0.5f / 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);
}
gl4.glClearBufferfv(GL_COLOR, 0, new float[]{1.0f, 0.5f, 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));
gl4.glViewportIndexedf(0, 0, 0, windowSize.x / 2.0f, windowSize.y);
gl4.glViewportIndexedf(1, windowSize.x / 2.0f, 0, windowSize.x / 2.0f, windowSize.y);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.VIEW_A));
gl4.glActiveTexture(GL_TEXTURE1);
gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.VIEW_B));
gl4.glDrawElementsInstancedBaseVertexBaseInstance(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 2, 0, 0);
return true;
}
示例11: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
try {
jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl4.glGenTextures(1, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(0));
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_R, GL_RED);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl4.glTexStorage3D(GL_TEXTURE_2D_ARRAY, texture.levels(),
format.internal.value,
texture.dimensions(0)[0], texture.dimensions(0)[1], 1);
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level,
0, 0, 0,
texture.dimensions(level)[0], texture.dimensions(level)[1], 1,
format.external.value, format.type.value,
texture.data(level));
}
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
} catch (IOException ex) {
Logger.getLogger(Gl_430_texture_storage.class.getName()).log(Level.SEVERE, null, ex);
}
return true;
}
示例12: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
try {
jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl4.glGenTextures(1, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(0));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glTexStorage2D(GL_TEXTURE_2D, texture.levels(),
format.internal.value, texture.dimensions()[0], texture.dimensions()[1]);
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexSubImage2D(GL_TEXTURE_2D, level,
0, 0,
texture.dimensions(level)[0], texture.dimensions(level)[1],
format.external.value, format.type.value,
texture.data(level));
}
imageSize.set(texture.dimensions());
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
} catch (IOException ex) {
Logger.getLogger(Gl_420_image_load.class.getName()).log(Level.SEVERE, null, ex);
}
return true;
}
示例13: 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, 1000.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, 1).put(1, 0.5f).put(2, 0).put(3, 1));
gl4.glUseProgram(programName);
gl4.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0);
gl4.glUniform1i(uniformDiffuseRGB, 0);
gl4.glUniform1i(uniformDiffuseBGR, 1);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RGB));
gl4.glBindSampler(0, samplerName.get(0));
gl4.glActiveTexture(GL_TEXTURE1);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.BGR));
gl4.glBindSampler(1, samplerName.get(0));
gl4.glBindVertexArray(vertexArrayName.get(0));
gl4.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0, 1, 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);
// 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;
}
示例15: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
try {
jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl4.glGenTextures(1, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(0));
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_R, GL_RED);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl4.glTexStorage3D(GL_TEXTURE_2D_ARRAY, texture.levels(), format.internal.value,
texture.dimensions(0)[0], texture.dimensions(0)[1], 1);
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexSubImage3D(GL_TEXTURE_2D_ARRAY, level,
0, 0, 0,
texture.dimensions(level)[0], texture.dimensions(level)[1], 1,
format.external.value, format.type.value,
texture.data(level));
}
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
} catch (IOException ex) {
Logger.getLogger(Gl_450_clip_control.class.getName()).log(Level.SEVERE, null, ex);
}
return true;
}