Java Code Examples for com.jogamp.opengl.GL3#glBindTexture()
The following examples show how to use
com.jogamp.opengl.GL3#glBindTexture() .
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_300_test_alpha.java From jogl-samples with MIT License | 6 votes |
private boolean initTexture(GL3 gl3) { try { gl3.glGenTextures(1, texture2dName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.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)); 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)); } } catch (IOException ex) { Logger.getLogger(Gl_300_test_alpha.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl3, "initTexture"); }
Example 2
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 3
Source File: Gl_320_primitive_line_msaa.java From jogl-samples with MIT License | 6 votes |
private boolean initTexture(GL3 gl3) { boolean validated = true; // Vec2i windowSize_ = windowSize.shiftR(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_NEAREST); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl3.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, windowSize.x >> framebufferScale, windowSize.y >> framebufferScale, 0, GL_RGBA, GL_UNSIGNED_BYTE, null); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureName.get(Texture.RENDERBUFFER)); //glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, 0); //glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LEVEL, 0); gl3.glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGBA8, windowSize.x >> framebufferScale, windowSize.y >> framebufferScale, true); return validated; }
Example 4
Source File: Gl_320_fbo_multisample_integer.java From jogl-samples with MIT License | 6 votes |
private void renderFBO(GL3 gl3, int framebuffer) { Mat4 projection = glm.ortho_(-1.1f, 1.1f, 1.1f, -1.1f, 1.1f, -1.1f); Mat4 view = new Mat4(1.0f); Mat4 model = new Mat4(1.0f).rotate(-0.3f, new Vec3(0.f, 0.f, 1.f)); Mat4 mvp = projection.mul(view).mul(model); gl3.glUseProgram(programName[Program.RENDER]); gl3.glUniform1i(uniformDiffuse[Program.RENDER], 0); gl3.glUniformMatrix4fv(uniformMvp[Program.RENDER], 1, false, mvp.toFa_(), 0); gl3.glViewport(0, 0, windowSize.x / framebufferSize, windowSize.y / framebufferSize); gl3.glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); gl3.glClearBufferuiv(GL_COLOR, 0, new int[]{0, 128, 255, 255}, 0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.DIFFUSE)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1); checkError(gl3, "renderFBO"); }
Example 5
Source File: Gl_300_test_alpha.java From jogl-samples with MIT License | 6 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glClearColor(1.0f, 0.5f, 0.0f, 1.0f); gl3.glClear(GL_COLOR_BUFFER_BIT); gl3.glUseProgram(programName); gl3.glUniform1i(uniformDiffuse, 0); gl3.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArrays(GL_TRIANGLES, 0, vertexCount); return true; }
Example 6
Source File: Gl_320_glsl_precision.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; { gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl3.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glClearBufferfv(GL_COLOR, 0, clearColor); gl3.glUseProgram(programName); gl3.glUniform1i(uniformDiffuse, 0); gl3.glUniformBlockBinding(programName, uniformTransform, Semantic.Uniform.TRANSFORM0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl3.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0); return true; }
Example 7
Source File: Gl_320_texture_fetch.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; { gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl3.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl3.glViewport(0, 0, windowSize.x, windowSize.y); clearColor.put(new float[]{0.0f, 0.5f, 1.0f, 1.0f}).rewind(); gl3.glClearBufferfv(GL_COLOR, 0, clearColor); // Bind the program for use gl3.glUseProgram(programName); gl3.glUniform1i(uniformDiffuse, 0); gl3.glUniformBlockBinding(programName, uniformTransform, Semantic.Uniform.TRANSFORM0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1); return true; }
Example 8
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 9
Source File: Gl_300_fbo_multisample.java From jogl-samples with MIT License | 5 votes |
private void renderFB(GL3 gl3, int texture2dName) { Mat4 perspective = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = perspective.mul(viewMat4()).mul(model); gl3.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArrays(GL_TRIANGLES, 0, vertexCount); checkError(gl3, "renderFB"); }
Example 10
Source File: Gl_330_sampler_wrap.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, (float) windowSize.x / windowSize.y, 0.1f, 1000.0f); Mat4 model = new Mat4(1.0f); Mat4 mvp = projection.mul(viewMat4()).mul(model); gl3.glClearBufferfv(GL_COLOR, 0, clearColor.put(0, 1).put(1, .5f).put(2, 0).put(3, 1)); gl3.glUseProgram(programName); gl3.glUniformMatrix4fv(uniformMvp, 1, false, mvp.toFa_(), 0); gl3.glUniform1i(uniformDiffuse, 0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); for (int Index = 0; Index < Viewport.MAX; ++Index) { gl3.glViewport(viewport[Index].x, viewport[Index].y, viewport[Index].z, viewport[Index].w); gl3.glBindSampler(0, samplerName.get(Index)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, vertexCount, 1); } return true; }
Example 11
Source File: Gl_320_texture_integer.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)); 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_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); for (int level = 0; level < texture.levels(); ++level) { // TODO fix format gl3.glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8UI, // TODO -A? texture.dimensions(level)[0], texture.dimensions(level)[1], 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, texture.data(level)); } gl3.glGenerateMipmap(GL_TEXTURE_2D); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); } catch (IOException ex) { Logger.getLogger(Gl_320_texture_integer.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl3, "initTexture"); }
Example 12
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 13
Source File: Gl_320_texture_pixel_store.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)); jgli.Gl.Format format = jgli.Gl.translate(texture.format()); // Setup the pixel storage to load only a rectangle in the middle of the source texture gl3.glPixelStorei(GL_UNPACK_ROW_LENGTH, texture.dimensions()[0]); gl3.glPixelStorei(GL_UNPACK_SKIP_PIXELS, texture.dimensions()[0] / 4); gl3.glPixelStorei(GL_UNPACK_SKIP_ROWS, texture.dimensions()[1] / 4); gl3.glTexImage2D(GL_TEXTURE_2D, 0, format.internal.value, texture.dimensions()[0] / 2, texture.dimensions()[1] / 2, 0, format.external.value, format.type.value, texture.data()); gl3.glPixelStorei(GL_UNPACK_ALIGNMENT, 4); gl3.glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); gl3.glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); gl3.glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); } catch (IOException ex) { Logger.getLogger(Gl_320_texture_pixel_store.class.getName()).log(Level.SEVERE, null, ex); } return true; }
Example 14
Source File: Gl_320_glsl_input_struct.java From jogl-samples with MIT License | 5 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; { gl3.glBindBuffer(GL_UNIFORM_BUFFER, bufferName.get(Buffer.TRANSFORM)); ByteBuffer pointer = gl3.glMapBufferRange( GL_UNIFORM_BUFFER, 0, Mat4.SIZE, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); Mat4 projection = glm.perspective_((float) Math.PI * 0.25f, 4.0f / 3.0f, 0.1f, 100.0f); Mat4 model = new Mat4(1.0f); pointer.asFloatBuffer().put(projection.mul(viewMat4()).mul(model).toFa_()); // Make sure the uniform buffer is uploaded gl3.glUnmapBuffer(GL_UNIFORM_BUFFER); } gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glClearBufferfv(GL_COLOR, 0, clearColor); gl3.glUseProgram(programName); gl3.glUniform1i(uniformDiffuse, 0); gl3.glUniformBlockBinding(programName, uniformTransform, Semantic.Uniform.TRANSFORM0); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glBindBufferBase(GL_UNIFORM_BUFFER, Semantic.Uniform.TRANSFORM0, bufferName.get(Buffer.TRANSFORM)); gl3.glDrawElementsInstancedBaseVertex(GL_TRIANGLES, elementCount, GL_UNSIGNED_SHORT, 0, 1, 0); return true; }
Example 15
Source File: GraphDisplayer.java From constellation with Apache License 2.0 | 5 votes |
/** * Called by the {@link GraphRenderable} using this graph display to bind to * this displayer's buffers so that the graph is drawn onto these buffers * rather than directly onto the screen buffers. * * @param gl The GL Context on which to bind to this displayer's buffers. */ final void bindDisplayer(final GL3 gl) { gl.glBindFramebuffer(GL3.GL_DRAW_FRAMEBUFFER, graphFboName[0]); gl.glDrawBuffers(1, graphDrawBuffers, 0); if (needsResize) { gl.glActiveTexture(GL3.GL_TEXTURE0); gl.glBindTexture(GL3.GL_TEXTURE_2D, graphColorTextureName[0]); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB8, width, height, 0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, null); gl.glActiveTexture(GL3.GL_TEXTURE0 + 1); gl.glBindTexture(GL3.GL_TEXTURE_2D, graphDepthTextureName[0]); gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT16, width, height, 0, GL3.GL_DEPTH_COMPONENT, GL.GL_FLOAT, null); needsResize = false; } }
Example 16
Source File: Gl_320_fbo_integer_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, 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); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(Texture.SPLASHBUFFER)); 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.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); gl3.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); 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 17
Source File: GlyphManagerOpenGLController.java From constellation with Apache License 2.0 | 4 votes |
private void bindGlyphs(GL3 gl, int uniformLocation, int textureUnit) { gl.glUniform1i(uniformLocation, textureUnit); gl.glActiveTexture(GL3.GL_TEXTURE0 + textureUnit); gl.glBindTexture(GL3.GL_TEXTURE_2D_ARRAY, glyphsTextureName[0]); }
Example 18
Source File: GlyphManagerOpenGLController.java From constellation with Apache License 2.0 | 4 votes |
private void bindCoordinates(GL3 gl, int uniformLocation, int textureUnit) { gl.glActiveTexture(GL3.GL_TEXTURE0 + textureUnit); gl.glBindTexture(GL3.GL_TEXTURE_BUFFER, coordinatesTextureName[0]); gl.glUniform1i(uniformLocation, textureUnit); }
Example 19
Source File: Gl_330_texture_swizzle.java From jogl-samples with MIT License | 4 votes |
private boolean initTexture(GL3 gl3) { try { gl3.glGenTextures(1, texture2dName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, texture2dName.get(0)); jgli.Texture2d texture = new Texture2d(jgli.Load.load(TEXTURE_ROOT + "/" + TEXTURE_DIFFUSE)); for (int level = 0; level < texture.levels(); ++level) { gl3.glCompressedTexImage2D( GL_TEXTURE_2D, level, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, texture.dimensions(level)[0], texture.dimensions(level)[1], 0, texture.size(level), texture.data(level)); } swizzleR[Viewport.V00] = GL_RED; swizzleG[Viewport.V00] = GL_GREEN; swizzleB[Viewport.V00] = GL_BLUE; swizzleA[Viewport.V00] = GL_ALPHA; swizzleR[Viewport.V10] = GL_BLUE; swizzleG[Viewport.V10] = GL_GREEN; swizzleB[Viewport.V10] = GL_RED; swizzleA[Viewport.V10] = GL_ALPHA; swizzleR[Viewport.V11] = GL_ONE; swizzleG[Viewport.V11] = GL_GREEN; swizzleB[Viewport.V11] = GL_BLUE; swizzleA[Viewport.V11] = GL_ALPHA; swizzleR[Viewport.V01] = GL_ZERO; swizzleG[Viewport.V01] = GL_GREEN; swizzleB[Viewport.V01] = GL_BLUE; swizzleA[Viewport.V01] = GL_ALPHA; gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, 0); } catch (IOException ex) { Logger.getLogger(Gl_330_texture_swizzle.class.getName()).log(Level.SEVERE, null, ex); } return checkError(gl3, "initTexture"); }
Example 20
Source File: Gl_320_draw_image_space.java From jogl-samples with MIT License | 4 votes |
@Override protected boolean render(GL gl) { GL3 gl3 = (GL3) gl; gl3.glViewport(0, 0, windowSize.x, windowSize.y); gl3.glUseProgram(programName); gl3.glActiveTexture(GL_TEXTURE0); gl3.glBindTexture(GL_TEXTURE_2D, textureName.get(0)); gl3.glBindVertexArray(vertexArrayName.get(0)); gl3.glDrawArraysInstanced(GL_TRIANGLES, 0, 3, 1); return true; }