[orx-mesh-generators] DemoAll: include loaded texture

This commit is contained in:
Abe Pazos
2025-01-31 17:18:20 +01:00
parent b7f6905a33
commit b86f3a9d02

View File

@@ -28,8 +28,8 @@ fun main() = application {
revolveMesh(5, 0.5) revolveMesh(5, 0.5)
) )
val texture = colorBuffer(256, 256) val texture1 = colorBuffer(256, 256)
val s = texture.shadow val s = texture1.shadow
for (y in 0 until 256) { for (y in 0 until 256) {
for (x in 0 until 256) { for (x in 0 until 256) {
s[x, y] = ColorRGBa(x / 256.0, y / 256.0, 0.0, 1.0) s[x, y] = ColorRGBa(x / 256.0, y / 256.0, 0.0, 1.0)
@@ -37,6 +37,8 @@ fun main() = application {
} }
s.upload() s.upload()
val texture2 = loadImage("demo-data/images/peopleCity01.jpg")
val positions = Rectangle.fromCenter(Vector2.ZERO, width * 0.01, height * 0.01) val positions = Rectangle.fromCenter(Vector2.ZERO, width * 0.01, height * 0.01)
.grid(4, 2).flatten().map { .grid(4, 2).flatten().map {
it.center.vector3(z = -5.0) it.center.vector3(z = -5.0)
@@ -53,7 +55,7 @@ fun main() = application {
x_fill = texture(p_texture, va_texCoord0.xy); x_fill = texture(p_texture, va_texCoord0.xy);
x_fill.rgb *= light; x_fill.rgb *= light;
""".trimIndent() """.trimIndent()
parameter("texture", texture) parameter("texture", if(mouse.position.x > drawer.bounds.center.x) texture2 else texture1)
parameter("light", Vector3(1.0).normalized) parameter("light", Vector3(1.0).normalized)
} }
meshes.forEachIndexed { i, mesh -> meshes.forEachIndexed { i, mesh ->