Search in sources :

Example 1 with Texture2DRenderTargetGL

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);
    }
}
Also used : Texture2DRenderTargetGL(io.xol.chunkstories.renderer.opengl.texture.Texture2DRenderTargetGL) Texture(io.xol.chunkstories.api.rendering.textures.Texture) HeightmapArrayTexture(io.xol.chunkstories.renderer.terrain.HeightmapArrayTexture)

Example 2 with Texture2DRenderTargetGL

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;
}
Also used : Texture2DRenderTargetGL(io.xol.chunkstories.renderer.opengl.texture.Texture2DRenderTargetGL) DataBufferInt(java.awt.image.DataBufferInt) Texture2DGL(io.xol.chunkstories.renderer.opengl.texture.Texture2DGL) DataBufferByte(java.awt.image.DataBufferByte) ByteBuffer(java.nio.ByteBuffer) IOException(java.io.IOException) FontFormatException(java.awt.FontFormatException) DataBuffer(java.awt.image.DataBuffer)

Aggregations

Texture2DRenderTargetGL (io.xol.chunkstories.renderer.opengl.texture.Texture2DRenderTargetGL)2 Texture (io.xol.chunkstories.api.rendering.textures.Texture)1 Texture2DGL (io.xol.chunkstories.renderer.opengl.texture.Texture2DGL)1 HeightmapArrayTexture (io.xol.chunkstories.renderer.terrain.HeightmapArrayTexture)1 FontFormatException (java.awt.FontFormatException)1 DataBuffer (java.awt.image.DataBuffer)1 DataBufferByte (java.awt.image.DataBufferByte)1 DataBufferInt (java.awt.image.DataBufferInt)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1