use of io.xol.chunkstories.renderer.opengl.texture.Texture2DRenderTargetGL in project chunkstories by Hugobros3.
the class WorldRendererImplementation method renderWorldInternal.
protected void renderWorldInternal(RenderingInterface renderingInterface) {
this.renderingGraph.render(renderingInterface);
Texture finalBuffer = this.renderingGraph.getRenderPass("forward").resolvedOutputs.get("shadedBuffer");
if (finalBuffer != null && finalBuffer instanceof Texture2DRenderTargetGL) {
this.averageLuma.computeAverageLuma((Texture2DRenderTargetGL) finalBuffer);
}
}
use of io.xol.chunkstories.renderer.opengl.texture.Texture2DRenderTargetGL in project chunkstories by Hugobros3.
the class TrueTypeFont method loadImageIntoOpenGLTexture.
public static Texture2DGL loadImageIntoOpenGLTexture(int offset, BufferedImage bufferedImage) {
try {
short width = (short) bufferedImage.getWidth();
short height = (short) bufferedImage.getHeight();
int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
ByteBuffer byteBuffer;
DataBuffer db = bufferedImage.getData().getDataBuffer();
if (db instanceof DataBufferInt) {
int[] intI = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
byte[] newI = new byte[intI.length * 4];
for (int i = 0; i < intI.length; i++) {
byte[] b = intToByteArray(intI[i]);
int newIndex = i * 4;
newI[newIndex] = b[1];
newI[newIndex + 1] = b[2];
newI[newIndex + 2] = b[3];
newI[newIndex + 3] = b[0];
}
byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(newI);
} else {
byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder()).put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
}
byteBuffer.flip();
Texture2DGL texture = new Texture2DRenderTargetGL(TextureFormat.RGBA_8BPP, width, height);
texture.uploadTextureData(width, height, byteBuffer);
texture.setLinearFiltering(false);
texture.setTextureWrapping(false);
return texture;
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
return null;
}
Aggregations