Add RenderConfig#initialBuilderCapacity
This commit is contained in:
parent
386d71b92f
commit
0f4b7ace07
@ -54,6 +54,8 @@ class VertexBuilder(
|
||||
val defaultMode: GeometryType? = null,
|
||||
initialCapacity: Int = 64
|
||||
) {
|
||||
constructor(attributes: GLAttributeList, initialCapacity: Int) : this(attributes, null, initialCapacity)
|
||||
|
||||
init {
|
||||
require(initialCapacity > 0) { "Invalid capacity: $initialCapacity" }
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class MultiMeshBuilder {
|
||||
fun get(config: RenderConfig<*>, layer: Int): VertexBuilder {
|
||||
return meshes.computeIfAbsent(config, Reference2ObjectFunction {
|
||||
Int2ObjectOpenHashMap()
|
||||
}).computeIfAbsent(layer, Int2ObjectFunction { Entry(config, VertexBuilder(config.program.attributes), layer) }).builder
|
||||
}).computeIfAbsent(layer, Int2ObjectFunction { Entry(config, VertexBuilder(config.program.attributes, config.initialBuilderCapacity), layer) }).builder
|
||||
}
|
||||
|
||||
fun clear() = meshes.clear()
|
||||
|
@ -5,6 +5,7 @@ import ru.dbotthepony.kvector.arrays.Matrix4f
|
||||
|
||||
abstract class RenderConfig<out T : GLShaderProgram>(val program: T) {
|
||||
val state get() = program.state
|
||||
open val initialBuilderCapacity: Int get() = 64
|
||||
|
||||
open fun setup(transform: Matrix4f = state.matrixStack.last()) {
|
||||
program.use()
|
||||
|
@ -44,6 +44,9 @@ class TileRenderers(val client: StarboundClient) {
|
||||
}
|
||||
|
||||
private inner class Config(private val texture: GLTexture2D, private val color: RGBAColor) : RenderConfig<GLTileProgram>(state.programs.tile) {
|
||||
override val initialBuilderCapacity: Int
|
||||
get() = 1024
|
||||
|
||||
override fun setup(transform: Matrix4f) {
|
||||
super.setup(transform)
|
||||
state.activeTexture = 0
|
||||
|
Loading…
Reference in New Issue
Block a user