private static void generateMipMapGLES20 (int target, Pixmap pixmap) { Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); Gdx.gl20.glGenerateMipmap(target); }
private static void generateMipMapGLES20 (int target, Pixmap pixmap) { Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); Gdx.gl20.glGenerateMipmap(target); }
/** Draws the given {@link Pixmap} to the texture at position x, y. No clipping is performed so you have to make sure that you * draw only inside the texture region. Note that this will only draw to mipmap level 0! * * @param pixmap The Pixmap * @param x The x coordinate in pixels * @param y The y coordinate in pixels */ public void draw (Pixmap pixmap, int x, int y) { if (data.isManaged()) throw new GdxRuntimeException("can't draw to a managed texture"); bind(); Gdx.gl.glTexSubImage2D(glTarget, 0, x, y, pixmap.getWidth(), pixmap.getHeight(), pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); }
/** Draws the given {@link Pixmap} to the texture at position x, y. No clipping is performed so you have to make sure that you * draw only inside the texture region. Note that this will only draw to mipmap level 0! * * @param pixmap The Pixmap * @param x The x coordinate in pixels * @param y The y coordinate in pixels */ public void draw (Pixmap pixmap, int x, int y) { if (data.isManaged()) throw new GdxRuntimeException("can't draw to a managed texture"); bind(); Gdx.gl.glTexSubImage2D(glTarget, 0, x, y, pixmap.getWidth(), pixmap.getHeight(), pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); }
glType = images[0][0].pixmap.getGLType(); glTypeSize = 1; glFormat = images[0][0].pixmap.getGLFormat(); glInternalFormat = images[0][0].pixmap.getGLInternalFormat(); glBaseInternalFormat = glFormat;
glType = images[0][0].pixmap.getGLType(); glTypeSize = 1; glFormat = images[0][0].pixmap.getGLFormat(); glInternalFormat = images[0][0].pixmap.getGLInternalFormat(); glBaseInternalFormat = glFormat;
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); } }
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); } }
Pixmap pixmap = ETC1.decodeImage(etcData, Format.RGB888); Gdx.gl.glTexImage2D(target + face, level, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); pixmap.dispose(); } else {
Pixmap pixmap = ETC1.decodeImage(etcData, Format.RGB888); Gdx.gl.glTexImage2D(target + face, level, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); pixmap.dispose(); } else {
@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; }
private static void generateMipMapCPU (int target, Pixmap pixmap, int textureWidth, int textureHeight) { Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); if ((Gdx.gl20 == null) && textureWidth != textureHeight) throw new GdxRuntimeException("texture width and height must be square when using mipmapping."); int width = pixmap.getWidth() / 2; int height = pixmap.getHeight() / 2; int level = 1; while (width > 0 && height > 0) { Pixmap tmp = new Pixmap(width, height, pixmap.getFormat()); tmp.setBlending(Blending.None); tmp.drawPixmap(pixmap, 0, 0, pixmap.getWidth(), pixmap.getHeight(), 0, 0, width, height); if (level > 1) pixmap.dispose(); pixmap = tmp; Gdx.gl.glTexImage2D(target, level, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); width = pixmap.getWidth() / 2; height = pixmap.getHeight() / 2; level++; } } }
private static void generateMipMapCPU (int target, Pixmap pixmap, int textureWidth, int textureHeight) { Gdx.gl.glTexImage2D(target, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); if ((Gdx.gl20 == null) && textureWidth != textureHeight) throw new GdxRuntimeException("texture width and height must be square when using mipmapping."); int width = pixmap.getWidth() / 2; int height = pixmap.getHeight() / 2; int level = 1; while (width > 0 && height > 0) { Pixmap tmp = new Pixmap(width, height, pixmap.getFormat()); tmp.setBlending(Blending.None); tmp.drawPixmap(pixmap, 0, 0, pixmap.getWidth(), pixmap.getHeight(), 0, 0, width, height); if (level > 1) pixmap.dispose(); pixmap = tmp; Gdx.gl.glTexImage2D(target, level, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); width = pixmap.getWidth() / 2; height = pixmap.getHeight() / 2; level++; } } }
@Override public void consumeCubemapData () { for (int i = 0; i < data.length; i++) { if (data[i].getType() == TextureData.TextureDataType.Custom) { data[i].consumeCustomData(GL20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); } else { Pixmap pixmap = data[i].consumePixmap(); boolean disposePixmap = data[i].disposePixmap(); if (data[i].getFormat() != pixmap.getFormat()) { Pixmap tmp = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), data[i].getFormat()); tmp.setBlending(Blending.None); tmp.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight()); if (data[i].disposePixmap()) pixmap.dispose(); pixmap = tmp; disposePixmap = true; } Gdx.gl.glPixelStorei(GL20.GL_UNPACK_ALIGNMENT, 1); Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); if (disposePixmap) pixmap.dispose(); } } }
@Override public void consumeCubemapData () { for (int i = 0; i < data.length; i++) { if (data[i].getType() == TextureData.TextureDataType.Custom) { data[i].consumeCustomData(GL20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i); } else { Pixmap pixmap = data[i].consumePixmap(); boolean disposePixmap = data[i].disposePixmap(); if (data[i].getFormat() != pixmap.getFormat()) { Pixmap tmp = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), data[i].getFormat()); tmp.setBlending(Blending.None); tmp.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight()); if (data[i].disposePixmap()) pixmap.dispose(); pixmap = tmp; disposePixmap = true; } Gdx.gl.glPixelStorei(GL20.GL_UNPACK_ALIGNMENT, 1); Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); if (disposePixmap) pixmap.dispose(); } } }
} else { Gdx.gl.glTexImage2D(target, miplevel, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
} else { Gdx.gl.glTexImage2D(target, miplevel, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
Gdx.gl.glTexSubImage2D(page.texture.glTarget, 0, rectX, rectY, rectWidth, rectHeight, image.getGLFormat(), image.getGLType(), image.getPixels()); } else
Gdx.gl.glTexSubImage2D(page.texture.glTarget, 0, rectX, rectY, rectWidth, rectHeight, image.getGLFormat(), image.getGLType(), image.getPixels()); } else