List of usage examples for org.lwjgl.opengl EXTTextureFilterAnisotropic GL_TEXTURE_MAX_ANISOTROPY_EXT
int GL_TEXTURE_MAX_ANISOTROPY_EXT
To view the source code for org.lwjgl.opengl EXTTextureFilterAnisotropic GL_TEXTURE_MAX_ANISOTROPY_EXT.
Click Source Link
From source file:cn.org.vbn.Texture2DArrayMipmapping.java
License:Open Source License
private void createTexture() throws IOException { this.tex = glGenTextures(); glBindTexture(GL_TEXTURE_2D_ARRAY, this.tex); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* Add maximum anisotropic filtering, if available */ if (caps.GL_EXT_texture_filter_anisotropic) { glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); float maxAnisotropy = glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); glTexParameterf(GL_TEXTURE_2D_ARRAY, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);// w w w .j a va 2 s. c om } else { glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } File image = new File("E:\\?\\imageJ\\test512\\512_slice20284.tif"); BufferedImage bufferedImage = ImageIO.read(image); ByteBuffer buffer = ByteBuffer.wrap(((DataBufferByte) bufferedImage.getData().getDataBuffer()).getData()); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, texSize, texSize, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, buffer); ByteBuffer bb = BufferUtils.createByteBuffer(3 * texSize * texSize); // int checkSize = 5; /* Generate some checker board pattern */ for (int y = 0; y < texSize; y++) { for (int x = 0; x < texSize; x++) { if (((x / checkSize + y / checkSize) % 2) == 0) { bb.put((byte) 255).put((byte) 255).put((byte) 255); } else { bb.put((byte) 0).put((byte) 0).put((byte) 0); } } } bb.flip(); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, texSize, texSize, 1, GL_RGB, GL_UNSIGNED_BYTE, buffer); /* Generate some diagonal lines for the second layer */ for (int y = 0; y < texSize; y++) { for (int x = 0; x < texSize; x++) { if ((x + y) / 3 % 3 == 0) { bb.put((byte) 255).put((byte) 255).put((byte) 255); } else { bb.put((byte) 0).put((byte) 0).put((byte) 0); } } } bb.flip(); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 1, texSize, texSize, 1, GL_RGB, GL_UNSIGNED_BYTE, buffer); glGenerateMipmap(GL_TEXTURE_2D_ARRAY); glBindTexture(GL_TEXTURE_2D_ARRAY, 0); }
From source file:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java
License:Open Source License
/** * Check if the filter settings of this particular texture have been changed and apply as needed. * //from w ww . j a v a 2s . c o m * @param texture * our texture object * @param texRecord * our record of the last state of the texture in gl * @param record */ public static void applyFilter(final Texture texture, final TextureRecord texRecord, final int unit, final TextureStateRecord record, final ContextCapabilities caps) { final Type type = texture.getType(); final int magFilter = LwjglTextureUtil.getGLMagFilter(texture.getMagnificationFilter()); // set up magnification filter if (!texRecord.isValid() || texRecord.magFilter != magFilter) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(getGLType(type), GL11.GL_TEXTURE_MAG_FILTER, magFilter); texRecord.magFilter = magFilter; } final int minFilter = LwjglTextureUtil.getGLMinFilter(texture.getMinificationFilter()); // set up mipmap filter if (!texRecord.isValid() || texRecord.minFilter != minFilter) { checkAndSetUnit(unit, record, caps); GL11.glTexParameteri(getGLType(type), GL11.GL_TEXTURE_MIN_FILTER, minFilter); texRecord.minFilter = minFilter; } // set up aniso filter if (caps.isAnisoSupported()) { float aniso = texture.getAnisotropicFilterPercent() * (caps.getMaxAnisotropic() - 1.0f); aniso += 1.0f; if (!texRecord.isValid() || (texRecord.anisoLevel - aniso > MathUtils.ZERO_TOLERANCE)) { checkAndSetUnit(unit, record, caps); GL11.glTexParameterf(getGLType(type), EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso); texRecord.anisoLevel = aniso; } } }
From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Texture.java
License:MIT License
@Override public void setAnisotropicFiltering(float value) { checkCreated();/* w ww .j av a 2 s .c om*/ if (value <= 0) { throw new IllegalArgumentException("Anisotropic filtering value must be greater than zero"); } // Bind the texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); // Set the anisotropic filtering value GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, value); // Unbind the texture GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); // Check for errors LWJGLUtil.checkForGLError(); }
From source file:com.xrbpowered.gl.examples.GLBasicTerrain.java
License:Open Source License
@Override protected void setupResources() { super.setupResources(); specular = new Texture("ice2a.jpg"); diffuse = new Texture("ice1a2.jpg"); float anis = GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); System.out.printf("Max anisotropy: %.1f\n", anis); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, anis); normal = new Texture("ice_n.jpg"); createTerrain();/*ww w .j av a 2s .co m*/ water = FastMeshBuilder.plane(64f, 4, 32, StandardShader.standardVertexInfo, null); for (int x = 0; x < 3; x++) for (int y = 0; y < 3; y++) { waterActor[x][y] = StaticMeshActor.make(scene, water, StandardShader.getInstance(), BufferTexture.createPlainColor(4, 4, new Color(0.4f, 0.5f, 0.65f)), plainSpecularTexture, plainNormalTexture); waterActor[x][y].position.set((x - 1) * CHUNK_SIZE, 0f, (y - 1) * CHUNK_SIZE); waterActor[x][y].updateTransform(); } // pickObjects = new StaticMesh[] {null, terrain}; CLEAR_COLOR = new Color(0.7f, 0.75f, 0.82f); StandardShader.environment.setFog(0f, 50f, new Vector4f(0.7f, 0.75f, 0.82f, 1f)); StandardShader.environment.ambientColor.set(0.05f, 0.1f, 0.2f); StandardShader.environment.lightColor.set(0.9f, 0.85f, 0.8f); lightActor.rotation.x = (float) Math.PI / 6f; lightActor.updateTransform(); }
From source file:com.xrbpowered.gl.res.textures.Texture.java
License:Open Source License
public static void setProperties(int textureType, boolean wrap, boolean filter, int anisotropy) { GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_WRAP_S, wrap ? GL11.GL_REPEAT : GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_WRAP_T, wrap ? GL11.GL_REPEAT : GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_MAG_FILTER, filter ? GL11.GL_LINEAR : GL11.GL_NEAREST); GL11.glTexParameteri(textureType, GL11.GL_TEXTURE_MIN_FILTER, filter ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_NEAREST); if (filter) { GL30.glGenerateMipmap(textureType); if (anisotropy > 1) { GL11.glTexParameterf(textureType, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);/*from ww w.j a va2s .c o m*/ } } }
From source file:dataAccess.lwjgl.VAO_Loader.java
public static int loadTexture(File file) { int textureID; if (textureMap.containsKey(file.getAbsolutePath())) { textureID = textureMap.get(file.getAbsolutePath()); } else {/*from w ww . j a va2 s .c o m*/ Texture texture = null; try { texture = TextureLoader.getTexture("PNG", new FileInputStream(file)); } catch (IOException ex) { Logger.getLogger(VAO_Loader.class.getName()).log(Level.SEVERE, null, ex); } textureID = texture.getTextureID(); textureMap.put(file.getAbsolutePath(), textureID); } GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0f); if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) { if (Settings.ANISOTROPIC_FILTERING) { float amount = Math.min(4f, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount); } } else { System.out.println("no anisotropic filtering possible!"); } return textureID; }
From source file:ivengine.Util.java
License:Creative Commons License
/** * Stores a variable amount of textures defined by URLS <filenames> into a texture array. Uses a magfilter <magfilter>, a minfilter <minfilter>. * If <mipmap> is true, mipmaps will be activated. * If <anisotropic> is true, anisotropic filtering will be activated, if supported. */// ww w . j a va 2 s.co m public static int loadTextureAtlasIntoTextureArray(URL[] filenames, int magfilter, int minfilter, boolean mipmap, boolean anisotropic) { int tex = GL11.glGenTextures(); GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, tex); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MAG_FILTER, magfilter); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MIN_FILTER, minfilter); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); ByteBuffer buf = null; PNGDecoder decoder = null; try { InputStream in = filenames[0].openStream(); decoder = new PNGDecoder(in); buf = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight()); decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA); buf.flip(); in.close(); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } int tileWidth = decoder.getWidth(); System.out.println(tileWidth); int tileHeight = decoder.getHeight(); System.out.println(tileHeight); GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, tileWidth, tileHeight, filenames.length, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null); for (int i = 0; i < filenames.length; i++) { GL12.glTexSubImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, /*tileWidth*x*/0, /*tileHeight*y*/0, i, tileWidth, tileHeight, 1, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf); buf.rewind(); if (i < filenames.length - 1) loadTexture(filenames[i + 1], buf); } if (mipmap) GL30.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY); if (anisotropic) { if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) { float maxanis = GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); System.out.println("Anisotropic filtering activated with a resolution of " + maxanis); System.out.println(GL11.glGetError()); GL11.glTexParameterf(GL30.GL_TEXTURE_2D_ARRAY, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxanis); System.out.println(GL11.glGetError()); } else { System.err.println( "WARNING - Anisotropic filtering not supported by this graphics card. Setting it as disabled"); } } GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0); return tex; }
From source file:jpcsp.graphics.RE.RenderingEngineLwjgl.java
License:Open Source License
@Override public void setTextureAnisotropy(float value) { GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, value); }
From source file:org.lwjgl.demo.opengl.textures.Texture2DArrayMipmapping.java
License:Open Source License
private void createTexture() { this.tex = glGenTextures(); glBindTexture(GL_TEXTURE_2D_ARRAY, this.tex); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); /* Add maximum anisotropic filtering, if available */ if (caps.GL_EXT_texture_filter_anisotropic) { glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); float maxAnisotropy = glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); glTexParameterf(GL_TEXTURE_2D_ARRAY, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);/*w w w . j ava2 s .c om*/ } else { glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, texSize, texSize, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, (ByteBuffer) null); ByteBuffer bb = BufferUtils.createByteBuffer(3 * texSize * texSize); int checkSize = 5; /* Generate some checker board pattern */ for (int y = 0; y < texSize; y++) { for (int x = 0; x < texSize; x++) { if (((x / checkSize + y / checkSize) % 2) == 0) { bb.put((byte) 255).put((byte) 255).put((byte) 255); } else { bb.put((byte) 0).put((byte) 0).put((byte) 0); } } } bb.flip(); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, texSize, texSize, 1, GL_RGB, GL_UNSIGNED_BYTE, bb); /* Generate some diagonal lines for the second layer */ for (int y = 0; y < texSize; y++) { for (int x = 0; x < texSize; x++) { if ((x + y) / 3 % 3 == 0) { bb.put((byte) 255).put((byte) 255).put((byte) 255); } else { bb.put((byte) 0).put((byte) 0).put((byte) 0); } } } bb.flip(); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 1, texSize, texSize, 1, GL_RGB, GL_UNSIGNED_BYTE, bb); glGenerateMipmap(GL_TEXTURE_2D_ARRAY); glBindTexture(GL_TEXTURE_2D_ARRAY, 0); }