From 0b62f067f6124434dbb87a145eb4ac61f6152e57 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sun, 15 Jan 2023 16:01:40 +0100 Subject: [PATCH] [orx-view-box] Fix color type configuration --- orx-view-box/src/commonMain/kotlin/ViewBox.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/orx-view-box/src/commonMain/kotlin/ViewBox.kt b/orx-view-box/src/commonMain/kotlin/ViewBox.kt index 7d00f152..0847c90b 100644 --- a/orx-view-box/src/commonMain/kotlin/ViewBox.kt +++ b/orx-view-box/src/commonMain/kotlin/ViewBox.kt @@ -13,6 +13,7 @@ class ViewBox( override val program: Program, var clientArea: Rectangle, translateMouse: Boolean = true, translateKeyboard: Boolean = true, + val colorType: ColorType? = null, val contentScale: Double? = null, val multisample: BufferMultisample? = null @@ -207,7 +208,13 @@ class ViewBox( val art = RenderTarget.active renderTarget = renderTarget(widthCeil, heightCeil, contentScale ?: art.contentScale, multisample ?: art.multisample) { - colorBuffer(type = art.colorBuffer(0).type) + colorBuffer( + type = colorType ?: if (art !is ProgramRenderTarget) { + art.colorBuffer(0).type + } else { + ColorType.UINT8 + } + ) depthBuffer() } if ((multisample ?: art.multisample) != BufferMultisample.Disabled) { @@ -258,11 +265,12 @@ fun Program.viewBox( area: Rectangle, translateMouse: Boolean = true, translateKeyboard: Boolean = true, + colorType: ColorType? = null, contentScale: Double? = null, multisample: BufferMultisample? = null, f: ViewBox.() -> Unit = {} ): ViewBox { - val viewBox = ViewBox(this, area, translateMouse, translateKeyboard, contentScale, multisample) + val viewBox = ViewBox(this, area, translateMouse, translateKeyboard, colorType, contentScale, multisample) viewBox.f() return viewBox } \ No newline at end of file