List of usage examples for com.badlogic.gdx.graphics GL20 GL_RGBA
int GL_RGBA
To view the source code for com.badlogic.gdx.graphics GL20 GL_RGBA.
Click Source Link
From source file:com.googlecode.gdxquake2.game.render.GlRenderer.java
License:Open Source License
public void uploadImage(Image image) { GlState.checkError("before upload image"); image.has_alpha = true;// ww w. j av a 2s . com image.complete = true; Images.GL_Bind(image.texnum); if (image.type == com.googlecode.gdxquake2.game.common.QuakeImage.it_pic) { GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); texImage2D(image.pixmap, GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE); image.upload_width = image.width; image.upload_height = image.height; } else if (image.type == com.googlecode.gdxquake2.game.common.QuakeImage.it_sky) { GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); if (Images.skyTarget == null) Images.skyTarget = image; Images.GL_Bind(Images.skyTarget.texnum); if (Images.skyTarget.upload_width != 6 * image.width) { texImage2D(new Pixmap(6 * image.width, image.height, Pixmap.Format.RGBA8888), GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE); Images.skyTarget.upload_width = 6 * image.width; } Images.skyTarget.upload_height = image.height; texSubImage2D(image.pixmap, GL20.GL_TEXTURE_2D, 0, image.width * image.skyIndex, 0, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE); } else { GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR); GlState.gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); int p2size = 1 << ((int) Math.ceil(Math.log(Math.max(image.width, image.height)) / Math.log(2))); image.upload_width = p2size; image.upload_height = p2size; int level = 0; do { Pixmap canvas = getTmpImage(p2size, p2size); canvas.setColor(0x88888888); canvas.fill(); try { canvas.drawPixmap(image.pixmap, 0, 0, image.pixmap.getWidth(), image.pixmap.getHeight(), 0, 0, p2size, p2size); } catch (Exception e) { GdxQuake2.tools.log("Error rendering image " + image.name + "; size: " + p2size + " MSG: " + e); break; } texImage2D(canvas, GL20.GL_TEXTURE_2D, level++, GL20.GL_RGBA, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE); p2size /= 2; } while (p2size > 0); } GLDebug.checkError(GlState.gl, "uploadImage"); }
From source file:com.heaven7.fantastictank.test.ScreenUtils.java
License:Apache License
public static Pixmap getFrameBufferPixmap(int x, int y, int w, int h) { Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); final Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888); ByteBuffer pixels = pixmap.getPixels(); Gdx.gl.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); return pixmap; }
From source file:com.heaven7.fantastictank.test.ScreenUtils.java
License:Apache License
/** Returns a portion of the default framebuffer contents specified by x, y, width and height, as a byte[] array with a length * equal to the specified width * height * 4. The byte[] will always contain RGBA8888 data. If the width and height specified * are larger than the framebuffer dimensions, the Texture will be padded accordingly. Pixels that fall outside of the current * screen will have RGBA values of 0. Because of differences in screen and image origins the framebuffer contents should be * flipped along the Y axis if you intend save them to disk as a bitmap. Flipping is not cheap operation, so use this * functionality wisely./*from ww w. j a va 2 s. c o m*/ * * @param flipY whether to flip pixels along Y axis */ public static byte[] getFrameBufferPixels(int x, int y, int w, int h, boolean flipY) { Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); final ByteBuffer pixels = BufferUtils.newByteBuffer(w * h * 4); Gdx.gl.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); final int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; if (flipY) { final int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } } else { pixels.clear(); pixels.get(lines); } return lines; }
From source file:com.softwaresemantics.diyglsllwp.ShaderGalleryActivity.java
License:Creative Commons License
/** * * *//* w w w . j av a2s.c om*/ public Pixmap getScreenshot(int x, int y, int w, int h, boolean flipY) { Gdx.gl20.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); final Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888); ByteBuffer pixels = pixmap.getPixels(); Gdx.gl20.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); final int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; if (flipY) { final int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } pixels.clear(); pixels.put(lines); } else { pixels.clear(); pixels.get(lines); } return pixmap; }
From source file:com.toet.TinyVoxel.android.AndroidConfig.java
@Override public void uploadPalette(int width, int height) { paletteBuffer.rewind();//from www . j a v a 2 s. c o m Gdx.graphics.getGL20().glPixelStorei(GL20.GL_UNPACK_ALIGNMENT, 1); Gdx.graphics.getGL20().glTexImage2D(GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, width, height, 0, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, paletteBuffer); }
From source file:com.toet.TinyVoxel.android.AndroidConfig.java
@Override public void uploadSinglePalette(int paletteId) { tinyPaletteBuffer.rewind();//from w w w . jav a 2 s. c o m Gdx.graphics.getGL20().glPixelStorei(GL20.GL_UNPACK_ALIGNMENT, 1); Gdx.graphics.getGL20().glTexSubImage2D(GL20.GL_TEXTURE_2D, 0, 0, paletteId, Config.TINY_GRID_TOTAL, 1, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, tinyPaletteBuffer); }
From source file:com.watabou.glwrap.NoosaTexture.java
License:Open Source License
public void pixels(int w, int h, int[] pixels) { // FIXME/*from www .j av a2s. c o m*/ bind(); IntBuffer imageBuffer = ByteBuffer.allocateDirect(w * h * 4).order(ByteOrder.nativeOrder()).asIntBuffer(); imageBuffer.put(pixels); imageBuffer.position(0); Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, w, h, 0, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, imageBuffer); }
From source file:mobi.shad.s3lib.gfx.util.ScreenShot.java
License:Apache License
/** * @param x/*from w w w . j a v a2 s. c o m*/ * @param y * @param w * @param h * @param flipY * @return */ public static Pixmap getScreenShot(int x, int y, int w, int h, boolean flipY) { Gdx.gl.glPixelStorei(GL20.GL_PACK_ALIGNMENT, 1); final Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888); ByteBuffer pixels = pixmap.getPixels(); Gdx.gl.glReadPixels(x, y, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels); final int numBytes = w * h * 4; byte[] lines = new byte[numBytes]; if (flipY) { final int numBytesPerLine = w * 4; for (int i = 0; i < h; i++) { pixels.position((h - i - 1) * numBytesPerLine); pixels.get(lines, i * numBytesPerLine, numBytesPerLine); } pixels.clear(); pixels.put(lines); } else { pixels.clear(); pixels.get(lines); } return pixmap; }
From source file:org.teavm.gdx.emu.PixmapEmulator.java
License:Apache License
public int getGLInternalFormat() { return GL20.GL_RGBA; }
From source file:org.teavm.gdx.emu.PixmapEmulator.java
License:Apache License
public int getGLFormat() { return GL20.GL_RGBA; }