Java Code Examples for com.jogamp.opengl.GL3#glTexParameteri()
The following examples show how to use
com.jogamp.opengl.GL3#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_320_fbo_rtt_texture_array.java From jogl-samples with MIT License | 6 votes |
private boolean initTexture(GL3 gl3) { gl3.glActiveTexture(GL_TEXTURE0); gl3.glGenTextures(1, textureName); gl3.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, windowSize.x / FRAMEBUFFER_SIZE, windowSize.y / FRAMEBUFFER_SIZE, 3,//depth 0, GL_BGR, GL_UNSIGNED_BYTE, null); return checkError(gl3, "initTexture"); }
Example 2
Source File: Gl_300_fbo_multisample.java From jogl-samples with MIT License | 6 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture texture = Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE); gl3.glGenTextures(Texture.MAX, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); jgli.Gl.Format glFormat = Gl.translate(texture.format()); for (int level = 0; level < texture.levels(); level++) { gl3.glTexImage2D(GL_TEXTURE_2D, level, glFormat.internal.value, texture.dimensions(level)[0], texture.dimensions(level)[1], 0, glFormat.external.value, glFormat.type.value, texture.data(level)); } } catch (IOException ex) { Logger.getLogger(Gl_300_fbo_multisample.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl3, "initTexture"); }
Example 3
Source File: Gl_320_fbo_blend_points.java From jogl-samples with MIT License | 6 votes |
private boolean initTexture(GL3 gl3) { boolean validated = true; Vec2i windowSize_ = windowSize.mul_(framebufferScale); gl3.glGenTextures(Texture.MAX, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8, windowSize_.x, windowSize_.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); return validated; }
Example 4
Source File: Gl_320_sync.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL3 gl3) { try { gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl3.glGenTextures(1, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); assert (!texture.empty()); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); for (int level = 0; level < texture.levels(); ++level) { gl3.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)); } gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_320_sync.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 5
Source File: GLTools.java From constellation with Apache License 2.0 | 5 votes |
/** * Load a BufferedImage array into a texture array. * <p> * Each BufferedImage must be of type BufferedImage.TYPE_4BYTE_ABGR. The * images will be loaded at 0,0 at each level of the texture array. * <p> * It appears that the images must have a row length that is a multiple of * four. This is probably due to the particular format we're using, and * could probably be worked around, but the simple fix is to check your row * length. * * @param gl the current OpenGL context. * @param textureName The name of the texture to bind to with BindTexture(). * @param images A List of BufferedImages of type * BufferedImage.TYPE_4BYTE_ABGR. * @param maxWidth The maximum width of the images. * @param maxHeight The maximum height of the images. * @param minFilter Texture selection with TEXTURE_MIN_FILTER. * @param magFilter Texture selection with TEXTURE_MAG_FILTER. * @param wrapMode texture wrap mode with TEXTURE_WRAP_S and TEXTURE_WRAP_T. */ public static void loadTextures(final GL3 gl, final int textureName, final List<BufferedImage> images, final int maxWidth, final int maxHeight, final int minFilter, final int magFilter, final int wrapMode) { gl.glBindTexture(GL3.GL_TEXTURE_2D_ARRAY, textureName); gl.glTexParameteri(GL3.GL_TEXTURE_2D_ARRAY, GL3.GL_TEXTURE_WRAP_S, wrapMode); gl.glTexParameteri(GL3.GL_TEXTURE_2D_ARRAY, GL3.GL_TEXTURE_WRAP_T, wrapMode); gl.glTexParameteri(GL3.GL_TEXTURE_2D_ARRAY, GL3.GL_TEXTURE_MIN_FILTER, minFilter); gl.glTexParameteri(GL3.GL_TEXTURE_2D_ARRAY, GL3.GL_TEXTURE_MAG_FILTER, magFilter); // Call glTexImage3D() to create the buffer here: we've assumed the internalformat and format. gl.glTexImage3D(GL3.GL_TEXTURE_2D_ARRAY, 0, GL.GL_RGBA, maxWidth, maxHeight, images.size(), 0, GL.GL_RGBA, GL3.GL_UNSIGNED_BYTE, null); int i = 0; for (BufferedImage image : images) { try { final TextureData data = AWTTextureIO.newTextureData(gl.getGLProfile(), image, false); if (data.getWidth() > maxWidth || data.getHeight() > maxHeight) { throw new RenderException(String.format("Image %d is too large", i)); } // Images are always placed at 0,0. final int xoffset = 0; final int yoffset = 0; final int zoffset = i; gl.glTexSubImage3D(GL3.GL_TEXTURE_2D_ARRAY, 0, xoffset, yoffset, zoffset, data.getWidth(), data.getHeight(), 1, data.getPixelFormat(), GL3.GL_UNSIGNED_BYTE, data.getBuffer()); data.destroy(); } catch (final RuntimeException ex) { LOGGER.log(Level.SEVERE, null, ex); } i++; } }
Example 6
Source File: Gl_320_primitive_sprite.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL3 gl3) { try { gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl3.glGenTextures(1, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); assert (!texture.empty()); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); for (int level = 0; level < texture.levels(); ++level) { gl3.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)); } gl3.glGenerateMipmap(GL_TEXTURE_2D); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_320_primitive_sprite.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 7
Source File: Gl_300_fbo_multisample.java From jogl-samples with MIT License | 5 votes |
private boolean initFramebuffer(GL3 gl3) { gl3.glGenRenderbuffers(1, colorRenderbufferName); gl3.glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbufferName.get(0)); // The second parameter is the number of samples. gl3.glRenderbufferStorageMultisample(GL_RENDERBUFFER, 8, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y); gl3.glGenFramebuffers(Framebuffer.MAX, framebufferName); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RENDER)); gl3.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbufferName.get(0)); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RENDER))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RESOLVE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebufferName.get(Framebuffer.RESOLVE)); gl3.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureName.get(Texture.RESOLVE), 0); if (!isFramebufferComplete(gl3, framebufferName.get(Framebuffer.RESOLVE))) { return false; } gl3.glBindFramebuffer(GL_FRAMEBUFFER, 0); return checkError(gl3, "initFramebuffer"); }
Example 8
Source File: Gl_330_sampler_object.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); gl3.glGenTextures(1, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA); for (int level = 0; level < texture.levels(); ++level) { gl3.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)); } gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, 0); } catch (IOException ex) { Logger.getLogger(Gl_330_sampler_object.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 9
Source File: Gl_330_blend_index.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); jgli.Gl.Swizzles swizzles = jgli.Gl.translate(texture.swizzles()); gl3.glGenTextures(1, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, swizzles.r.value); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, swizzles.g.value); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, swizzles.b.value); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, swizzles.a.value); for (int level = 0; level < texture.levels(); ++level) { gl3.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_330_blend_index.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl3, "initTexture"); }
Example 10
Source File: Gl_330_texture_integer_rgb10a2ui.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); if (texture.empty()) { return false; } jgli.Gl.Format format = jgli.Gl.translate(texture.format()); gl3.glGenTextures(1, textureName); // Default unpack alignment of 4 is ok, we have 32 bit per pixel. gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage2D(GL_TEXTURE_2D, 0, format.internal.value, // Gl.InternalFormat.INTERNAL_RGB10A2U.value, texture.dimensions(0)[0], texture.dimensions(0)[1], 0, format.external.value, // Gl.ExternalFormat.EXTERNAL_RGBA_INTEGER.value, // format.type.value, GL_UNSIGNED_INT_10_10_10_2, texture.data(0)); } catch (IOException ex) { Logger.getLogger(Gl_330_texture_integer_rgb10a2ui.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 11
Source File: Gl_320_texture_offset.java From jogl-samples with MIT License | 5 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); gl3.glGenTextures(1, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); for (int level = 0; level < texture.levels(); ++level) { gl3.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_320_texture_offset.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 12
Source File: GraphDisplayer.java From constellation with Apache License 2.0 | 4 votes |
@Override public void init(GLAutoDrawable drawable) { final GL3 gl = drawable.getGL().getGL3(); String graphVp = null; String graphFp = null; try { graphVp = getVertexShader(); graphFp = getFragmentShader(); } catch (final IOException ex) { LOGGER.log(Level.SEVERE, "Can''t read graph texture shaders", ex); } graphTextureShader = GLTools.loadShaderSourceWithAttributes(gl, "graphTex", graphVp, null, graphFp, vertexTarget, "position", textureCoordinatesTarget, "inputTextureCoordinates", ShaderManager.FRAG_BASE, "fragColor"); graphTextureBatch.initialise(GRAPH_TEXTURE_NUMBER_OF_VERTICES); graphTextureBatch.stage(vertexTarget, -1f, -1f); graphTextureBatch.stage(vertexTarget, 1f, -1f); graphTextureBatch.stage(vertexTarget, -1f, 1f); graphTextureBatch.stage(vertexTarget, 1f, 1f); graphTextureBatch.stage(textureCoordinatesTarget, 0f, 0f); graphTextureBatch.stage(textureCoordinatesTarget, 1f, 0f); graphTextureBatch.stage(textureCoordinatesTarget, 0f, 1f); graphTextureBatch.stage(textureCoordinatesTarget, 1f, 1f); graphTextureBatch.finalise(gl); // Create the FBO to draw the graph onto. gl.glGenFramebuffers(1, graphFboName, 0); gl.glBindFramebuffer(GL3.GL_DRAW_FRAMEBUFFER, graphFboName[0]); // Create a texture for colour information. gl.glGenTextures(1, graphColorTextureName, 0); gl.glBindTexture(GL3.GL_TEXTURE_2D, graphColorTextureName[0]); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA8, 10, 10, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, null); gl.glFramebufferTexture(GL3.GL_DRAW_FRAMEBUFFER, GL3.GL_COLOR_ATTACHMENT0, graphColorTextureName[0], 0); graphDrawBuffers[0] = GL3.GL_COLOR_ATTACHMENT0; // Create a texture for depth information and attach it. gl.glGenTextures(1, graphDepthTextureName, 0); gl.glBindTexture(GL3.GL_TEXTURE_2D, graphDepthTextureName[0]); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT16, 10, 10, 0, GL3.GL_DEPTH_COMPONENT, GL.GL_FLOAT, null); gl.glFramebufferTexture(GL3.GL_DRAW_FRAMEBUFFER, GL3.GL_DEPTH_ATTACHMENT, graphDepthTextureName[0], 0); graphColorTextureShaderLocation = gl.glGetUniformLocation(graphTextureShader, "graphTexture"); graphDepthTextureShaderLocation = gl.glGetUniformLocation(graphTextureShader, "depthTexture"); createShaderLocations(gl); }
Example 13
Source File: Gl_320_fbo_srgb_blend.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { boolean validated = true; try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); assert (!texture.empty()); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl3.glGenTextures(Texture.MAX, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl3.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) { gl3.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)); } gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, windowSize.x * framebufferScale, windowSize.y * framebufferScale, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_320_fbo_srgb_blend.class.getName()).log(Level.SEVERE, null, ex); } return validated; }
Example 14
Source File: Gl_320_texture_streaming.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl3.glGenTextures(1, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage2D(GL_TEXTURE_2D, 0, format.internal.value, texture.dimensions()[0], texture.dimensions()[1], 0, format.external.value, format.type.value, null); int textureSize = texture.size(0); int[] pixelBuffer = {0}; gl3.glGenBuffers(1, pixelBuffer, 0); gl3.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixelBuffer[0]); gl3.glBufferData(GL_PIXEL_UNPACK_BUFFER, textureSize, null, GL_STREAM_DRAW); ByteBuffer pointer = gl3.glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, textureSize, GL_MAP_WRITE_BIT); pointer.put(texture.data(0)).rewind(); gl3.glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); gl3.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture.dimensions()[0], texture.dimensions()[1], format.external.value, format.type.value, 0); gl3.glDeleteBuffers(1, pixelBuffer, 0); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_320_texture_streaming.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 15
Source File: Gl_320_fbo_integer.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); gl3.glGenTextures(Texture.MAX, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); jgli.Gl.Format format = jgli.Gl.translate(jgli.Format.FORMAT_RGB8_UINT_PACK8); for (int level = 0; level < texture.levels(); level++) { gl3.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)); } gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); gl3.glBindTexture(GL_TEXTURE_2D, 0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RENDERBUFFER)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, windowSize.x / framebufferSize, windowSize.y / framebufferSize, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, null); gl3.glBindTexture(GL_TEXTURE_2D, 0); } catch (IOException ex) { Logger.getLogger(Gl_320_fbo_integer_blit.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl3, "initTexture"); }
Example 16
Source File: Gl_320_fbo_blit.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); gl3.glGenTextures(Texture.MAX, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); for (int level = 0; level < texture.levels(); level++) { gl3.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)); } gl3.glGenerateMipmap(GL_TEXTURE_2D); // Allocate all mipmaps memory gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); gl3.glBindTexture(GL_TEXTURE_2D, 0); } catch (IOException ex) { Logger.getLogger(Gl_320_fbo_blit.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 17
Source File: Gl_320_fbo_multisample_explicit.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); gl3.glGenTextures(Texture.MAX, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); for (int level = 0; level < texture.levels(); level++) { gl3.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)); } gl3.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.MULTISAMPLE_COLORBUFFER)); gl3.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, true); gl3.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.MULTISAMPLE_DEPTHBUFFER)); gl3.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_DEPTH_COMPONENT24, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, true); gl3.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); gl3.glBindTexture(GL_TEXTURE_2D, 0); } catch (IOException ex) { Logger.getLogger(Gl_320_fbo_multisample_explicit.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 18
Source File: Gl_320_texture_lod.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { try { gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl3.glActiveTexture(GL_TEXTURE0); gl3.glGenTextures(Texture.MAX, textureName); jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); { gl3.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.ZERO)); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_LOD, 0.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LOD, 0.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_LOD_BIAS, 4.0f); for (int level = 0; level < texture.levels(); ++level) { gl3.glTexImage3D(GL_TEXTURE_2D_ARRAY, level, format.internal.value, texture.dimensions(level)[0], texture.dimensions(level)[1], 1, 0, format.external.value, format.type.value, texture.data(level)); } } { gl3.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.ONE)); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_LOD, 3.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LOD, 3.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_LOD_BIAS, 0.0f); for (int level = 0; level < texture.levels(); ++level) { gl3.glTexImage3D(GL_TEXTURE_2D_ARRAY, level, format.internal.value, texture.dimensions(level)[0], texture.dimensions(level)[1], 1, 0, format.external.value, format.type.value, texture.data(level)); } } { gl3.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.TWO)); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_LOD, 0.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LOD, 10.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_LOD_BIAS, 4.0f); for (int level = 0; level < texture.levels(); ++level) { gl3.glTexImage3D(GL_TEXTURE_2D_ARRAY, level, format.internal.value, texture.dimensions(level)[0], texture.dimensions(level)[1], 1, 0, format.external.value, format.type.value, texture.data(level)); } } { gl3.glBindTexture(GL_TEXTURE_2D_ARRAY, textureName.get(Texture.THREE)); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_LOD, 0.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAX_LOD, 10.0f); gl3.glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_LOD_BIAS, 3.5f); for (int level = 0; level < texture.levels(); ++level) { gl3.glTexImage3D(GL_TEXTURE_2D_ARRAY, level, format.internal.value, texture.dimensions(level)[0], texture.dimensions(level)[1], 1, 0, format.external.value, format.type.value, texture.data(level)); } } gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D_ARRAY, 0); } catch (IOException ex) { Logger.getLogger(Gl_320_texture_lod.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 19
Source File: Gl_320_fbo_srgb_decode_ext.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { boolean validated = true; try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); assert (!texture.empty()); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); gl3.glGenTextures(Texture.MAX, textureName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texture.levels() - 1); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); for (int level = 0; level < texture.levels(); ++level) { gl3.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)); } gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.COLORBUFFER)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, windowSize.x * framebufferScale, windowSize.y * framebufferScale, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.RENDERBUFFER)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, windowSize.x * framebufferScale, windowSize.y * framebufferScale, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_320_fbo_srgb_decode_ext.class.getName()).log(Level.SEVERE, null, ex); } return validated; }
Example 20
Source File: Gl_330_blend_rtt.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { try { jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); gl3.glActiveTexture(GL_TEXTURE0); gl3.glGenTextures(Texture.MAX, texture2dName); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(Texture.RGB8)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage2D(GL_TEXTURE_2D, 0, format.internal.value, texture.dimensions()[0], texture.dimensions()[1], 0, format.external.value, format.type.value, texture.data()); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(Texture.R)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ZERO); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ZERO); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ZERO); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(Texture.G)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ZERO); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_RED); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_ZERO); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ZERO); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(Texture.B)); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_ZERO); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_ZERO); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ZERO); for (int i = Texture.R; i <= Texture.B; ++i) { gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(i)); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, texture.dimensions()[0], texture.dimensions()[1], 0, GL_RGB, GL_UNSIGNED_BYTE, null); } } catch (IOException ex) { Logger.getLogger(Gl_330_blend_rtt.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl3, "initTexture"); }