Skip to content

GFX.Render

Name - Description Default Type
<input>
<output>
Steps Render steps to follow. None &[GFX.PipelineStep][GFX.PipelineStep]
View The view to render. (Optional) None &GFX.View

Details

This function should be used only once per rendered frame.

It takes a View or sequence of Views that represent the main camera as a parameter.

Info

If neither :View nor :Views is specified, the renderer will use a default view with both identity view and projection matrices.

The :Steps parameter contains the list of rendering operations to perform. This can be a sequence of objects created by one of the following:

Default queue

If no render queue is specified, this command reads from a global default queue.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(defshards spin-transform [t location]
  t
  (| (Math.Multiply 0.2) (Math.AxisAngleX) (Math.Rotation) >= .rotX)
  (| (Math.Multiply 0.7) (Math.AxisAngleY) (Math.Rotation) >= .rotY)
  (| (Math.Multiply 0.9) (Math.AxisAngleZ) (Math.Rotation) >= .rotZ)
  location (Math.Translation) (Math.MatMul .rotX) (Math.MatMul .rotY) (Math.MatMul .rotZ))

(def timestep (/ 1.0 120.0))

(GFX.MainWindow
:Contents
(->
(Setup
  ; Keep track of the time variable
 0.0 >= .time

  ; Load the built-in cube mesh
 (GFX.BuiltinMesh :Type BuiltinMeshType.Cube) >= .mesh

  ; Declare transform variable
 (Float3 0 0 0) (Math.Translation) >= .transform

  ; The queue that will contain the draw commands (just the cube)
  ; By default this queue it automatically cleared after it has been processed
 (GFX.DrawQueue) >= .queue

  ; Define a pass that renders the cube, with the built-in color and camera transform behaviour
 (GFX.BuiltinFeature BuiltinFeatureId.Transform) >> .features
 (GFX.BuiltinFeature  BuiltinFeatureId.BaseColor) >> .features
 (GFX.DrawablePass :Features .features :Queue .queue) >> .render-steps

  ; Setup the camera
 {:Position (Float3 0 0 8) :Target (Float3 0 0 0)} (Math.LookAt) >= .view-transform
 (GFX.View :View .view-transform) >= .view)

; Rotate the cube's transform
.time (Math.Add timestep) > .time
(spin-transform .time (Float3 0.0 0 0))

; Update and retrieve the drawable
; Note that the transform is the input 
(GFX.Drawable :Mesh .mesh :Params {:baseColor (Float4 0 1 0 1)}) >= .drawable

; Add drawable to the queue
.drawable (GFX.Draw .queue)

; Render everyghing
(GFX.Render :View .view :Steps .render-steps)))

Image

[info] Ignoring value inside a wire definition: #user-function(0000024B7E907BC0) ignore this warning if this was intentional.