Package: graphene

Macro graphene:with-object

Lambda List

graphene:with-object ((var type &rest args) &body body)

Syntax

(graphene:with-object (obj type &rest args) body) => result

Arguments

obj -- a Graphene instance to create and initialize
type -- a symbol for a Graphene type
args -- arguments for initializing the Graphene instance

Details

The graphene:with-object macro allocates an new Graphene instance for the given Graphene type, initializes the Graphene instance with given values and executes the body that uses the Graphene instance. After execution of the body the allocated memory for the Graphene instance is released.

The type argument can have one of the following values to create and initialize a corresponding Graphene instance:
graphene:point-t
See the graphene:with-point macro.
graphene:point3d-t
See the graphene:with-point3d macro.
graphene:size-t
See the graphene:with-size macro.
graphene:rect-t
See the graphene:with-rect macro.
graphene:quad-t
See the graphene:with-quad macro.
graphene:triangle-t
See the graphene:with-triangle macro.
graphene:box-t
See the graphene:with-box macro.
graphene:sphere-t
See the graphene:with-sphere macro.
graphene:frustum-t
See the graphene:with-frustum macro.
graphene:vec2-t
See the graphene:with-vec2 macro.
graphene:vec3-t
See the graphene:with-vec3 macro.
graphene:vec4-t
See the graphene:with-vec4 macro.
graphene:matrix-t
See the graphene:with-matrix macro.
graphene:euler-t
See the graphene:with-euler macro.
graphene:quaternion-t
See the graphene:with-quaternion macro.
graphene:plane-t
See the graphene:with-plane macro.
graphene:ray-t
See the graphene:with-ray macro.

Examples

Initalize a graphene:point-t instance with default values:
* (macroexpand '(graphene:with-object (p graphene:point-t) p))
(LET ((P (GRAPHENE:POINT-ALLOC)))
  (GRAPHENE:POINT-INIT P 0.0 0.0)
  (UNWIND-PROTECT (PROGN P) (GRAPHENE:POINT-FREE P)))
T    
Initialize a graphene:with-point instance with two values:
* (macroexpand '(graphene:with-object (p graphene:point-t 1 2) p))
(LET ((P (GRAPHENE:POINT-ALLOC)))
  (GRAPHENE:POINT-INIT P 1 2)
  (UNWIND-PROTECT (PROGN P) (GRAPHENE:POINT-FREE P)))
T    
 

See also

2025-4-7