-
Notifications
You must be signed in to change notification settings - Fork 1
/
scene-mixin.lisp
executable file
·2170 lines (1956 loc) · 164 KB
/
scene-mixin.lisp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(in-package :krma)
(eval-when (:compile-toplevel :load-toplevel)
(when *muffle-compilation-notes*
#+sbcl(declaim (sb-ext:muffle-conditions sb-ext:compiler-note))))
(eval-when (:compile-toplevel :load-toplevel)
(when krma::*debug*
(declaim (optimize (safety 3) (debug 3))))
(unless krma::*debug*
(declaim (optimize (speed 3) (safety 0) (debug 0)))))
(defcstruct 3DMatrix
(m00 :float)
(m10 :float)
(m20 :float)
(m30 :float)
(m01 :float)
(m11 :float)
(m21 :float)
(m31 :float)
(m02 :float)
(m12 :float)
(m22 :float)
(m32 :float)
(m03 :float)
(m13 :float)
(m23 :float)
(m33 :float))
(defun copy-matrix-to-foreign (lisp-matrix p-matrix)
;; arrays in 3d-math are column major internally
;; matrices in glsl are also column major
(let ((array (3dm::marr lisp-matrix)))
(loop for i from 0 below 4
do (loop for j from 0 below 4
do (setf (mem-aref p-matrix :float (+ j (* i 4)))
(clampf (aref array (+ j (* i 4)))))))
(values)))
#+NIL
(defun copy-matrix-to-foreign (lisp-matrix p-matrix)
(let ((array (3dm.f::marr4 lisp-matrix)))
(sb-sys:with-pinned-objects (array)
(vk::memcpy p-matrix (sb-sys:vector-sap array) (load-time-value (* 16 (foreign-type-size :float))))))
(values))
(defcstruct vertex-uniform-buffer
(view (:struct 3DMatrix))
(proj (:struct 3DMatrix))
(vproj (:struct 3DMatrix)))
(defcstruct fragment-uniform-buffer
(lights (:array (:struct light) 10))
(num-lights :unsigned-int)
(scene-ambient :unsigned-int)
(padding1 :unsigned-int)
(padding2 :unsigned-int))
(defun update-fragment-uniform-buffer (pipeline scene)
(let ((lights (scene-lights scene)))
(with-foreign-object (p-stage '(:struct fragment-uniform-buffer))
(let ((p-lights (foreign-slot-pointer p-stage '(:struct fragment-uniform-buffer) 'lights)))
(loop for i from 0 for light in lights
when (typep light 'light-mixin)
do (let ((p-light (mem-aptr p-lights '(:struct light) i)))
(with-slots (position
diffuse
specular
constant-attenuation
linear-attenuation
quadratic-attenuation
spot-cutoff
spot-exponent
spot-direction)
light
(setf (foreign-slot-value p-light '(:struct light) 'pos-x) (clampf (vx position))
(foreign-slot-value p-light '(:struct light) 'pos-y) (clampf (vy position))
(foreign-slot-value p-light '(:struct light) 'pos-z) (clampf (vz position))
(foreign-slot-value p-light '(:struct light) 'pos-w) (typecase light
(directional-light 0.0f0)
(light-mixin 1.0f0)
(t 0.0f0))
(foreign-slot-value p-light '(:struct light) 'diffuse) (canonicalize-color diffuse)
(foreign-slot-value p-light '(:struct light) 'specular) (canonicalize-color specular)
(foreign-slot-value p-light '(:struct light) 'constant-attenuation) (clampf constant-attenuation)
(foreign-slot-value p-light '(:struct light) 'linear-attenuation) (clampf linear-attenuation)
(foreign-slot-value p-light '(:struct light) 'quadratic-attenuation) (clampf quadratic-attenuation)
(foreign-slot-value p-light '(:struct light) 'spot-cutoff) (clampf spot-cutoff)
(foreign-slot-value p-light '(:struct light) 'spot-exponent) (clampf spot-exponent)
(foreign-slot-value p-light '(:struct light) 'spot-direction-x) (clampf (vx spot-direction))
(foreign-slot-value p-light '(:struct light) 'spot-direction-y) (clampf (vy spot-direction))
(foreign-slot-value p-light '(:struct light) 'spot-direction-z) (clampf (vz spot-direction)))))
finally (setf (foreign-slot-value p-stage '(:struct fragment-uniform-buffer) 'num-lights) i)
(setf (foreign-slot-value p-stage '(:struct fragment-uniform-buffer) 'scene-ambient) (canonicalize-color
(scene-ambient scene)))
(copy-uniform-buffer-memory (default-logical-device pipeline)
p-stage
(allocated-memory (pipeline-fragment-uniform-buffer pipeline))
(load-time-value (foreign-type-size '(:struct fragment-uniform-buffer))))))))
(values))
(defclass krma-essential-scene-mixin ()
((application :initarg :app :reader scene-application)
(dpy :accessor scene-display)
(im-draw-data :accessor im-draw-data)
(rm-draw-data :accessor rm-draw-data)
(lights :initform (list (make-instance 'directional-light)) :accessor scene-lights)
(3d-camera-projection-matrix)
(3d-camera-view-matrix)
(2d-camera-projection-matrix)
(2d-camera-view-matrix)
(ambient :initform *default-scene-ambient* :accessor scene-ambient)
(children :initform () :accessor node-children))
(:documentation "Absract base class for application scenes in krma. Define your own scene classes with this mixin as a superclass."))
#+sbcl
(defun finalize-scene (scene)
(let ((draw-data (im-draw-data scene)))
(sb-ext:finalize scene
#'(lambda ()
(%purge-im-groups-1 draw-data))
:dont-save t)))
#+ccl
(defun finalize-scene (scene))
(defmethod initialize-instance :after ((instance krma-essential-scene-mixin) &rest initargs &key (display (default-display))
&allow-other-keys)
(declare (ignore initargs))
(setf (scene-display instance) display)
(setf (im-draw-data instance) (make-immediate-mode-draw-data "IM Draw Data" (scene-display instance)))
(setf (rm-draw-data instance) (make-array 2 :initial-contents
(list
(make-retained-mode-draw-data "RM Draw Data 0" (scene-display instance))
(make-retained-mode-draw-data "RM Draw Data 1" (scene-display instance)))))
(finalize-scene instance)
(values))
(defclass standard-scene (krma-essential-scene-mixin)
()
(:documentation "A concrete scene class based on krma-essential-scene-mixin used in krma-test-application."))
#+DELETEME
(defmethod update-2d-camera (scene &optional
(proj (mortho-vulkan 0 640 480 0 0 1024))
(view (mlookat (vec3 0 0 -1024) (vec3 0 0 0) (vec3 0 1 0))))
"Function which takes a projection matrix and a view matrix from a 2d-camera and stores it in the scene so that the scene need not know about the camera class directly. Called before render-scene."
(declare (type krma-essential-scene-mixin scene))
(with-slots (2d-camera-projection-matrix
2d-camera-view-matrix)
scene
(setf 2d-camera-projection-matrix proj)
(setf 2d-camera-view-matrix view)
(values)))
#+DELETEME
(defmethod update-3d-camera (scene &optional
(proj (mperspective-vulkan
45 (/ 640 480)
*default-znear* *default-zfar*)
#+NIL(mortho-vulkan -1500 1500
(* -1500 (/ 640 480))
(* 1500 (/ 640 480))
*default-znear* *default-zfar*))
(view (mlookat (vec3 0 0 1500) (vec3 0 0 0) (vec3 0 1 0))))
"Function which takes a projection matrix and a view matrix from a 3d-camera and stores it in the scene so that the scene need not know about the camera class directly. Called before render-scene."
(declare (type krma-essential-scene-mixin scene))
(with-slots (3d-camera-projection-matrix
3d-camera-view-matrix)
scene
(setf 3d-camera-projection-matrix proj)
(setf 3d-camera-view-matrix view)
(values)))
(defmethod render-scene ((scene krma-essential-scene-mixin)
viewport dpy command-buffer rm-draw-data im-draw-data)
(render-3d-scene scene viewport dpy command-buffer rm-draw-data im-draw-data)
(vkCmdNextSubpass (h command-buffer) VK_SUBPASS_CONTENTS_INLINE)
(render-2d-scene scene viewport dpy command-buffer rm-draw-data im-draw-data)
(values))
(defmethod render-2d-scene ((scene krma-essential-scene-mixin)
viewport dpy command-buffer rm-draw-data im-draw-data)
"The default method to render krma scenes. You can define your own methods for your own scene classes and call-next-method if you like."
;; todo: think about having separate clos objects for 3d-scene and 2d-scene
(let ((device (default-logical-device dpy))
(pipeline-store (krma-pipeline-store dpy)))
(with-slots (x y width height 2d-camera 3d-camera) viewport
(let ((2d-camera-projection-matrix (camera-proj-matrix 2d-camera))
(2d-camera-view-matrix (camera-view-matrix 2d-camera)))
(loop for (p dl) on (2d-cmd-oriented-combinations pipeline-store rm-draw-data) by #'cddr
do (render-draw-list-cmds p rm-draw-data dl dpy device command-buffer
scene
2d-camera-view-matrix 2d-camera-projection-matrix
viewport))
(loop for (p dl) on (2d-draw-list-oriented-combinations pipeline-store rm-draw-data) by #'cddr
do (render-draw-list p rm-draw-data dl dpy device command-buffer
scene
2d-camera-view-matrix 2d-camera-projection-matrix
viewport))
(loop for (p dl) on (2d-cmd-oriented-combinations pipeline-store im-draw-data) by #'cddr
do (render-draw-list-cmds p im-draw-data dl dpy device command-buffer
scene
2d-camera-view-matrix 2d-camera-projection-matrix
viewport))
(loop for (p dl) on (2d-draw-list-oriented-combinations pipeline-store im-draw-data) by #'cddr
do (render-draw-list p im-draw-data dl dpy device command-buffer
scene
2d-camera-view-matrix 2d-camera-projection-matrix
viewport))
(values)))))
(defmethod render-3d-scene ((scene krma-essential-scene-mixin)
viewport dpy command-buffer rm-draw-data im-draw-data)
"The default method to render krma scenes. You can define your own methods for your own scene classes and call-next-method if you like."
;; todo: think about having separate clos objects for 3d-scene and 2d-scene
(let ((device (default-logical-device dpy))
(pipeline-store (krma-pipeline-store dpy)))
(with-slots (x y width height 2d-camera 3d-camera) viewport
(let ((3d-camera-projection-matrix (camera-proj-matrix 3d-camera))
(3d-camera-view-matrix (camera-view-matrix 3d-camera)))
;;(print 2d-camera-projection-matrix)
;;(print 2d-camera-view-matrix)
(loop for (p dl) on (3d-draw-list-oriented-combinations pipeline-store rm-draw-data) by #'cddr
do (render-draw-list p rm-draw-data dl dpy device command-buffer
scene
3d-camera-view-matrix 3d-camera-projection-matrix
viewport))
(loop for (p dl) on (3d-cmd-oriented-combinations pipeline-store rm-draw-data) by #'cddr
do (render-draw-list-cmds p rm-draw-data dl dpy device command-buffer
scene
3d-camera-view-matrix 3d-camera-projection-matrix
viewport))
(loop for (p dl) on (3d-draw-list-oriented-combinations pipeline-store im-draw-data) by #'cddr
do (render-draw-list p im-draw-data dl dpy device command-buffer
scene
3d-camera-view-matrix 3d-camera-projection-matrix
viewport))
(loop for (p dl) on (3d-cmd-oriented-combinations pipeline-store im-draw-data) by #'cddr
do (render-draw-list-cmds p im-draw-data dl dpy device command-buffer
scene
3d-camera-view-matrix 3d-camera-projection-matrix
viewport))
(values)))))
;; 2d-point
(defun scene-add-2d-point-primitive (scene group model-matrix point-size color x y &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 2d point primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), point-size should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. and x and y must be real numbers. Dispatches actual work to render thread. To delete the point, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x y))
(declare (type (unsigned-byte 32) object-id))
(declare (type (or mat4 null) model-matrix))
(declare (type atom group))
;; we try to run code which potentially errors outside of render-thread
;; the body of rm-dispatch-to-render-thread-with-handle becomes a closure
(setq color (canonicalize-color color))
(setq x (clampf x))
(setq y (clampf y))
(setq elevation (clampf elevation))
(setq point-size (clampf point-size))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-2d-point-primitive draw-data handle object-id group (when model-matrix (mcopy model-matrix)) point-size color elevation x y)))
(defun scene-add-2d-point (scene group point-size color x y &optional (object-id 0) (elevation 0))
"Retained-mode function, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, point-size should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. and x and y must be real numbers. Dispatches actual work to render thread. To delete the point, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x y))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq x (clampf x))
(setq y (clampf y))
(setq elevation (clampf elevation))
(setq point-size (clampf point-size))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-2d-point draw-data object-id group point-size color elevation x y)))
(defun scene-draw-2d-point (scene group point-size color x y &optional (object-id 0) (elevation 0))
"Immediate-mode function, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, point-size should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. and x and y must be real numbers. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x y point-size))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq point-size (clampf point-size))
(let ((draw-data (im-draw-data scene)))
(declare (type standard-draw-data draw-data))
(%draw-data-draw-2d-point draw-data object-id group point-size (canonicalize-color color) (clampf elevation) (clampf x) (clampf y))))
;; 3d-point
(defun scene-add-3d-point-primitive (scene group model-matrix point-size color x y z &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 3d point primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), point-size should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, and x, y and z must be real numbers. Dispatches actual work to render thread. To delete the point, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x y z point-size))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq x (clampf x))
(setq y (clampf y))
(setq z (clampf z))
(setq elevation (clampf elevation))
(setq point-size (clampf point-size))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-3d-point-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) point-size color elevation x y z)))
(defun scene-add-3d-point (scene group point-size color x y z &optional (object-id 0))
"Retained-mode function, adds a point to retained-mode draw-lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, point-size should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, and x and y must be real numbers. Dispatches actual work to render thread. To delete the point, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x y z point-size))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq x (clampf x))
(setq y (clampf y))
(setq z (clampf z))
(setq point-size (clampf point-size))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-3d-point draw-data object-id group point-size color x y z)))
(defun scene-draw-3d-point (scene group point-size color x y z &optional (object-id 0))
"Immediate-mode function, draws a 3d point, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, point-size should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, and x, y and z must be real numbers. Performs work in current thread, which should be the render thread."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x y z))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-3d-point draw-data object-id group (clampf point-size)
(canonicalize-color color) (clampf x) (clampf y) (clampf z))))
;; 2d-line
(defun scene-add-2d-line-primitive (scene group model-matrix line-thickness color x0 y0 x1 y1 &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 2d line primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0 and x1, y1 must be real numbers which represent the endpoints of the line. Dispatches actual work to render thread. To delete the line segment, you must delete the primitive using the handle."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 line-thickness))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq elevation (clampf elevation))
(setq line-thickness (clampf line-thickness))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-2d-line-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) line-thickness color elevation x0 y0 x1 y1)))
(defun scene-add-2d-line (scene group line-thickness color x0 y0 x1 y1 &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a 2d line segment to draw lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0 and x1, y1 must be real numbers which represent the endpoints of the line. Dispatches actual work to render thread. To delete the line segment, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-2d-line draw-data object-id group line-thickness color elevation x0 y0 x1 y1)))
(defun scene-draw-2d-line (scene group line-thickness color x0 y0 x1 y1 &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a 2d line segment. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0 and x1, y1 must be real numbers which represent the endpoints of the line. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-2d-line draw-data object-id group (clampf line-thickness)
(canonicalize-color color) (clampf elevation) (clampf x0) (clampf y0) (clampf x1) (clampf y1))))
;; 3d-line
(defun scene-add-3d-line-primitive (scene group model-matrix line-thickness color x0 y0 z0 x1 y1 z1 &optional (object-id 0))
"Retained-mode function, returns a handle for a 3d line primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, z0 and x1, y1, z1 must be real numbers which represent the endpoints of the line. Dispatches actual work to render thread. To delete the line segment, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 z0 x1 y1 z1 line-thickness))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq z0 (clampf z0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq z1 (clampf z1))
(setq line-thickness (clampf line-thickness))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-3d-line-primitive draw-data handle object-id group (when model-matrix (mcopy model-matrix)) line-thickness color x0 y0 z0 x1 y1 z1)))
(defun scene-add-3d-line (scene group line-thickness color x0 y0 z0 x1 y1 z1 &optional (object-id 0))
"Retained-mode function, adds a 3d line segment to the draw lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, z0 and x1, y1, z1 must be real numbers which represent the endpoints of the line. Dispatches actual work to render thread. To delete the line you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 z0 x1 y1 z1 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq z0 (clampf z0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq z1 (clampf z1))
(setq line-thickness (clampf line-thickness))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-3d-line draw-data object-id group line-thickness color x0 y0 z0 x1 y1 z1)))
(defun scene-draw-3d-line (scene group line-thickness color x0 y0 z0 x1 y1 z1 &optional (object-id 0))
"Retained-mode function, adds a 3d line segment to the draw lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, z0 and x1, y1, z1 must be real numbers which represent the endpoints of the line. Dispatches actual work to render thread. To delete the line you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x0 x1 y1 z1 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-3d-line draw-data object-id group (clampf line-thickness) (canonicalize-color color)
(clampf x0) (clampf y0) (clampf z0)
(clampf x1) (clampf y1) (clampf z1))))
;; 2d-polyline
(defun scene-add-2d-polyline-primitive (scene group model-matrix closed? line-thickness color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 2d polyline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. vertices should be of the form (list x0 y0 x1 y1 ... xn yn) where the x's and the y's are vertex points of the polyline and must be real numbers. Dispatches actual work to render thread. To delete the polyline, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-2d-polyline-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) closed? line-thickness color elevation vertices)))
(defun scene-add-2d-polyline (scene group closed? line-thickness color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a 2d polyline to the draw lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. vertices should be of the form (list x0 y0 x1 y1 ... xn yn) where the x's and the y's are vertex points of the polyline and must be real numbers. Dispatches actual work to render thread. To delete the polyline, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-2d-polyline draw-data object-id group closed? line-thickness color elevation vertices)))
(defun scene-draw-2d-polyline (scene group closed? line-thickness color vertices &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a 2d polyline. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. vertices should be of the form (list x0 y0 x1 y1 ... xn yn) where the x's and the y's are vertex points of the polyline and must be real numbers. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-2d-polyline
draw-data object-id group closed? (clampf line-thickness) (canonicalize-color color) (clampf elevation) vertices)))
;; 2d-triangle
(defun scene-add-2d-triangle-primitive (scene group model-matrix line-thickness color x0 y0 x1 y1 x2 y2 &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 2d triangle outline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, x1, y1, x2 and y2 are the three vertex coordinates of the triangle and must be real numbers. Dispatches actual work to render thread. To delete the triangle, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 x2 y2 line-thickness))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq x2 (clampf x2))
(setq y2 (clampf y2))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-2d-polyline-primitive draw-data handle object-id group
(when model-matrix (mcopy model-matrix)) t line-thickness color elevation
(list x0 y0 x1 y1 x2 y2))))
(defun scene-add-2d-triangle (scene group line-thickness color x0 y0 x1 y1 x2 y2 &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a 2d triangle outline to the draw lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, x1, y1, x2 and y2 are the three vertex coordinates of the triangle and must be real numbers. Dispatches actual work to render thread. To delete the triangle, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 x2 y2 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq x2 (clampf x2))
(setq y2 (clampf y2))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-2d-polyline draw-data object-id group t line-thickness color elevation
(list x0 y0 x1 y1 x2 y2))))
(defun scene-draw-2d-triangle (scene group line-thickness color x0 y0 x1 y1 x2 y2 &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a 2d triangle outline, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, x1, y1, x2 and y2 are the three vertex coordinates of the triangle and must be real numbers. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 x2 y2 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-2d-polyline draw-data object-id group t (clampf line-thickness) (canonicalize-color color) (clampf elevation)
(list x0 y0 x1 y1 x2 y2))))
;; 2d-rectangle
(defun scene-add-2d-rectangle-primitive (scene group model-matrix line-thickness color x0 y0 x1 y1 &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 2d rectangle outline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, x1, and y1 are the top-left and bottom-right corners of the rectangle and must be real numbers. Dispatches actual work to render thread. To delete the rectangle, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 line-thickness))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-2d-polyline-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) t line-thickness color elevation
(list x0 y0 x0 y1 x1 y1 x1 y0))))
(defun scene-add-2d-rectangle (scene group line-thickness color x0 y0 x1 y1 &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a 2d rectangle outline to the draw lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, x1, and y1 are the top-left and bottom-right corners of the rectangle and must be real numbers. Dispatches actual work to render thread. To delete the rectangle, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-2d-polyline draw-data object-id group t line-thickness color elevation
(list x0 y0 x0 y1 x1 y1 x1 y0))))
(defun scene-draw-2d-rectangle (scene group line-thickness color x0 y0 x1 y1 &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a 2d rectangle outline, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an a non-null atom, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. x0, y0, x1, and y1 are the top-left and bottom-right corners of the rectangle and must be real numbers. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real x0 y0 x1 y1 line-thickness))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(setq x0 (clampf x0))
(setq y0 (clampf y0))
(setq x1 (clampf x1))
(setq y1 (clampf y1))
(%draw-data-draw-2d-polyline draw-data object-id group t (clampf line-thickness) (canonicalize-color color) (clampf elevation)
(list x0 y0 x0 y1 x1 y1 x1 y0))))
;; multicolor-2d-polyline
(defun scene-add-multicolor-2d-polyline-primitive (scene group model-matrix closed? line-thickness vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a multicolored 2d polyline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. vertices should be of the form (list x0 y0 color0 x1 y1 color1 ... xn yn colorn) where the x's and the y's are vertex points of the polyline and must be real numbers, color values can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. Dispatches actual work to render thread. To delete the polyline, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-multicolor-2d-polyline-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) closed? line-thickness elevation vertices)))
(defun scene-add-multicolor-2d-polyline (scene group closed? line-thickness vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a multicolored 2d polyline to the draw lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. vertices should be of the form (list x0 y0 color0 x1 y1 color1 ... xn yn colorn) where the x's and the y's are vertex points of the polyline and must be real numbers, color values can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. Dispatches actual work to render thread. To delete the polyline, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (and atom t) group))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-multicolor-2d-polyline draw-data object-id group closed? line-thickness elevation vertices)))
(defun scene-draw-multicolor-2d-polyline (scene group closed? line-thickness vertices &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a multicolored 2d polyline, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. vertices should be of the form (list x0 y0 color0 x1 y1 color1 ... xn yn colorn) where the x's and the y's are vertex points of the polyline and must be real numbers, color values can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-multicolor-2d-polyline draw-data object-id group closed? (clampf line-thickness) (clampf elevation) vertices)))
;; 2d-circular-arc
(defun scene-add-2d-circular-arc-primitive (scene group model-matrix closed? line-thickness color
center-x center-y radius start-angle end-angle
number-of-segments &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 2d circular arc outline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. center-x, and center-y must be real numbers, radius must be a positive real number, start-angle and end-angle are real numbers, measured in radians. number-of-segments must be a positive integer, and defaults to 64. Dispatches actual work to render thread. To delete the arc, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type boolean closed?))
(declare (type real center-x center-y radius start-angle end-angle line-thickness))
(declare (type (integer 1 #.most-positive-fixnum) number-of-segments))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq center-x (coerce center-x 'double-float))
(setq center-y (coerce center-y 'double-float))
(setq radius (coerce radius 'double-float))
(setq start-angle (coerce start-angle 'double-float))
(setq end-angle (coerce end-angle 'double-float))
(setq color (canonicalize-color color))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-2d-circular-arc-primitive draw-data handle object-id group
(when model-matrix (mcopy model-matrix)) closed? line-thickness color elevation
center-x center-y radius start-angle end-angle
number-of-segments)))
(defun scene-add-2d-circular-arc (scene group closed? line-thickness color
center-x center-y radius start-angle end-angle
number-of-segments &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a 2d circular arc outline to the draw lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. center-x, and center-y must be real numbers, radius must be a positive real number, start-angle and end-angle are real numbers, measured in radians. number-of-segments must be a positive integer, and defaults to 64. Dispatches actual work to render thread. To delete the arc, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type boolean closed?))
(declare (type real center-x center-y radius start-angle end-angle line-thickness))
(declare (type (integer 1 #.most-positive-fixnum) number-of-segments))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq center-x (coerce center-x 'double-float))
(setq center-y (coerce center-y 'double-float))
(setq radius (coerce radius 'double-float))
(setq start-angle (coerce start-angle 'double-float))
(setq end-angle (coerce end-angle 'double-float))
(setq color (canonicalize-color color))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-2d-circular-arc draw-data object-id group closed? line-thickness color elevation
center-x center-y radius start-angle end-angle
number-of-segments)))
(defun scene-draw-2d-circular-arc (scene group closed? line-thickness color
center-x center-y radius start-angle end-angle
number-of-segments &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws 2d circular arc outline, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. center-x, and center-y must be real numbers, radius must be a positive real number, start-angle and end-angle are real numbers, measured in radians. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type boolean closed?))
(declare (type real center-x center-y radius start-angle end-angle))
(declare (type (integer 1 #.most-positive-fixnum) number-of-segments))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-2d-circular-arc draw-data object-id group closed? (clampf line-thickness) (canonicalize-color color) (clampf elevation)
(coerce center-x 'double-float) (coerce center-y 'double-float)
(coerce radius 'double-float)
(coerce start-angle 'double-float) (coerce end-angle 'double-float)
number-of-segments)))
;; 2d-circle
(defun scene-add-2d-circle-primitive (scene group model-matrix line-thickness color
center-x center-y radius
number-of-segments &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a 2d circle outline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), line-thickness should be a positive real number. color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. center-x, and center-y must be real numbers, radius must be a positive real number. number-of-segments must be a positive integer, and defaults to 64. Dispatches actual work to render thread. To delete the arc, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real center-x center-y radius line-thickness))
(declare (type (integer 1 #.most-positive-fixnum) number-of-segments))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq center-x (coerce center-x 'double-float))
(setq center-y (coerce center-y 'double-float))
(setq radius (coerce radius 'double-float))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-2d-circle-primitive draw-data handle object-id group
(when model-matrix (mcopy model-matrix)) line-thickness color elevation
center-x center-y radius
number-of-segments)))
(defun scene-add-2d-circle (scene group line-thickness color
center-x center-y radius
number-of-segments &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a 2d circle outline to the draw lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, line-thickness should be a positive real number. color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. center-x, and center-y must be real numbers, radius must be a positive real number. number-of-segments must be a positive integer, and defaults to 64. Dispatches actual work to render thread. To delete the arc, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real center-x center-y radius line-thickness))
(declare (type (integer 1 #.most-positive-fixnum) number-of-segments))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq center-x (coerce center-x 'double-float))
(setq center-y (coerce center-y 'double-float))
(setq radius (coerce radius 'double-float))
(setq line-thickness (clampf line-thickness))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-2d-circle draw-data object-id
group line-thickness color elevation
center-x center-y radius
number-of-segments)))
(defun scene-draw-2d-circle (scene group line-thickness color
center-x center-y radius
number-of-segments &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a 2d circle outline, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, line-thickness should be a positive real number. color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. center-x, and center-y must be real numbers, radius must be a positive real number. number-of-segments must be a positive integer, and defaults to 64. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real center-x center-y radius))
(declare (type (integer 1 #.most-positive-fixnum) number-of-segments))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-2d-circle draw-data object-id group (clampf line-thickness) (canonicalize-color color) (clampf elevation)
(coerce center-x 'double-float) (coerce center-y 'double-float)
(coerce radius 'double-float)
number-of-segments)))
;; 3d-polyline
(defun scene-add-3d-polyline-primitive (scene group model-matrix closed? line-thickness color vertices &optional (object-id 0))
"Retained-mode function, returns a handle for a 3d polyline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. vertices should be of the form (list x0 y0 z0 x1 y1 z1 ... xn yn zn) where the x, y and z's are the vertex points of the polyline and must be real numbers. Dispatches actual work to render thread. To delete the polyline, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq line-thickness (clampf line-thickness))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-3d-polyline-primitive draw-data handle object-id group (when model-matrix (mcopy model-matrix)) closed? line-thickness color vertices)))
(defun scene-add-3d-polyline (scene group closed? line-thickness color vertices &optional (object-id 0))
"Retained-mode function, adds a 3d polyline to the draw lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. vertices should be of the form (list x0 y0 z0 x1 y1 z1 ... xn yn zn) where the x, y and z's are the vertex points of the polyline and must be real numbers. Dispatches actual work to render thread. To delete the polyline, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq line-thickness (clampf line-thickness))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-3d-polyline draw-data object-id group closed? line-thickness color vertices)))
(defun scene-draw-3d-polyline (scene group closed? line-thickness color vertices &optional (object-id 0))
"Immediate-mode function, draws a 3d polyline. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. vertices should be of the form (list x0 y0 z0 x1 y1 z1 ... xn yn zn) where the x, y and z's are the vertex points of the polyline and must be real numbers. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-3d-polyline draw-data object-id group closed? (clampf line-thickness) (canonicalize-color color) vertices)))
;; multicolor-3d-polyline
(defun scene-add-multicolor-3d-polyline-primitive (scene group model-matrix closed? line-thickness vertices &optional (object-id 0))
"Retained-mode function, returns a handle for a multicolored 3d polyline primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. vertices should be of the form (list x0 y0 z0 color0 x1 y1 z1 color1 ... xn yn zn colorn) where the x, y and z's are vertex points of the polyline and must be real numbers, color values can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. Dispatches actual work to render thread. To delete the polyline, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq line-thickness (clampf line-thickness))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-multicolor-3d-polyline-primitive draw-data handle object-id group (when model-matrix (mcopy model-matrix)) closed? line-thickness vertices)))
(defun scene-add-multicolor-3d-polyline (scene group closed? line-thickness vertices &optional (object-id 0))
"Retained-mode function, adds a multicolored 3d polyline to the draw lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. vertices should be of the form (list x0 y0 z0 color0 x1 y1 z1 color1 ... xn yn zn colorn) where the x, y and z's are vertex points of the polyline and must be real numbers, color values can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. Dispatches actual work to render thread. To delete the polyline, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq line-thickness (clampf line-thickness))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-multicolor-3d-polyline draw-data object-id group closed? line-thickness vertices)))
(defun scene-draw-multicolor-3d-polyline (scene group closed? line-thickness vertices &optional (object-id 0))
"Immediate-mode function, draws a multicolored 3d polyline, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, closed? should be a boolean, which specifies whether to draw a segment between the last vertex and the first vertex, line-thickness should be a positive real number. vertices should be of the form (list x0 y0 z0 color0 x1 y1 z1 color1 ... xn yn zn colorn) where the x, y and z's are vertex points of the polyline and must be real numbers, color values can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type real line-thickness))
(declare (type boolean closed?))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-multicolor-3d-polyline draw-data object-id group closed? (clampf line-thickness) vertices)))
;; filled-2d-triangle-list
(defun scene-add-filled-2d-triangle-list-primitive (scene group model-matrix color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a filled 2d triangle list primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 x10 y10 x20 y20 x01 y01 x11 y11 x21 y21 ... x0n y0n x1n y1n x2n y2n) where the x and y values represent vertices of a triangle in a series of triangles and must be real numbers, Dispatches actual work to render thread. To delete the triangle list, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-filled-2d-triangle-list-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) color elevation vertices)))
(defun scene-add-filled-2d-triangle-list (scene group color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a filled 2d triangle list to the draw-lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 x10 y10 x20 y20 x01 y01 x11 y11 x21 y21 ... x0n y0n x1n y1n x2n y2n) where the x and y values represent vertices of a triangle in a series of triangles and must be real numbers, Dispatches actual work to render thread. To delete the triangle list, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-filled-2d-triangle-list draw-data object-id group color elevation vertices)))
(defun scene-draw-filled-2d-triangle-list (scene group color vertices &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a filled 2d triangle list. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 x10 y10 x20 y20 x01 y01 x11 y11 x21 y21 ... x0n y0n x1n y1n x2n y2n) where the x and y values represent vertices of a triangle in a series of triangles and must be real numbers, Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-filled-2d-triangle-list draw-data object-id group (canonicalize-color color) (clampf elevation) vertices)))
;; filled-2d-triangle-strip
(defun scene-add-filled-2d-triangle-strip-primitive (scene group model-matrix color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a filled 2d triangle strip primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x0 y0 x1 y1 ... xn yn) where the x and y values represent successive vertices of a triangle strip and must be real numbers, Dispatches actual work to render thread. To delete the triangle strip, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-filled-2d-triangle-strip-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) color elevation vertices)))
(defun scene-draw-filled-2d-triangle-strip (scene group color vertices &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a filled 2d triangle strip. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x0 y0 x1 y1 ... xn yn) where the x and y values represent successive vertices of a triangle strip and must be real numbers. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(declare (type immediate-mode-draw-data draw-data))
(let ((draw-list (draw-data-2d-triangle-strip-draw-list draw-data)))
;; we add the primitive/cmd without a handle:
(%draw-list-add-filled-2d-triangle-strip/list draw-list object-id group nil (canonicalize-color color) (clampf elevation) vertices))))
;; filled-2d-rectangle-list
(defun scene-add-filled-2d-rectangle-list-primitive (scene group model-matrix color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a filled 2d rectangle list primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 x10 y10 x10 y10 x11 y11 ... x0n y0n x1n y1n) where each pair of successive x and y's represent the top-left corner followed by the bottom-right corner of each rectangle and must be real numbers. Dispatches actual work to render thread. To delete the rectangle list, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-filled-2d-rectangle-list-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) color elevation vertices)))
(defun scene-add-filled-2d-rectangle-list (scene group color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a filled 2d rectangle list to the draw-lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 x10 y10 x10 y10 x11 y11 ... x0n y0n x1n y1n) where each pair of successive x and y's represent the top-left corner followed by the bottom-right corner of each rectangle and must be real numbers. Dispatches actual work to render thread. To delete the rectangle list, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-filled-2d-rectangle-list draw-data object-id group color elevation vertices)))
(defun scene-draw-filled-2d-rectangle-list (scene group color vertices &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a filled 2d rectangle list. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 x10 y10 x10 y10 x11 y11 ... x0n y0n x1n y1n) where each pair of successive x and y's represent the top-left corner followed by the bottom-right corner of each rectangle and must be real numbers. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (and atom t) group))
(let ((draw-data (im-draw-data scene)))
(%draw-data-draw-filled-2d-rectangle-list draw-data object-id group (canonicalize-color color) (clampf elevation) vertices)))
;; textured-2d-rectangle-list
(defun scene-add-textured-2d-rectangle-list-primitive (scene group model-matrix texture color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a textured 2d rectangle list primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), texture should be a texture such as return from make-vulkan-texture, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 u00 v00 x10 y10 u10 v10 x01 y01 u01 v01 x11 y11 u11 v11 ... x0n y0n u0n v0n x1n y1n u1n v1n) where each pair of successive x, y, u and v represent the top-left corner followed by the bottom-right corner of each rectangle with their normalized texture coordinates, and must be real numbers. There must be at least one pair of the sequence x, y, u, v. Dispatches actual work to render thread. To delete the rectangle list, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-textured-2d-rectangle-list-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) texture color elevation vertices)))
(defun scene-add-textured-2d-rectangle-list (scene group texture color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a textured 2d rectangle list to the draw-lists. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, texture should be a texture such as return from make-vulkan-texture, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 u00 v00 x10 y10 u10 v10 x01 y01 u01 v01 x11 y11 u11 v11 ... x0n y0n u0n v0n x1n y1n u1n v1n) where each pair of successive x, y, u and v represent the top-left corner followed by the bottom-right corner of each rectangle with their normalized texture coordinates, and must be real numbers. There must be at least one pair of the sequence x, y, u, v. Dispatches actual work to render thread. To delete the rectangle list, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-textured-2d-rectangle-list draw-data object-id group texture color elevation vertices)))
(defun scene-draw-textured-2d-rectangle-list (scene group texture color vertices &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a textured 2d rectangle list. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, texture should be a texture such as return from make-vulkan-texture, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x00 y00 u00 v00 x10 y10 u10 v10 x01 y01 u01 v01 x11 y11 u11 v11 ... x0n y0n u0n v0n x1n y1n u1n v1n) where each pair of successive x, y, u and v represent the top-left corner followed by the bottom-right corner of each rectangle with their normalized texture coordinates, and must be real numbers. There must be at least one pair of the sequence x, y, u, v. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(%draw-data-draw-textured-2d-rectangle-list
(im-draw-data scene) object-id group texture (canonicalize-color color) (clampf elevation) vertices))
;; filled-2d-convex-polygon
(defun scene-add-filled-2d-convex-polygon-primitive (scene group model-matrix color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, returns a handle for a filled 2d convex polygon primitive. Required arguments: scene must be of type krma-essential-scene-mixin, group must be an atom, possibly nil (meaning not associated with a group), model-matrix must either be a 3d-matrices:mat4 or nil (nil effectively means identity), color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x0 y0 x1 y1 ... xn yn) where each successive x and y are the vertices of the polygon, and must be real numbers. There must be at least three x, y pairs in vertices. Dispatches actual work to render thread. To delete the polygon, you must delete the primitive using the handle or delete the entire group, if any."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (or mat4 null) model-matrix))
(declare (type (unsigned-byte 32) object-id))
(declare (type atom group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread-with-handle (scene draw-data handle)
(%draw-data-add-filled-2d-convex-polygon-primitive
draw-data handle object-id group (when model-matrix (mcopy model-matrix)) color elevation vertices)))
(defun scene-add-filled-2d-convex-polygon (scene group color vertices &optional (object-id 0) (elevation 0))
"Retained-mode function, adds a filled 2d convex polygon to the draw-lists, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x0 y0 x1 y1 ... xn yn) where each successive x and y are the vertices of the polygon, and must be real numbers. There must be at least three x, y pairs in vertices. Dispatches actual work to render thread. To delete the polygon, you must delete the entire group."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(setq color (canonicalize-color color))
(setq elevation (clampf elevation))
(rm-dispatch-to-render-thread (scene draw-data)
(%draw-data-add-filled-2d-convex-polygon draw-data object-id group color elevation vertices)))
(defun scene-draw-filled-2d-convex-polygon (scene group color vertices &optional (object-id 0) (elevation 0))
"Immediate-mode function, draws a filled 2d convex polygon, returns no values. Required arguments: scene must be of type krma-essential-scene-mixin, group must be a non-null atom, color can either be a 4 component vector who's elements are real numbers between zero and one, or a 32 bit unsigned integer, vertices must be of the form (list x0 y0 x1 y1 ... xn yn) where each successive x and y are the vertices of the polygon, and must be real numbers. There must be at least three x, y pairs in vertices. Performs work in current thread, which should be the render thread. Effects of this function only last for the current frame."
(declare (type krma-essential-scene-mixin scene))
(declare (type sequence vertices))
(declare (type (unsigned-byte 32) object-id))
(declare (type (and atom t) group))
(%draw-data-draw-filled-2d-convex-polygon (im-draw-data scene) object-id group (canonicalize-color color) (clampf elevation) vertices))
;; filled-2d-circle
(declaim (inline compute-circle-vertices))
(defun compute-circle-vertices (fixnum-number-of-segments df-center-x df-center-y df-radius)
(declare (optimize (speed 3) (safety 0) (debug 3) (compilation-speed 3) (space 0)))
(declare (type fixnum fixnum-number-of-segments))
(declare (type double-float df-center-x df-center-y df-radius))