Java Code Examples for com.jogamp.opengl.GL4#glTexParameteri()
The following examples show how to use
com.jogamp.opengl.GL4#glTexParameteri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Gl_400_blend_rtt.java From jogl-samples with MIT License | 6 votes |
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; }
Example 2
Source File: Gl_410_glsl_block.java From jogl-samples with MIT License | 5 votes |
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"); }
Example 3
Source File: TextureManager.java From plugins with GNU General Public License v3.0 | 5 votes |
int initTextureArray(TextureProvider textureProvider, GL4 gl) { if (!allTexturesLoaded(textureProvider)) { return -1; } Texture[] textures = textureProvider.getTextures(); int textureArrayId = GLUtil.glGenTexture(gl); gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, textureArrayId); gl.glTexStorage3D(gl.GL_TEXTURE_2D_ARRAY, 1, gl.GL_RGBA8, TEXTURE_SIZE, TEXTURE_SIZE, textures.length); gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST); gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST); gl.glTexParameteri(gl.GL_TEXTURE_2D_ARRAY, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE); // Set brightness to 1.0d to upload unmodified textures to GPU double save = textureProvider.getBrightness(); textureProvider.setBrightness(1.0d); updateTextures(textureProvider, gl, textureArrayId); textureProvider.setBrightness(save); gl.glActiveTexture(gl.GL_TEXTURE1); gl.glBindTexture(gl.GL_TEXTURE_2D_ARRAY, textureArrayId); gl.glActiveTexture(gl.GL_TEXTURE0); return textureArrayId; }
Example 4
Source File: Gl_400_sampler_fetch.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL4 gl4) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); 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_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); 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); for (int level = 0; level < texture.levels(); ++level) { gl4.glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, level, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, texture.dimensions(level)[0], texture.dimensions(level)[1], 1, 0, texture.size(level), texture.data(level)); } } catch (IOException ex) { Logger.getLogger(Gl_400_sampler_fetch.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl4, "initTexture"); }
Example 5
Source File: Gl_500_texture_cube_arb.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL4 gl4) { jgli.TextureCube texture = new TextureCube(jgli.Format.FORMAT_RGBA8_UNORM_PACK8, new int[]{2, 2}, 1); assert (!texture.empty()); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); texture.clearFace(0, new byte[]{(byte) 255, (byte) 0, (byte) 0, (byte) 255}); texture.clearFace(1, new byte[]{(byte) 255, (byte) 128, (byte) 0, (byte) 255}); texture.clearFace(2, new byte[]{(byte) 255, (byte) 255, (byte) 0, (byte) 255}); texture.clearFace(3, new byte[]{(byte) 0, (byte) 255, (byte) 0, (byte) 255}); texture.clearFace(4, new byte[]{(byte) 0, (byte) 255, (byte) 255, (byte) 255}); texture.clearFace(5, new byte[]{(byte) 0, (byte) 0, (byte) 255, (byte) 255}); 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); gl4.glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY, texture.levels(), format.internal.value, texture.dimensions()[0], texture.dimensions()[1], texture.faces()); gl4.glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, 0, 0, 0, texture.dimensions()[0], texture.dimensions()[1], texture.faces(), format.external.value, format.type.value, texture.data()); return true; }
Example 6
Source File: Gl_430_program_compute.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL4 gl4) { try { 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.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_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_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.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)); } gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_430_program_compute.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 7
Source File: Gl_440_buffer_storage.java From jogl-samples with MIT License | 5 votes |
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_440_buffer_storage.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 8
Source File: Gl_400_texture_cube.java From jogl-samples with MIT License | 5 votes |
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; }
Example 9
Source File: Gl_450_fbo_multisample_explicit.java From jogl-samples with MIT License | 5 votes |
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; }
Example 10
Source File: Gl_420_texture_conversion.java From jogl-samples with MIT License | 5 votes |
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); for (int i = 0; i < Texture.MAX; ++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, 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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), textureInternalFormat[i], texture.dimensions(0)[0], texture.dimensions(0)[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], textureFormat[i], GL_UNSIGNED_BYTE, texture.data(level)); } } gl4.glBindTexture(GL_TEXTURE_2D, 0); gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_420_texture_conversion.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 11
Source File: Gl_430_draw_without_vertex_attrib.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL4 gl4) { try { 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.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_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_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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), format.internal.value, texture.dimensions(0)[0], texture.dimensions(0)[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)); } gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_430_draw_without_vertex_attrib.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 12
Source File: Gl_450_texture_derivative.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL4 gl4) { jgli.Texture2d texture = new Texture2d(jgli.Format.FORMAT_RGBA8_UNORM_PACK8, new int[]{64, 64}); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); 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) 255, (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) 0, (byte) 255}); 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_NEAREST_MIPMAP_LINEAR); 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); 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.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)); } if (texture.levels() == 1) { gl4.glGenerateMipmap(GL_TEXTURE_2D); } gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); return true; }
Example 13
Source File: Gl_450_texture_barrier.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL4 gl4) { boolean validated = true; try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); assert (!texture.empty()); gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl4.glGenTextures(Texture.MAX, textureName); 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_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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), format.internal.value, texture.dimensions()[0], texture.dimensions()[1]); for (int level = 0; level < texture.levels(); ++level) { gl4.glCompressedTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, texture.dimensions(level)[0], texture.dimensions(level)[1], format.internal.value, texture.size(level), texture.data(level)); } 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.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, windowSize.x, windowSize.y); gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_450_texture_barrier.class.getName()).log(Level.SEVERE, null, ex); } return validated; }
Example 14
Source File: Gl_500_multi_draw_indirect_count_arb.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL4 gl4) { try { 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.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl4.glGenTextures(Texture.MAX, textureName, 0); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName[Texture.A]); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.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)); } gl4.glBindTexture(GL_TEXTURE_2D, textureName[Texture.B]); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.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)); } gl4.glBindTexture(GL_TEXTURE_2D, textureName[Texture.C]); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_NONE); 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_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.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)); } gl4.glBindTexture(GL_TEXTURE_2D, 0); gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_500_multi_draw_indirect_arb.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 15
Source File: Gl_430_program_compute_variable_group_size.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL4 gl4) { try { 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.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl4.glGenTextures(Texture.MAX, textureName); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.INPUT)); 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_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.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)); } gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.OUTPUT)); gl4.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, texture.dimensions()[0], texture.dimensions()[1]); textureSize = new Vec2i(texture.dimensions()[0], texture.dimensions()[1]); } catch (IOException ex) { Logger.getLogger(Gl_430_program_compute.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 16
Source File: Gl_420_picking.java From jogl-samples with MIT License | 4 votes |
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.glGenTextures(Texture.MAX, textureName); // Diffuse { gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); 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_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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), format.internal.value, texture.dimensions(0)[0], texture.dimensions(0)[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)); } gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } // Piking { gl4.glBindTexture(GL_TEXTURE_BUFFER, textureName.get(Texture.PICKING)); gl4.glTexBuffer(GL_TEXTURE_BUFFER, GL_R32F, bufferName.get(Buffer.PICKING)); gl4.glBindTexture(GL_TEXTURE_BUFFER, 0); } } catch (IOException ex) { Logger.getLogger(Gl_420_picking.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 17
Source File: Gl_400_fbo_shadow.java From jogl-samples with MIT License | 4 votes |
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"); }
Example 18
Source File: Gl_440_multi_draw_indirect_id_arb.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL4 gl4) { boolean validated = true; 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.A)); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), GL_RGBA8, 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], GL_BGR, GL_UNSIGNED_BYTE, texture.data(level)); } /////////////////////////////////////////// gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.B)); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), GL_RGBA8, 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], GL_BGR, GL_UNSIGNED_BYTE, texture.data(level)); } /////////////////////////////////////////// gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.C)); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_NONE); 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_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), GL_RGBA8, 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], GL_BGR, GL_UNSIGNED_BYTE, texture.data(level)); } gl4.glBindTexture(GL_TEXTURE_2D, 0); gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_440_multi_draw_indirect_id_arb.class.getName()).log(Level.SEVERE, null, ex); } return validated; }
Example 19
Source File: Gl_420_fbo.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL4 gl4) { boolean validated = true; 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.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_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.glTexStorage2D(GL_TEXTURE_2D, texture.levels(), GL_COMPRESSED_RGB_S3TC_DXT1_EXT, texture.dimensions()[0], texture.dimensions()[1]); for (int level = 0; level < texture.levels(); ++level) { gl4.glCompressedTexSubImage2D( GL_TEXTURE_2D, level, 0, 0, texture.dimensions(level)[0], texture.dimensions(level)[1], GL_COMPRESSED_RGB_S3TC_DXT1_EXT, texture.size(level), texture.data(level)); } 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.glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, windowSize.x, windowSize.y); 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.glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH_COMPONENT24, windowSize.x, windowSize.y); gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_420_fbo.class.getName()).log(Level.SEVERE, null, ex); } return validated; }
Example 20
Source File: Gl_430_multi_draw_indirect.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL4 gl4) { try { 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.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl4.glGenTextures(Texture.MAX, textureName); gl4.glActiveTexture(GL_TEXTURE0); gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.A)); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.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)); } /////////////////////////////////////////// gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.B)); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.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)); } /////////////////////////////////////////// gl4.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.C)); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_NONE); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_NONE); 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_BASE_LEVEL, 0); gl4.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(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.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)); } gl4.glBindTexture(GL_TEXTURE_2D, 0); gl4.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_430_multi_draw_indirect.class.getName()).log(Level.SEVERE, null, ex); } return true; }