本文整理汇总了Java中com.jogamp.opengl.GL4.glTexImage2D方法的典型用法代码示例。如果您正苦于以下问题:Java GL4.glTexImage2D方法的具体用法?Java GL4.glTexImage2D怎么用?Java GL4.glTexImage2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL4
的用法示例。
在下文中一共展示了GL4.glTexImage2D方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
gl4.glGenTextures(Texture.MAX, textureName);
{
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.MULTISAMPLE));
gl4.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGBA8,
FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, true);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
}
{
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLOR));
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0,
GL_RGBA, GL_UNSIGNED_BYTE, null);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glBindTexture(GL_TEXTURE_2D, 0);
}
return true;
}
示例2: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
try {
gl4.glGenTextures(Texture.MAX, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexImage2D(GL_TEXTURE_2D, level,
format.internal.value,
texture.dimensions(level)[0], texture.dimensions(level)[1],
0,
format.external.value, format.type.value,
texture.data(level));
}
} catch (IOException ex) {
Logger.getLogger(Gl_400_fbo_multisample.class.getName()).log(Level.SEVERE, null, ex);
}
return true;
}
示例3: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glGenTextures(Texture.MAX, textureName);
for (int i = Texture.R; i <= Texture.B; ++i) {
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(i));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1000);
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.glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA8,
320, 240,
0,
GL_RGBA, GL_UNSIGNED_BYTE,
null);
}
return true;
}
示例4: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
gl4.glGenTextures(Texture.MAX, textureName);
{
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.MULTISAMPLE));
gl4.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y,
true);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
}
{
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLOR));
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA,
GL_UNSIGNED_BYTE, null);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glBindTexture(GL_TEXTURE_2D, 0);
}
return true;
}
示例5: 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);
}
示例6: 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;
}
示例7: 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);
}
示例8: 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));
gl4.glGenTextures(Texture.MAX, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexImage2D(GL_TEXTURE_2D, level,
format.internal.value,
texture.dimensions(level)[0], texture.dimensions(level)[1],
0,
format.external.value, format.type.value,
texture.data(level));
}
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.MULTISAMPLE_COLORBUFFER));
gl4.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y,
true);
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.MULTISAMPLE_DEPTHBUFFER));
gl4.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_DEPTH_COMPONENT24, FRAMEBUFFER_SIZE.x,
FRAMEBUFFER_SIZE.y, true);
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA,
GL_UNSIGNED_BYTE, null);
gl4.glBindTexture(GL_TEXTURE_2D, 0);
} catch (IOException ex) {
Logger.getLogger(Gl_450_fbo_multisample_explicit.class.getName()).log(Level.SEVERE, null, ex);
}
return true;
}
示例9: initFramebuffer
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initFramebuffer(GL4 gl4) {
gl4.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.MULTISAMPLE));
// The second parameter is the number of samples.
gl4.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, false);
gl4.glGenFramebuffers(Framebuffer.MAX, framebufferName);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER));
gl4.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.MULTISAMPLE), 0);
if (!isFramebufferComplete(gl4, framebufferName.get(0))) {
return false;
}
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLOR));
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA,
GL_UNSIGNED_BYTE, null);
gl4.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE));
gl4.glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureName.get(Texture.COLOR), 0);
if (!isFramebufferComplete(gl4, framebufferName.get(Framebuffer.RESOLVE))) {
return false;
}
gl4.glBindFramebuffer(GL_FRAMEBUFFER, 0);
return true;
}
示例10: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glGenTextures(Texture.MAX, textureName);
for (int i = Texture.R; i <= Texture.B; ++i) {
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(i));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
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.glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA8,
windowSize.x / FRAMEBUFFER_FACTOR,
windowSize.y / FRAMEBUFFER_FACTOR,
0,
GL_RGB, GL_UNSIGNED_BYTE,
null);
}
return checkError(gl4, "initTexture");
}
示例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));
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_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
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);
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexImage2D(GL_TEXTURE_2D, level,
format.internal.value,
texture.dimensions(level)[0], texture.dimensions(level)[1],
0,
format.external.value, format.type.value,
texture.data(level));
}
gl4.glGenerateMipmap(GL_TEXTURE_2D);
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
} catch (IOException ex) {
Logger.getLogger(Gl_410_glsl_block.class.getName()).log(Level.SEVERE, null, ex);
}
return checkError(gl4, "initTexture");
}
示例12: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
boolean validated = true;
try {
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl4.glGenTextures(Texture.MAX, textureName);
jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE));
assert (!texture.empty());
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
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);
// Set image
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexImage2D(GL_TEXTURE_2D, level,
format.internal.value,
texture.dimensions(level)[0], texture.dimensions(level)[1],
0,
format.external.value, format.type.value,
texture.data(level));
}
// Allocate texture storage of texture::COPY.
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COPY));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
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);
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexImage2D(GL_TEXTURE_2D, level,
format.internal.value,
texture.dimensions(level)[0], texture.dimensions(level)[1],
0,
format.external.value, format.type.value,
null);
}
gl4.glBindTexture(GL_TEXTURE_2D, 0);
// Fill texture data of texture::COPY from texture::DIFFUSE.
for (int level = 0; level < texture.levels(); ++level) {
gl4.glCopyImageSubData(
textureName.get(Texture.DIFFUSE), GL_TEXTURE_2D, level, 0, 0, 0,
textureName.get(Texture.COPY), GL_TEXTURE_2D, level, 0, 0, 0,
texture.dimensions(level)[0], texture.dimensions(level)[1], 1);
}
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
} catch (IOException ex) {
Logger.getLogger(Gl_430_texture_copy.class.getName()).log(Level.SEVERE, null, ex);
}
return validated;
}
示例13: initTexture
import com.jogamp.opengl.GL4; //导入方法依赖的package包/类
private boolean initTexture(GL4 gl4) {
boolean validated = true;
int[] textureSize = {128, 128};
jgli.Texture2d texture = new Texture2d(jgli.Format.FORMAT_RGBA8_UNORM_PACK32, textureSize);
texture.clear(0, 0, 0, new byte[]{(byte) 255, (byte) 0, (byte) 0, (byte) 255});
texture.clear(0, 0, 1, new byte[]{(byte) 255, (byte) 128, (byte) 0, (byte) 255});
texture.clear(0, 0, 2, new byte[]{(byte) 0, (byte) 255, (byte) 0, (byte) 255});
texture.clear(0, 0, 3, new byte[]{(byte) 0, (byte) 255, (byte) 0, (byte) 255});
texture.clear(0, 0, 4, new byte[]{(byte) 0, (byte) 255, (byte) 255, (byte) 255});
texture.clear(0, 0, 5, new byte[]{(byte) 0, (byte) 0, (byte) 255, (byte) 255});
texture.clear(0, 0, 6, new byte[]{(byte) 255, (byte) 0, (byte) 255, (byte) 255});
texture.clear(0, 0, 7, new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255});
assert (!texture.empty());
jgli.Gl.Format format = jgli.Gl.translate(texture.format());
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl4.glGenTextures(Texture.MAX, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 2);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
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_SWIZZLE_R, GL_BLUE);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
for (int level = 0; level < texture.levels(); ++level) {
gl4.glTexImage2D(GL_TEXTURE_2D, level,
format.internal.value,
texture.dimensions(level)[0], texture.dimensions(level)[1],
0,
format.external.value, format.type.value,
texture.data(level));
}
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE, 0,
GL_RGBA, GL_UNSIGNED_BYTE, null);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RENDERBUFFER));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, windowSize.x / FRAMEBUFFER_SIZE,
windowSize.y / FRAMEBUFFER_SIZE, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null);
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
return validated;
}
示例14: 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));
assert (!texture.empty());
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
gl4.glGenTextures(Texture.MAX, textureName);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE));
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_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
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);
for (int level = 0; level < texture.levels(); ++level) {
gl4.glCompressedTexImage2D(
GL_TEXTURE_2D,
level,
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
texture.dimensions(level)[0],
texture.dimensions(level)[1],
0,
texture.size(level),
texture.data(level));
}
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER));
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, windowSize.x, windowSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, null);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RENDERBUFFER));
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_DEPTH_COMPONENT24, windowSize.x, windowSize.y, 0, GL_DEPTH_COMPONENT,
GL_FLOAT, null);
gl4.glActiveTexture(GL_TEXTURE0);
gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.SHADOWMAP));
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
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_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
gl4.glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, shadowSize.x, shadowSize.y, 0, GL_DEPTH_COMPONENT,
GL_FLOAT, null);
gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
} catch (IOException ex) {
Logger.getLogger(Gl_400_fbo_shadow.class.getName()).log(Level.SEVERE, null, ex);
}
return checkError(gl4, "initTexture");
}