From a94b51eb0dd3464b80cb2438e5eeb9a16dee3fe9 Mon Sep 17 00:00:00 2001 From: Arhik Date: Sat, 21 Oct 2023 20:03:37 +0530 Subject: [PATCH] Fixing mesh cube with wireframe example. Though this made to work. There is an underlying problem with it. `RenderType` defined as `WIREFRAME` alone leads to unintialized `WorldObject`. --- examples/meshCubeWireFrame.jl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/examples/meshCubeWireFrame.jl b/examples/meshCubeWireFrame.jl index 9198be5..a5759f5 100644 --- a/examples/meshCubeWireFrame.jl +++ b/examples/meshCubeWireFrame.jl @@ -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) @@ -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