Удалён тестовый код
This commit is contained in:
parent
fe7529d208
commit
76e5357b32
@ -214,99 +214,6 @@ class TileRenderer(val state: GLStateTracker, val tile: TileDefinition) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
val fx = pos.x.toFloat()
|
||||
val fy = pos.y.toFloat()
|
||||
|
||||
val a = fx
|
||||
val b = fy
|
||||
|
||||
val c = fx + 1f
|
||||
val d = fy + 1f
|
||||
|
||||
val piece = tile.render.renderTemplate.pieces[tile.render.renderTemplate.representativePiece]!!
|
||||
|
||||
if (tile.render.variants == 0) {
|
||||
val (u0, v0) = texture.pixelToUV(piece.texturePosition)
|
||||
val (u1, v1) = texture.pixelToUV(piece.texturePosition + piece.textureSize)
|
||||
|
||||
builder.quadZ(b, a, d, c, 1f, VertexTransformers.uv(u0, v0, u1, v1))
|
||||
} else {
|
||||
val variant = (getter.randomDoubleFor(pos) * tile.render.variants).toInt()
|
||||
|
||||
val (u0, v0) = texture.pixelToUV(piece.texturePosition + piece.variantStride!! * variant)
|
||||
val (u1, v1) = texture.pixelToUV(piece.texturePosition + piece.textureSize + piece.variantStride * variant)
|
||||
|
||||
builder.quadZ(b, a, d, c, 1f, VertexTransformers.uv(u0, v0, u1, v1))
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
fun renderPiece() {
|
||||
val vao = state.newVAO()
|
||||
val vbo = state.newVBO()
|
||||
val ebo = state.newEBO()
|
||||
|
||||
vao.bind()
|
||||
vbo.bind()
|
||||
|
||||
val base = tile.render.renderTemplate!!.pieces["base"]!!
|
||||
|
||||
val builder = GLFlatAttributeListBuilder.VERTEX_TEXTURE.vertexBuilder(VertexType.QUADS)
|
||||
|
||||
run {
|
||||
val pos1 = base.texturePosition + base.variantStride!! * (glfwGetTime() % 15).toInt()
|
||||
val pos2 = base.texturePosition + base.textureSize + base.variantStride * (glfwGetTime() % 15).toInt()
|
||||
|
||||
val (u0, v0) = texture.pixelToUV(pos1)
|
||||
val (u1, v1) = texture.pixelToUV(pos2)
|
||||
|
||||
builder.quadZ(-1f, -1f, 1f, 1f, 0f, VertexTransformers.uv(u0, v0, u1, v1))
|
||||
}
|
||||
|
||||
run {
|
||||
val pos1 = base.texturePosition + base.variantStride!! * ((glfwGetTime() + 1) % 15).toInt()
|
||||
val pos2 = base.texturePosition + base.textureSize + base.variantStride * ((glfwGetTime() + 1) % 15).toInt()
|
||||
|
||||
val (u0, v0) = texture.pixelToUV(pos1)
|
||||
val (u1, v1) = texture.pixelToUV(pos2)
|
||||
|
||||
builder.quadZ(-3f, -1f, -1f, 1f, 0f, VertexTransformers.uv(u0, v0, u1, v1))
|
||||
}
|
||||
|
||||
run {
|
||||
val pos1 = base.texturePosition + base.variantStride!! * ((glfwGetTime() + 2) % 15).toInt()
|
||||
val pos2 = base.texturePosition + base.textureSize + base.variantStride * ((glfwGetTime() + 2) % 15).toInt()
|
||||
|
||||
val (u0, v0) = texture.pixelToUV(pos1)
|
||||
val (u1, v1) = texture.pixelToUV(pos2)
|
||||
|
||||
builder.quadZ(3f, -1f, 1f, 1f, 0f, VertexTransformers.uv(u0, v0, u1, v1))
|
||||
}
|
||||
|
||||
builder.upload(vbo, ebo, GL_STREAM_DRAW)
|
||||
GLFlatAttributeListBuilder.VERTEX_TEXTURE.apply(vao, enable = true)
|
||||
|
||||
state.shaderVertexTexture.use()
|
||||
|
||||
state.activeTexture = 0
|
||||
texture.bind()
|
||||
|
||||
state.shaderVertexTexture["_texture"] = 0
|
||||
state.shaderVertexTexture["_transform"] = Matrix4f.IDENTITY.scale(0.5f, 0.5f)
|
||||
|
||||
texture.textureMagFilter = GL_NEAREST
|
||||
texture.textureMinFilter = GL_NEAREST_MIPMAP_NEAREST
|
||||
|
||||
vbo.bind()
|
||||
ebo.bind()
|
||||
glDrawElements(GL_TRIANGLES, builder.indexCount, GL_UNSIGNED_INT, 0L)
|
||||
checkForGLError()
|
||||
|
||||
vao.close()
|
||||
vbo.close()
|
||||
ebo.close()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
Loading…
Reference in New Issue
Block a user