Skip to content

Commit

Permalink
Fixing mesh cube with wireframe example.
Browse files Browse the repository at this point in the history
Though this made to work. There is an underlying
problem with it.

`RenderType` defined as `WIREFRAME` alone leads to
unintialized `WorldObject`.
  • Loading branch information
arhik committed Oct 21, 2023
1 parent c30aae7 commit a94b51e
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions examples/meshCubeWireFrame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,31 @@ gpuDevice = scene.gpuDevice

renderer = getRenderer(scene)

mesh = WGPUgfx.defaultCube(
joinpath(pkgdir(WGPUgfx), "assets", "cube.obj")

mesh = WorldObject(
WGPUgfx.defaultWGPUMesh(
joinpath(pkgdir(WGPUgfx), "assets", "cube.obj")
),
RenderType(VISIBLE | SURFACE | BBOX ),
nothing,
nothing,
nothing,
nothing
)

wo = WorldObject{Cube}(
mesh,
RenderType(VISIBLE | WIREFRAME | AXIS),
wireFrame = WorldObject(
WGPUgfx.defaultWGPUMesh(
joinpath(pkgdir(WGPUgfx), "assets", "cube.obj")
),
RenderType(VISIBLE | WIREFRAME ),
nothing,
nothing,
nothing,
nothing
)

addObject!(renderer, wo)
addObject!(renderer, mesh)
addObject!(renderer, wireFrame)

attachEventSystem(renderer)

Expand All @@ -45,11 +56,11 @@ end
main = () -> begin
try
while !WindowShouldClose(canvas.windowRef[])
runApp(renderer)
tz = translate([sin(time()), 0, 0]).linear
mat = MMatrix{4, 4}(wo.uniformData)
mat = MMatrix{4, 4}(mesh.uniformData)
mat .= tz
wo.uniformData = mat
runApp(renderer)
mesh.uniformData = mat
PollEvents()
end
finally
Expand Down

0 comments on commit a94b51e

Please sign in to comment.