/** Sets the image data of the {@link Texture} based on the {@link Pixmap}. The texture must be bound for this to work. If * <code>disposePixmap</code> is true, the pixmap will be disposed at the end of the method. * @param pixmap the Pixmap */ public static void generateMipMap (Pixmap pixmap, int textureWidth, int textureHeight) { generateMipMap(GL20.GL_TEXTURE_2D, pixmap, textureWidth, textureHeight); }
/** Sets the image data of the {@link Texture} based on the {@link Pixmap}. The texture must be bound for this to work. If * <code>disposePixmap</code> is true, the pixmap will be disposed at the end of the method. */ public static void generateMipMap (int target, Pixmap pixmap, int textureWidth, int textureHeight) { if (!useHWMipMap) { generateMipMapCPU(target, pixmap, textureWidth, textureHeight); return; } if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.WebGL || Gdx.app.getType() == ApplicationType.iOS) { generateMipMapGLES20(target, pixmap); } else { generateMipMapDesktop(target, pixmap, textureWidth, textureHeight); } }
private static void generateMipMapDesktop (int target, Pixmap pixmap, int textureWidth, int textureHeight) { if (Gdx.graphics.supportsExtension("GL_ARB_framebuffer_object") || Gdx.graphics.supportsExtension("GL_EXT_framebuffer_object") || Gdx.gl30 != null) { Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); Gdx.gl20.glGenerateMipmap(target); } else { generateMipMapCPU(target, pixmap, textureWidth, textureHeight); } }
@Override public void create () { camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.position.set(0, 1.5f, 1.5f); camera.lookAt(0, 0, 0); camera.update(); controller = new PerspectiveCamController(camera); mesh = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute( Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE)); mesh.setVertices(new float[] {-1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, -1, 1, 0, -1, 0, -1, 0, 0,}); mesh.setIndices(new short[] {0, 1, 2, 3}); shader = new ShaderProgram(Gdx.files.internal("data/shaders/flattex-vert.glsl").readString(), Gdx.files.internal( "data/shaders/flattex-frag.glsl").readString()); if (!shader.isCompiled()) throw new GdxRuntimeException("shader error: " + shader.getLog()); textureHW = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true); MipMapGenerator.setUseHardwareMipMap(false); textureSW = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true); currTexture = textureHW; createUI(); multiplexer = new InputMultiplexer(); Gdx.input.setInputProcessor(multiplexer); multiplexer.addProcessor(ui); multiplexer.addProcessor(controller); }
private static void generateMipMapDesktop (int target, Pixmap pixmap, int textureWidth, int textureHeight) { if (Gdx.graphics.supportsExtension("GL_ARB_framebuffer_object") || Gdx.graphics.supportsExtension("GL_EXT_framebuffer_object") || Gdx.gl30 != null) { Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); Gdx.gl20.glGenerateMipmap(target); } else { generateMipMapCPU(target, pixmap, textureWidth, textureHeight); } }
MipMapGenerator.setUseHardwareMipMap(true);
/** Sets the image data of the {@link Texture} based on the {@link Pixmap}. The texture must be bound for this to work. If * <code>disposePixmap</code> is true, the pixmap will be disposed at the end of the method. */ public static void generateMipMap (int target, Pixmap pixmap, int textureWidth, int textureHeight) { if (!useHWMipMap) { generateMipMapCPU(target, pixmap, textureWidth, textureHeight); return; } if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.WebGL || Gdx.app.getType() == ApplicationType.iOS) { generateMipMapGLES20(target, pixmap); } else { generateMipMapDesktop(target, pixmap, textureWidth, textureHeight); } }
/** Sets the image data of the {@link Texture} based on the {@link Pixmap}. The texture must be bound for this to work. If * <code>disposePixmap</code> is true, the pixmap will be disposed at the end of the method. * @param pixmap the Pixmap */ public static void generateMipMap (Pixmap pixmap, int textureWidth, int textureHeight) { generateMipMap(GL20.GL_TEXTURE_2D, pixmap, textureWidth, textureHeight); }
private static void generateMipMapDesktop (int target, Pixmap pixmap, int textureWidth, int textureHeight) { if (Gdx.graphics.supportsExtension("GL_ARB_framebuffer_object") || Gdx.graphics.supportsExtension("GL_EXT_framebuffer_object") || Gdx.gl30 != null) { Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); Gdx.gl20.glGenerateMipmap(target); } else { generateMipMapCPU(target, pixmap, textureWidth, textureHeight); } }
/** Sets the image data of the {@link Texture} based on the {@link Pixmap}. The texture must be bound for this to work. If * <code>disposePixmap</code> is true, the pixmap will be disposed at the end of the method. */ public static void generateMipMap (int target, Pixmap pixmap, int textureWidth, int textureHeight) { if (!useHWMipMap) { generateMipMapCPU(target, pixmap, textureWidth, textureHeight); return; } if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.WebGL || Gdx.app.getType() == ApplicationType.iOS) { generateMipMapGLES20(target, pixmap); } else { generateMipMapDesktop(target, pixmap, textureWidth, textureHeight); } }
@Override public void consumeCustomData (int target) { if (!isPrepared) throw new GdxRuntimeException("Call prepare() before calling consumeCompressedData()"); if (!Gdx.graphics.supportsExtension("GL_OES_compressed_ETC1_RGB8_texture")) { Pixmap pixmap = ETC1.decodeImage(data, Format.RGB565); Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); if (useMipMaps) MipMapGenerator.generateMipMap(target, pixmap, pixmap.getWidth(), pixmap.getHeight()); pixmap.dispose(); useMipMaps = false; } else { Gdx.gl.glCompressedTexImage2D(target, 0, ETC1.ETC1_RGB8_OES, width, height, 0, data.compressedData.capacity() - data.dataOffset, data.compressedData); if (useMipMaps()) Gdx.gl20.glGenerateMipmap(GL20.GL_TEXTURE_2D); } data.dispose(); data = null; isPrepared = false; }
@Override public void consumeCustomData (int target) { if (!isPrepared) throw new GdxRuntimeException("Call prepare() before calling consumeCompressedData()"); if (!Gdx.graphics.supportsExtension("GL_OES_compressed_ETC1_RGB8_texture")) { Pixmap pixmap = ETC1.decodeImage(data, Format.RGB565); Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); if (useMipMaps) MipMapGenerator.generateMipMap(target, pixmap, pixmap.getWidth(), pixmap.getHeight()); pixmap.dispose(); useMipMaps = false; } else { Gdx.gl.glCompressedTexImage2D(target, 0, ETC1.ETC1_RGB8_OES, width, height, 0, data.compressedData.capacity() - data.dataOffset, data.compressedData); if (useMipMaps()) Gdx.gl20.glGenerateMipmap(GL20.GL_TEXTURE_2D); } data.dispose(); data = null; isPrepared = false; }
MipMapGenerator.generateMipMap(target, pixmap, pixmap.getWidth(), pixmap.getHeight()); } else { Gdx.gl.glTexImage2D(target, miplevel, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0,
MipMapGenerator.generateMipMap(target, pixmap, pixmap.getWidth(), pixmap.getHeight()); } else { Gdx.gl.glTexImage2D(target, miplevel, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0,
/** Sets the image data of the {@link Texture} based on the {@link Pixmap}. The texture must be bound for this to work. If * <code>disposePixmap</code> is true, the pixmap will be disposed at the end of the method. * @param pixmap the Pixmap */ public static void generateMipMap (Pixmap pixmap, int textureWidth, int textureHeight) { generateMipMap(GL20.GL_TEXTURE_2D, pixmap, textureWidth, textureHeight); }
@Override public void consumeCustomData (int target) { if (!isPrepared) throw new GdxRuntimeException("Call prepare() before calling consumeCompressedData()"); if (!Gdx.graphics.supportsExtension("GL_OES_compressed_ETC1_RGB8_texture")) { Pixmap pixmap = ETC1.decodeImage(data, Format.RGB565); Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); if (useMipMaps) MipMapGenerator.generateMipMap(target, pixmap, pixmap.getWidth(), pixmap.getHeight()); pixmap.dispose(); useMipMaps = false; } else { Gdx.gl.glCompressedTexImage2D(target, 0, ETC1.ETC1_RGB8_OES, width, height, 0, data.compressedData.capacity() - data.dataOffset, data.compressedData); if (useMipMaps()) Gdx.gl20.glGenerateMipmap(GL20.GL_TEXTURE_2D); } data.dispose(); data = null; isPrepared = false; }
MipMapGenerator.generateMipMap(target, pixmap, pixmap.getWidth(), pixmap.getHeight()); } else { Gdx.gl.glTexImage2D(target, miplevel, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0,