func (raylibRenderer *RaylibRenderer) Render(level *ldtkgo.Level) {
	raylibRenderer.Clear()
	rl.BeginDrawing()
	for _, layer := range level.Layers {
		switch layer.Type {
		case ldtkgo.LayerTypeTile:
			if len(layer.Tiles) > 0 {
				raylibRenderer.beginLayer(layer, level.Width, level.Height)
				target := raylibRenderer.RenderedLayers[len(raylibRenderer.RenderedLayers)-1]
				rl.BeginTextureMode(target.Image)
				for _, tile := range layer.Tiles {
					raylibRenderer.renderTile(tile.Position[0]+layer.OffsetX, tile.Position[1]+layer.OffsetY, tile.Src[0], tile.Src[1], layer.GridSize, layer.GridSize, tile.Flip)
				}
				rl.EndTextureMode()
			}
		case ldtkgo.LayerTypeIntGrid:  
			fallthrough
		case ldtkgo.LayerTypeAutoTile:
			if len(layer.AutoTiles) > 0 {
				raylibRenderer.beginLayer(layer, level.Width, level.Height)
				target := raylibRenderer.RenderedLayers[len(raylibRenderer.RenderedLayers)-1]
				rl.BeginTextureMode(target.Image)
				for _, tile := range layer.AutoTiles {
					raylibRenderer.renderTile(tile.Position[0]+layer.OffsetX, tile.Position[1]+layer.OffsetY, tile.Src[0], tile.Src[1], layer.GridSize, layer.GridSize, tile.Flip)
				}
				rl.EndTextureMode()
			}
		}
	}
	rl.EndDrawing()
	sort.Slice(raylibRenderer.RenderedLayers, func(i, j int) bool {
		return i > j
	})
}
Render clears, and then renders out each visible Layer in an ldtgo.Level instance.
package raylibrenderer
import (
	"path/filepath"
	"sort"
	rl "github.com/gen2brain/raylib-go/raylib"
	"github.com/solarlune/ldtkgo"
)
type TilesetLoader interface {
	LoadTileset(string) rl.Texture2D
}
type DiskLoader struct {
	BasePath string
}
func NewDiskLoader(basePath string) *DiskLoader {
	return &DiskLoader{
		BasePath: basePath,
	}
}
func (d *DiskLoader) LoadTileset(tilesetPath string) rl.Texture2D {
	return rl.LoadTexture(filepath.Join(d.BasePath, tilesetPath))
}
type RenderedLayer struct {
	Image rl.RenderTexture2D  
	Layer *ldtkgo.Layer       
}
type RaylibRenderer struct {
	Tilesets       map[string]rl.Texture2D
	CurrentTileset string
	RenderedLayers []*RenderedLayer
	Loader         TilesetLoader  
}
func NewRaylibRenderer(loader TilesetLoader) *RaylibRenderer {
	return &RaylibRenderer{
		Tilesets:       map[string]rl.Texture2D{},
		RenderedLayers: []*RenderedLayer{},
		Loader:         loader,
	}
}
func (raylibRenderer *RaylibRenderer) Clear() {
	for _, layer := range raylibRenderer.RenderedLayers {
		rl.UnloadRenderTexture(layer.Image)
	}
	raylibRenderer.RenderedLayers = []*RenderedLayer{}
}
func (raylibRenderer *RaylibRenderer) beginLayer(layer *ldtkgo.Layer, w, h int) {
	tilesetPath := layer.TilesetPath
	_, exists := raylibRenderer.Tilesets[tilesetPath]
	if !exists {
		raylibRenderer.Tilesets[tilesetPath] = raylibRenderer.Loader.LoadTileset(tilesetPath)
	}
	raylibRenderer.CurrentTileset = tilesetPath
	renderedImage := rl.LoadRenderTexture(int32(w), int32(h))
	raylibRenderer.RenderedLayers = append(raylibRenderer.RenderedLayers, &RenderedLayer{Image: renderedImage, Layer: layer})
}
func (raylibRenderer *RaylibRenderer) renderTile(x, y, srcX, srcY, srcW, srcH int, flipBit byte) {
	tileset := raylibRenderer.Tilesets[raylibRenderer.CurrentTileset]
	src := rl.NewRectangle(float32(srcX), float32(srcY), float32(srcW), float32(srcH))
	dst := src
	dst.X = float32(x)
	dst.Y = float32(y)
	if flipBit&1 > 0 {
		src.Width *= -1
	}
	if flipBit&2 > 0 {
		src.Height *= -1
	}
	rl.DrawTexturePro(tileset, src, dst, rl.Vector2{}, 0, rl.White)
}