Skip to content

Commit

Permalink
docs: expand demo test with a fbo size override and user zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
silenium-dev committed Oct 7, 2024
1 parent d11b55b commit b0eda7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {

testImplementation(compose.desktop.currentOs)
testImplementation(libs.logback.classic)
testImplementation("me.saket.telephoto:zoomable:0.13.0")
}

compose.desktop {
Expand Down
22 changes: 20 additions & 2 deletions src/test/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import dev.silenium.compose.gl.surface.GLSurfaceView
import dev.silenium.compose.gl.surface.Stats
import dev.silenium.compose.gl.surface.rememberGLSurfaceState
import kotlinx.coroutines.delay
import me.saket.telephoto.zoomable.ZoomSpec
import me.saket.telephoto.zoomable.rememberZoomableState
import me.saket.telephoto.zoomable.zoomable
import org.lwjgl.opengl.GL30.*
import kotlin.time.Duration.Companion.milliseconds

Expand All @@ -43,12 +46,27 @@ fun ApplicationScope.App() {
}
GLSurfaceView(
state = state,
modifier = Modifier.aspectRatio(1f).align(Alignment.Center),
modifier = Modifier
.aspectRatio(1f)
.zoomable(rememberZoomableState(ZoomSpec(6f)))
.align(Alignment.Center),
presentMode = GLSurfaceView.PresentMode.MAILBOX,
// fboSizeOverride = FBOSizeOverride(512, 512, TransformOrigin.Center),
fboSizeOverride = FBOSizeOverride(4096, 4096, TransformOrigin.Center),
) {
glClearColor(color.red, color.green, color.blue, color.alpha)
glClear(GL_COLOR_BUFFER_BIT)
glBegin(GL_QUADS)
// fat rectangle from top left to bottom right
glColor3f(1f, 0f, 0f)
glVertex2f(-1f, 0f)
glColor3f(0f, 1f, 0f)
glVertex2f(0f, -1f)
glColor3f(0f, 0f, 1f)
glVertex2f(1f, 0f)
glColor3f(1f, 1f, 1f)
glVertex2f(0f, 1f)
glEnd()

val wait = (1000.0 / 60).milliseconds
redrawAfter(wait)
}
Expand Down

0 comments on commit b0eda7d

Please sign in to comment.