GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, buffer); WritableRaster raster = pageImage.getRaster(); for (int y = 0; y < height; y++) {
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, buffer); WritableRaster raster = pageImage.getRaster(); for (int y = 0; y < height; y++) {
/** * Returns the content of the color buffer from GPU memory as a ByteBuffer. * @return a ByteBuffer or null */ public ByteBuffer getColorBufferRawData() { ByteBuffer buffer = BufferUtils.createByteBuffer(this.width() * this.height() * 4); this.bindTexture(); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer); FBO.unbindTexture(); return buffer; }
public static void saveGlTexture(String name, int textureId, int mipmapLevels) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); for(int level = 0; level <= mipmapLevels; level++) { int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH); int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT); int size = width * height; BufferedImage bufferedimage = new BufferedImage(width, height, 2); File output = new File(name + "_" + level + ".png"); IntBuffer buffer = BufferUtils.createIntBuffer(size); int[] data = new int[size]; GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer); buffer.get(data); bufferedimage.setRGB(0, 0, width, height, data, 0, width); try { ImageIO.write(bufferedimage, "png", output); FMLLog.info("[TextureDump] Exported png to: " + output.getAbsolutePath()); } catch(IOException ioexception) { FMLLog.info("[TextureDump] Unable to write: ", ioexception); } } } }
/** * @see org.newdawn.slick.opengl.renderer.SGL#glGetTexImage(int, int, int, int, java.nio.ByteBuffer) */ public void glGetTexImage(int target, int level, int format, int type, ByteBuffer pixels) { GL11.glGetTexImage(target, level, format, type, pixels); }
@Override public void getTexImage(int level, int format, int type, Buffer buffer) { if (buffer instanceof ByteBuffer) { ByteBuffer directBuffer = allocateDirectBuffer((ByteBuffer) buffer); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, textureFormatToGL[format], textureTypeToGL[type], (ByteBuffer) buffer); copyBuffer((ByteBuffer) buffer, directBuffer); } else if (buffer instanceof IntBuffer) { IntBuffer directBuffer = allocateDirectBuffer((IntBuffer) buffer); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, textureFormatToGL[format], textureTypeToGL[type], directBuffer); copyBuffer((IntBuffer) buffer, directBuffer); } else if (buffer instanceof ShortBuffer) { ShortBuffer directBuffer = allocateDirectBuffer((ShortBuffer) buffer); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, textureFormatToGL[format], textureTypeToGL[type], (ShortBuffer) buffer); copyBuffer((ShortBuffer) buffer, directBuffer); } else if (buffer instanceof FloatBuffer) { FloatBuffer directBuffer = allocateDirectBuffer((FloatBuffer) buffer); GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, textureFormatToGL[format], textureTypeToGL[type], (FloatBuffer) buffer); copyBuffer((FloatBuffer) buffer, directBuffer); } else { throw new IllegalArgumentException(); } }
final int[] data = new int[size]; GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer); buffer.get(data); bufferedimage.setRGB(0, 0, width, height, data, 0, width);
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, buffer); WritableRaster raster = pageImage.getRaster(); for (int y = 0; y < height; y++) {
@Override public ByteBuffer texture2DGetImage( final JCGLTextureUnitType unit, final JCGLTexture2DUsableType texture) throws JCGLException { NullCheck.notNull(texture, "Texture"); NullCheck.notNull(unit, "Unit"); checkTextureUnit(this.context, unit); checkTexture2D(this.context, texture); final JCGLTextureFormat format = texture.format(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaL area = AreaSizesL.area(texture.size()); final long width = area.width(); final long height = area.height(); final long data_size = width * height * (long) format.getBytesPerPixel(); final ByteBuffer data = ByteBuffer.allocateDirect(Math.toIntExact(data_size)); data.order(ByteOrder.nativeOrder()); this.texture2DBind(unit, texture); GL11.glGetTexImage( GL11.GL_TEXTURE_2D, 0, spec.getFormat(), spec.getType(), data); return data; }
public void createHeightmapDataBuffer(){ heightmapDataBuffer = BufferUtil.createFloatBuffer(getHeightmap().getMetaData().getWidth() * getHeightmap().getMetaData().getHeight()); heightmap.bind(); glGetTexImage(GL_TEXTURE_2D,0,GL_RED,GL_FLOAT,heightmapDataBuffer); }
@Override public ByteBuffer texture2DGetImage( final JCGLTextureUnitType unit, final JCGLTexture2DUsableType texture) throws JCGLException { NullCheck.notNull(texture); NullCheck.notNull(unit); LWJGL3Textures.checkTextureUnit(this.context, unit); LWJGL3Textures.checkTexture2D(this.context, texture); final JCGLTextureFormat format = texture.textureGetFormat(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaInclusiveUnsignedLType area = texture.textureGetArea(); final long width = area.getRangeX().getInterval(); final long height = area.getRangeY().getInterval(); final ByteBuffer data = ByteBuffer.allocateDirect( (int) (width * height * (long) format.getBytesPerPixel())); data.order(ByteOrder.nativeOrder()); this.texture2DBind(unit, texture); GL11.glGetTexImage( GL11.GL_TEXTURE_2D, 0, spec.getFormat(), spec.getType(), data); return data; }
@Override public ByteBuffer textureCubeGetImageLH( final JCGLTextureUnitType unit, final JCGLCubeMapFaceLH face, final JCGLTextureCubeUsableType texture) throws JCGLException { NullCheck.notNull(texture); NullCheck.notNull(face); NullCheck.notNull(unit); LWJGL3Textures.checkTextureUnit(this.context, unit); LWJGL3Textures.checkTextureCube(this.context, texture); final JCGLTextureFormat format = texture.textureGetFormat(); final LWJGL3TextureSpec spec = LWJGL3TextureSpecs.getTextureSpec(format); final AreaInclusiveUnsignedLType area = texture.textureGetArea(); final long width = area.getRangeX().getInterval(); final long height = area.getRangeY().getInterval(); final ByteBuffer data = ByteBuffer.allocateDirect( (int) (width * height * (long) format.getBytesPerPixel())); data.order(ByteOrder.nativeOrder()); final int gface = LWJGL3TypeConversions.cubeFaceToGL(face); this.textureCubeBind(unit, texture); GL11.glGetTexImage( gface, 0, spec.getFormat(), spec.getType(), data); return data; }
glGetTexImage(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT,GL_FLOAT,depthmapBuffer); float depth = depthmapBuffer.get((int) (BaseContext.getWindow().getWidth() * screenPos.getY() + screenPos.getX()));