List of usage examples for org.lwjgl.opengl EXTTextureFilterAnisotropic GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
int GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
To view the source code for org.lwjgl.opengl EXTTextureFilterAnisotropic GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT.
Click Source Link
From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc}//from www . ja va2 s . c o m */ @Override public RenderCapabilities glCapabilities() { //! //! Retrieves the capabilities from the context. //! final GLCapabilities capabilities = GL.getCapabilities(); final RenderCapabilities.LanguageVersion version; if (capabilities.OpenGL33) { version = RenderCapabilities.LanguageVersion.GL33; } else if (capabilities.OpenGL32) { version = RenderCapabilities.LanguageVersion.GL32; } else if (capabilities.OpenGL31) { version = RenderCapabilities.LanguageVersion.GL31; } else if (capabilities.OpenGL30) { version = RenderCapabilities.LanguageVersion.GL30; } else if (capabilities.OpenGL21) { version = RenderCapabilities.LanguageVersion.GL21; } else { throw new RuntimeException("Cannot find a suitable context, OpenGL 2.1 is at-least required."); } //! //! Retrieves the limitation from the context. //! final Map<RenderCapabilities.Limit, Float> limit = new HashMap<>(); limit.put(RenderCapabilities.Limit.FRAME_ATTACHMENT, GL11.glGetFloat(GL30.GL_MAX_COLOR_ATTACHMENTS)); limit.put(RenderCapabilities.Limit.FRAME_MULTIPLE_RENDER_ATTACHMENT, GL11.glGetFloat(ARBDrawBuffers.GL_MAX_DRAW_BUFFERS_ARB)); limit.put(RenderCapabilities.Limit.FRAME_SAMPLE, GL11.glGetFloat(GL30.GL_MAX_SAMPLES)); limit.put(RenderCapabilities.Limit.TEXTURE_ANISOTROPIC, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); limit.put(RenderCapabilities.Limit.TEXTURE_SIZE, GL11.glGetFloat(GL11.GL_MAX_TEXTURE_SIZE)); limit.put(RenderCapabilities.Limit.TEXTURE_STAGE, GL11.glGetFloat(GL20.GL_MAX_TEXTURE_IMAGE_UNITS)); limit.put(RenderCapabilities.Limit.GLSL_MAX_VERTEX_ATTRIBUTES, GL11.glGetFloat(GL20.GL_MAX_VERTEX_ATTRIBS)); //! //! Retrieves the extension from the context. //! final Map<RenderCapabilities.Extension, Boolean> extension = new HashMap<>(); extension.put(RenderCapabilities.Extension.FRAME_BUFFER, capabilities.GL_ARB_framebuffer_object); extension.put(RenderCapabilities.Extension.FRAME_BUFFER_MULTIPLE_RENDER_TARGET, capabilities.GL_ARB_draw_buffers); extension.put(RenderCapabilities.Extension.FRAME_BUFFER_MULTIPLE_SAMPLE, capabilities.GL_ARB_multisample); extension.put(RenderCapabilities.Extension.VERTEX_ARRAY_OBJECT, capabilities.GL_ARB_vertex_array_object); extension.put(RenderCapabilities.Extension.TEXTURE_3D, true); extension.put(RenderCapabilities.Extension.TEXTURE_COMPRESSION_S3TC, capabilities.GL_EXT_texture_compression_s3tc); extension.put(RenderCapabilities.Extension.TEXTURE_FILTER_ANISOTROPIC, capabilities.GL_EXT_texture_filter_anisotropic); extension.put(RenderCapabilities.Extension.GLSL_PRECISION, capabilities.GL_ARB_shader_precision); extension.put(RenderCapabilities.Extension.GLSL_EXPLICIT_ATTRIBUTE, capabilities.GL_ARB_explicit_attrib_location); extension.put(RenderCapabilities.Extension.GLSL_EXPLICIT_UNIFORM, capabilities.GL_ARB_explicit_uniform_location); extension.put(RenderCapabilities.Extension.GLSL_GEOMETRY, capabilities.GL_ARB_geometry_shader4); return new RenderCapabilities(version, extension, limit); }
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);//ww w .j a va2s . c o m } 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.renderer.lwjgl.LwjglContextCapabilities.java
License:Open Source License
public LwjglContextCapabilities(final org.lwjgl.opengl.ContextCapabilities caps) { final IntBuffer buf = BufferUtils.createIntBuffer(16); _supportsVBO = caps.GL_ARB_vertex_buffer_object; _supportsGL1_2 = caps.OpenGL12;/*from w w w . j ava 2 s .co m*/ _supportsMultisample = caps.GL_ARB_multisample; _supportsDoubleCoefficientsInClipPlaneEquation = true; _supportsConstantColor = _supportsEq = caps.GL_ARB_imaging; _supportsSeparateFunc = caps.GL_EXT_blend_func_separate; _supportsSeparateEq = caps.GL_EXT_blend_equation_separate; _supportsMinMax = caps.GL_EXT_blend_minmax; _supportsSubtract = caps.GL_EXT_blend_subtract; _supportsFogCoords = caps.GL_EXT_fog_coord; _supportsFragmentProgram = caps.GL_ARB_fragment_program; _supportsVertexProgram = caps.GL_ARB_vertex_program; _supportsPointSprites = caps.GL_ARB_point_sprite; _supportsPointParameters = caps.GL_ARB_point_parameters; _supportsTextureLodBias = caps.GL_EXT_texture_lod_bias; if (_supportsTextureLodBias) { GL11.glGetInteger(EXTTextureLODBias.GL_MAX_TEXTURE_LOD_BIAS_EXT, buf); _maxTextureLodBias = buf.get(0); } else { _maxTextureLodBias = 0f; } GL11.glGetInteger(GL11.GL_MAX_CLIP_PLANES, buf); _maxUserClipPlanes = buf.get(0); _glslSupported = caps.GL_ARB_shader_objects && caps.GL_ARB_fragment_shader && caps.GL_ARB_vertex_shader && caps.GL_ARB_shading_language_100; _geometryShader4Supported = caps.GL_ARB_geometry_shader4 && _glslSupported; _geometryInstancingSupported = caps.GL_EXT_draw_instanced || caps.OpenGL31; if (_glslSupported) { GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_ATTRIBS_ARB, buf); _maxGLSLVertexAttribs = buf.get(0); } // Pbuffer _pbufferSupported = caps.GL_ARB_pixel_buffer_object; // FBO _fboSupported = caps.GL_EXT_framebuffer_object; if (_fboSupported) { _supportsFBOMultisample = caps.GL_EXT_framebuffer_multisample; _supportsFBOBlit = caps.GL_EXT_framebuffer_blit; if (caps.GL_ARB_draw_buffers) { GL11.glGetInteger(EXTFramebufferObject.GL_MAX_COLOR_ATTACHMENTS_EXT, buf); _maxFBOColorAttachments = buf.get(0); } else { _maxFBOColorAttachments = 1; } // Max multisample samples. if (caps.GL_EXT_framebuffer_multisample && caps.GL_EXT_framebuffer_blit) { GL11.glGetInteger(EXTFramebufferMultisample.GL_MAX_SAMPLES_EXT, buf); _maxFBOSamples = buf.get(0); } else { _maxFBOSamples = 0; } } else { _maxFBOColorAttachments = 0; } _twoSidedStencilSupport = caps.GL_EXT_stencil_two_side; _stencilWrapSupport = caps.GL_EXT_stencil_wrap; // number of available auxiliary draw buffers GL11.glGetInteger(GL11.GL_AUX_BUFFERS, buf); _numAuxDrawBuffers = buf.get(0); // max texture size. GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE, buf); _maxTextureSize = buf.get(0); // Check for support of multitextures. _supportsMultiTexture = caps.GL_ARB_multitexture; // Support for texture formats _supportsFloatTextures = caps.GL_ARB_texture_float; _supportsIntegerTextures = caps.GL_EXT_texture_integer; _supportsOneTwoComponentTextures = caps.GL_ARB_texture_rg; // Check for support of fixed function dot3 environment settings _supportsEnvDot3 = caps.GL_ARB_texture_env_dot3; // Check for support of fixed function dot3 environment settings _supportsEnvCombine = caps.GL_ARB_texture_env_combine; // Check for support of automatic mipmap generation _automaticMipMaps = caps.GL_SGIS_generate_mipmap; _supportsDepthTexture = caps.GL_ARB_depth_texture; _supportsShadow = caps.GL_ARB_shadow; // If we do support multitexturing, find out how many textures we // can handle. if (_supportsMultiTexture) { GL11.glGetInteger(ARBMultitexture.GL_MAX_TEXTURE_UNITS_ARB, buf); _numFixedTexUnits = buf.get(0); } else { _numFixedTexUnits = 1; } // Go on to check number of texture units supported for vertex and // fragment shaders if (caps.GL_ARB_shader_objects && caps.GL_ARB_vertex_shader && caps.GL_ARB_fragment_shader) { GL11.glGetInteger(ARBVertexShader.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, buf); _numVertexTexUnits = buf.get(0); GL11.glGetInteger(ARBFragmentShader.GL_MAX_TEXTURE_IMAGE_UNITS_ARB, buf); _numFragmentTexUnits = buf.get(0); GL11.glGetInteger(ARBFragmentShader.GL_MAX_TEXTURE_COORDS_ARB, buf); _numFragmentTexCoordUnits = buf.get(0); } else { // based on nvidia dev doc: // http://developer.nvidia.com/object/General_FAQ.html#t6 // "For GPUs that do not support GL_ARB_fragment_program and // GL_NV_fragment_program, those two limits are set equal to // GL_MAX_TEXTURE_UNITS." _numFragmentTexCoordUnits = _numFixedTexUnits; _numFragmentTexUnits = _numFixedTexUnits; // We'll set this to 0 for now since we do not know: _numVertexTexUnits = 0; } // ARBShaderObjects.GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB // caps.GL_EXT_bindable_uniform // EXTBindableUniform.GL_MAX_BINDABLE_UNIFORM_SIZE_EXT; // Now determine the maximum number of supported texture units _numTotalTexUnits = Math.max(_numFragmentTexCoordUnits, Math.max(_numFixedTexUnits, Math.max(_numFragmentTexUnits, _numVertexTexUnits))); // Check for S3 texture compression capability. _supportsS3TCCompression = caps.GL_EXT_texture_compression_s3tc; // Check for LA texture compression capability. _supportsLATCCompression = caps.GL_EXT_texture_compression_latc; // Check for generic texture compression capability. _supportsGenericCompression = caps.GL_ARB_texture_compression; // Check for 3D texture capability. _supportsTexture3D = caps.OpenGL12; // Check for cubemap capability. _supportsTextureCubeMap = caps.GL_ARB_texture_cube_map; // See if we support anisotropic filtering _supportsAniso = caps.GL_EXT_texture_filter_anisotropic; if (_supportsAniso) { // Due to LWJGL buffer check, you can't use smaller sized // buffers (min_size = 16 for glGetFloat()). final FloatBuffer max_a = BufferUtils.createFloatBuffer(16); max_a.rewind(); // Grab the maximum anisotropic filter. GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, max_a); // set max. _maxAnisotropic = max_a.get(0); } // See if we support textures that are not power of 2 in size. _supportsNonPowerTwo = caps.GL_ARB_texture_non_power_of_two; // See if we support textures that do not have width == height. _supportsRectangular = caps.GL_ARB_texture_rectangle; _supportsMirroredRepeat = caps.GL_ARB_texture_mirrored_repeat; _supportsMirrorClamp = _supportsMirrorEdgeClamp = _supportsMirrorBorderClamp = caps.GL_EXT_texture_mirror_clamp; _supportsBorderClamp = caps.GL_ARB_texture_border_clamp; _supportsEdgeClamp = _supportsGL1_2; try { _displayVendor = GL11.glGetString(GL11.GL_VENDOR); } catch (final Exception e) { _displayVendor = "Unable to retrieve vendor."; } try { _displayRenderer = GL11.glGetString(GL11.GL_RENDERER); } catch (final Exception e) { _displayRenderer = "Unable to retrieve adapter details."; } try { _displayVersion = GL11.glGetString(GL11.GL_VERSION); } catch (final Exception e) { _displayVersion = "Unable to retrieve API version."; } try { _shadingLanguageVersion = GL11.glGetString(GL20.GL_SHADING_LANGUAGE_VERSION); } catch (final Exception e) { _shadingLanguageVersion = "Unable to retrieve shading language version."; } }
From source file:com.opengg.core.render.texture.Texture.java
public void setAnisotropyLevel(int level) { if (GL.getCapabilities().GL_EXT_texture_filter_anisotropic) { float lev = Math.min(level, glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); tex.setParameterf(GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, lev); } else {/* w w w. j av a 2 s. co m*/ GGConsole.warning("Anisotropy is not available on this device"); } }
From source file:com.xrbpowered.gl.Client.java
License:Open Source License
public static void printInfo() { System.out.println("\n--------------------------------\nSYSTEM INFO\n--------------------------------"); System.out.println("Device: " + GL11.glGetString(GL11.GL_RENDERER)); System.out.println("Device vendor: " + GL11.glGetString(GL11.GL_VENDOR)); System.out.println("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION)); System.out.printf("Max texture size: %d\n", GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE)); System.out.printf("Max MSAA samples: %d\n", GL11.glGetInteger(GL30.GL_MAX_SAMPLES)); System.out.printf("Max anisotropy: %d\n", GL11.glGetInteger(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); System.out.printf("Max texture array layers: %d\n", GL11.glGetInteger(GL30.GL_MAX_ARRAY_TEXTURE_LAYERS)); System.out.printf("Max vertex attribs: %d\n", GL11.glGetInteger(GL20.GL_MAX_VERTEX_ATTRIBS)); System.out.printf("Max uniform components: %d\n", GL11.glGetInteger(GL20.GL_MAX_VERTEX_UNIFORM_COMPONENTS)); System.out.printf("Available video memory (NVIDIA only): %.1f%%\n", getAvailMemoryNVidia() * 100f); System.out.println("--------------------------------"); System.out.println();/*from ww w . ja v a2 s.c om*/ GL11.glGetError(); // clear errors }
From source file:com.xrbpowered.gl.examples.ExampleMenu.java
License:Open Source License
protected void addQualitySettings(WidgetMenuBuilder mb) { int max = GL11.glGetInteger(GL30.GL_MAX_SAMPLES); int index = 0; LinkedList<String> options = new LinkedList<>(); options.add("Off"); for (int i = 1, d = 2; d <= max; i++, d <<= 1) { options.add(d + "x"); if (d == settings.multisample) index = i;/*w w w . j av a 2s. c o m*/ } mb.addMenuItem(new MenuOptionItem(mb.getPageRoot(), "Anti-aliasing", options.toArray(), index, 0) { @Override public void onChangeValue(int index) { String s = getValueName(); settings.multisample = s.equals("Off") ? 0 : Integer.parseInt(s.substring(0, s.length() - 1)); } }); max = GL11.glGetInteger(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); index = 0; options.clear(); options.add("Off"); for (int i = 1, d = 2; d <= max; i++, d <<= 1) { options.add(d + "x"); if (d == settings.anisotropy) index = i; } mb.addMenuItem(new MenuOptionItem(mb.getPageRoot(), "Anisotropic filtering", options.toArray(), index, 0) { @Override public void onChangeValue(int index) { String s = getValueName(); settings.anisotropy = s.equals("Off") ? 1 : Integer.parseInt(s.substring(0, s.length() - 1)); } }); }
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();/*from w w w .j a v a 2s . c o 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.SystemSettings.java
License:Open Source License
public void verifyAnisotropy() { anisotropy = Math.min(anisotropy, GL11.glGetInteger(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); }
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 w w. j ava 2s . 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. */// w w w.j a va 2 s.c o 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; }