Skip to content

Commit 26fab9e

Browse files
authored
Fix few typos in code snippet on 'First render' page and add imports (#10)
1 parent 519696b commit 26fab9e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

_docs/starting/first-render.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ This tutorial assumes the [First Application](/docs/starting/first-application)
1010
The initial setup of render seems a bit daunting in WebGPU, especially if we are coming from an OpenGL background. In reality, it isn't as bad as it seems. LittleKt takes care of a lot of the work for us but also keeps things low-level enough that we can build on top of it. Let's render something!
1111

1212
```kotlin
13+
import com.littlekt.Context
14+
import com.littlekt.ContextListener
15+
import com.littlekt.file.vfs.readTexture
16+
import com.littlekt.graphics.Color
17+
import com.littlekt.graphics.webgpu.*
18+
import com.littlekt.graphics.g2d.*
19+
import com.littlekt.resources.Textures
20+
import com.littlekt.util.viewport.ExtendViewport
21+
1322
class MyGame(context: Context) : ContextListener(context) {
1423

1524
override suspend fun Context.start() {
@@ -19,7 +28,7 @@ class MyGame(context: Context) : ContextListener(context) {
1928

2029
val device = graphics.device // LittleKt creates a WebGPU adapter & a device from it. It's as simple as referencing it.
2130
val surfaceCapability = graphics.surfaceCapabilities // we grab the current graphics surface capabilities
22-
val preferredFromat = graphics.preferredFormat // what TextureFormat the surface prefers
31+
val preferredFormat = graphics.preferredFormat // what TextureFormat the surface prefers
2332

2433
// then we configure the surface
2534
graphics.configureSurface(
@@ -54,7 +63,7 @@ class MyGame(context: Context) : ContextListener(context) {
5463
val swapChainTexture: WebGPUTexture = checkNotNull(surfaceTexture.texture) // we need the underlying WebGPU texture, which may be null
5564
val frame: TextureView = swapChainTexture.createView() // we create the view of the texture! We can now use it as a color attachment in a render pass!
5665

57-
val commandEncoder: CommandEncoder = device.createCommandEncoder // handles creating commands to present to the surface
66+
val commandEncoder: CommandEncoder = device.createCommandEncoder() // handles creating commands to present to the surface
5867
val renderPassEncoder =
5968
commandEncoder.beginRenderPass(
6069
desc =
@@ -96,4 +105,4 @@ class MyGame(context: Context) : ContextListener(context) {
96105
}
97106
}
98107
}
99-
```
108+
```

0 commit comments

Comments
 (0)