-
Notifications
You must be signed in to change notification settings - Fork 146
/
rlgl_cgo.go
949 lines (824 loc) · 25.3 KB
/
rlgl_cgo.go
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
package rl
/*
#include "raylib.h"
#include "rlgl.h"
#include <stdlib.h>
*/
import "C"
import (
"unsafe"
)
// SetMatrixProjection - Set a custom projection matrix (replaces internal projection matrix)
func SetMatrixProjection(proj Matrix) {
cproj := proj.cptr()
C.rlSetMatrixProjection(*cproj)
}
// SetMatrixModelview - Set a custom modelview matrix (replaces internal modelview matrix)
func SetMatrixModelview(view Matrix) {
cview := view.cptr()
C.rlSetMatrixModelview(*cview)
}
// BeginShaderMode - Begin custom shader drawing
func BeginShaderMode(shader Shader) {
cshader := shader.cptr()
C.BeginShaderMode(*cshader)
}
// EndShaderMode - End custom shader drawing (use default shader)
func EndShaderMode() {
C.EndShaderMode()
}
// BeginBlendMode - Begin blending mode (alpha, additive, multiplied)
func BeginBlendMode(mode BlendMode) {
cmode := (C.int)(mode)
C.BeginBlendMode(cmode)
}
// EndBlendMode - End blending mode (reset to default: alpha blending)
func EndBlendMode() {
C.EndBlendMode()
}
// MatrixMode - Choose the current matrix to be transformed
func MatrixMode(mode int32) {
cmode := C.int(mode)
C.rlMatrixMode(cmode)
}
// PushMatrix - Push the current matrix to stack
func PushMatrix() {
C.rlPushMatrix()
}
// PopMatrix - Pop lattest inserted matrix from stack
func PopMatrix() {
C.rlPopMatrix()
}
// LoadIdentity - Reset current matrix to identity matrix
func LoadIdentity() {
C.rlLoadIdentity()
}
// Translatef - Multiply the current matrix by a translation matrix
func Translatef(x float32, y float32, z float32) {
cx := C.float(x)
cy := C.float(y)
cz := C.float(z)
C.rlTranslatef(cx, cy, cz)
}
// Rotatef - Multiply the current matrix by a rotation matrix
func Rotatef(angle float32, x float32, y float32, z float32) {
cangle := C.float(angle)
cx := C.float(x)
cy := C.float(y)
cz := C.float(z)
C.rlRotatef(cangle, cx, cy, cz)
}
// Scalef - Multiply the current matrix by a scaling matrix
func Scalef(x float32, y float32, z float32) {
cx := C.float(x)
cy := C.float(y)
cz := C.float(z)
C.rlScalef(cx, cy, cz)
}
// Frustum .
func Frustum(left float64, right float64, bottom float64, top float64, znear float64, zfar float64) {
cleft := C.double(left)
cright := C.double(right)
cbottom := C.double(bottom)
ctop := C.double(top)
cznear := C.double(znear)
czfar := C.double(zfar)
C.rlFrustum(cleft, cright, cbottom, ctop, cznear, czfar)
}
// Ortho .
func Ortho(left float64, right float64, bottom float64, top float64, znear float64, zfar float64) {
cleft := C.double(left)
cright := C.double(right)
cbottom := C.double(bottom)
ctop := C.double(top)
cznear := C.double(znear)
czfar := C.double(zfar)
C.rlOrtho(cleft, cright, cbottom, ctop, cznear, czfar)
}
// Viewport - Set the viewport area
func Viewport(x int32, y int32, width int32, height int32) {
cx := C.int(x)
cy := C.int(y)
cwidth := C.int(width)
cheight := C.int(height)
C.rlViewport(cx, cy, cwidth, cheight)
}
// Begin - Initialize drawing mode (how to organize vertex)
func Begin(mode int32) {
cmode := C.int(mode)
C.rlBegin(cmode)
}
// End - Finish vertex providing
func End() {
C.rlEnd()
}
// Vertex2i - Define one vertex (position) - 2 int
func Vertex2i(x int32, y int32) {
cx := C.int(x)
cy := C.int(y)
C.rlVertex2i(cx, cy)
}
// Vertex2f - Define one vertex (position) - 2 float
func Vertex2f(x float32, y float32) {
cx := C.float(x)
cy := C.float(y)
C.rlVertex2f(cx, cy)
}
// Vertex3f - Define one vertex (position) - 3 float
func Vertex3f(x float32, y float32, z float32) {
cx := C.float(x)
cy := C.float(y)
cz := C.float(z)
C.rlVertex3f(cx, cy, cz)
}
// TexCoord2f - Define one vertex (texture coordinate) - 2 float
func TexCoord2f(x float32, y float32) {
cx := C.float(x)
cy := C.float(y)
C.rlTexCoord2f(cx, cy)
}
// Normal3f - Define one vertex (normal) - 3 float
func Normal3f(x float32, y float32, z float32) {
cx := C.float(x)
cy := C.float(y)
cz := C.float(z)
C.rlNormal3f(cx, cy, cz)
}
// Color4ub - Define one vertex (color) - 4 byte
func Color4ub(r uint8, g uint8, b uint8, a uint8) {
cr := C.uchar(r)
cg := C.uchar(g)
cb := C.uchar(b)
ca := C.uchar(a)
C.rlColor4ub(cr, cg, cb, ca)
}
// Color3f - Define one vertex (color) - 3 float
func Color3f(x float32, y float32, z float32) {
cx := C.float(x)
cy := C.float(y)
cz := C.float(z)
C.rlColor3f(cx, cy, cz)
}
// Color4f - Define one vertex (color) - 4 float
func Color4f(x float32, y float32, z float32, w float32) {
cx := C.float(x)
cy := C.float(y)
cz := C.float(z)
cw := C.float(w)
C.rlColor4f(cx, cy, cz, cw)
}
// EnableVertexArray - Enable vertex array (VAO, if supported)
func EnableVertexArray(vaoId uint32) bool {
cvaoId := C.uint(vaoId)
return bool(C.rlEnableVertexArray(cvaoId))
}
// DisableVertexArray - Disable vertex array (VAO, if supported)
func DisableVertexArray() {
C.rlDisableVertexArray()
}
// EnableVertexBuffer - Enable vertex buffer (VBO)
func EnableVertexBuffer(id uint32) {
cid := C.uint(id)
C.rlEnableVertexBuffer(cid)
}
// DisableVertexBuffer - Disable vertex buffer (VBO)
func DisableVertexBuffer() {
C.rlDisableVertexBuffer()
}
// EnableVertexBufferElement - Enable vertex buffer element (VBO element)
func EnableVertexBufferElement(id uint32) {
cid := C.uint(id)
C.rlEnableVertexBufferElement(cid)
}
// DisableVertexBufferElement - Disable vertex buffer element (VBO element)
func DisableVertexBufferElement() {
C.rlDisableVertexBufferElement()
}
// EnableVertexAttribute - Enable vertex attribute index
func EnableVertexAttribute(index uint32) {
cindex := C.uint(index)
C.rlEnableVertexAttribute(cindex)
}
// DisableVertexAttribute - Disable vertex attribute index
func DisableVertexAttribute(index uint32) {
cindex := C.uint(index)
C.rlDisableVertexAttribute(cindex)
}
// ActiveTextureSlot - Select and active a texture slot
func ActiveTextureSlot(slot int32) {
cslot := C.int(slot)
C.rlActiveTextureSlot(cslot)
}
// EnableTexture - Enable texture
func EnableTexture(id uint32) {
cid := C.uint(id)
C.rlEnableTexture(cid)
}
// DisableTexture - Disable texture
func DisableTexture() {
C.rlDisableTexture()
}
// EnableTextureCubemap - Enable texture cubemap
func EnableTextureCubemap(id uint32) {
cid := C.uint(id)
C.rlEnableTextureCubemap(cid)
}
// DisableTextureCubemap - Disable texture cubemap
func DisableTextureCubemap() {
C.rlDisableTextureCubemap()
}
// TextureParameters - Set texture parameters (filter, wrap)
func TextureParameters(id uint32, param int32, value int32) {
cid := C.uint(id)
cparam := C.int(param)
cvalue := C.int(value)
C.rlTextureParameters(cid, cparam, cvalue)
}
// CubemapParameters - Set cubemap parameters (filter, wrap)
func CubemapParameters(id uint32, param int32, value int32) {
cid := C.uint(id)
cparam := C.int(param)
cvalue := C.int(value)
C.rlCubemapParameters(cid, cparam, cvalue)
}
// EnableShader - Enable shader program
func EnableShader(id uint32) {
cid := C.uint(id)
C.rlEnableShader(cid)
}
// DisableShader - Disable shader program
func DisableShader() {
C.rlDisableShader()
}
// EnableFramebuffer - Enable render texture (fbo)
func EnableFramebuffer(id uint32) {
cid := C.uint(id)
C.rlEnableFramebuffer(cid)
}
// DisableFramebuffer - Disable render texture (fbo), return to default framebuffer
func DisableFramebuffer() {
C.rlDisableFramebuffer()
}
// ActiveDrawBuffers - Activate multiple draw color buffers
func ActiveDrawBuffers(count int32) {
ccount := C.int(count)
C.rlActiveDrawBuffers(ccount)
}
// EnableColorBlend - Enable color blending
func EnableColorBlend() {
C.rlEnableColorBlend()
}
// DisableColorBlend - Disable color blending
func DisableColorBlend() {
C.rlDisableColorBlend()
}
// EnableDepthTest - Enable depth test
func EnableDepthTest() {
C.rlEnableDepthTest()
}
// DisableDepthTest - Disable depth test
func DisableDepthTest() {
C.rlDisableDepthTest()
}
// EnableDepthMask - Enable depth write
func EnableDepthMask() {
C.rlEnableDepthMask()
}
// DisableDepthMask - Disable depth write
func DisableDepthMask() {
C.rlDisableDepthMask()
}
// EnableBackfaceCulling - Enable backface culling
func EnableBackfaceCulling() {
C.rlEnableBackfaceCulling()
}
// DisableBackfaceCulling - Disable backface culling
func DisableBackfaceCulling() {
C.rlDisableBackfaceCulling()
}
// SetCullFace - Set face culling mode
func SetCullFace(mode int32) {
cmode := C.int(mode)
C.rlSetCullFace(cmode)
}
// EnableScissorTest - Enable scissor test
func EnableScissorTest() {
C.rlEnableScissorTest()
}
// DisableScissorTest - Disable scissor test
func DisableScissorTest() {
C.rlDisableScissorTest()
}
// Scissor - Scissor test
func Scissor(x int32, y int32, width int32, height int32) {
cx := C.int(x)
cy := C.int(y)
cwidth := C.int(width)
cheight := C.int(height)
C.rlScissor(cx, cy, cwidth, cheight)
}
// EnableWireMode - Enable wire mode
func EnableWireMode() {
C.rlEnableWireMode()
}
// EnablePointMode - Enable point mode
func EnablePointMode() {
C.rlEnablePointMode()
}
// DisableWireMode - Disable wire mode
func DisableWireMode() {
C.rlDisableWireMode()
}
// SetLineWidth - Set the line drawing width
func SetLineWidth(width float32) {
cwidth := C.float(width)
C.rlSetLineWidth(cwidth)
}
// GetLineWidth - Get the line drawing width
func GetLineWidth() float32 {
return float32(C.rlGetLineWidth())
}
// EnableSmoothLines - Enable line aliasing
func EnableSmoothLines() {
C.rlEnableSmoothLines()
}
// DisableSmoothLines - Disable line aliasing
func DisableSmoothLines() {
C.rlDisableSmoothLines()
}
// EnableStereoRender - Enable stereo rendering
func EnableStereoRender() {
C.rlEnableStereoRender()
}
// DisableStereoRender - Disable stereo rendering
func DisableStereoRender() {
C.rlDisableStereoRender()
}
// IsStereoRenderEnabled - Check if stereo render is enabled
func IsStereoRenderEnabled() bool {
return bool(C.rlIsStereoRenderEnabled())
}
// ClearColor - Clear color buffer with color
func ClearColor(r uint8, g uint8, b uint8, a uint8) {
cr := C.uchar(r)
cg := C.uchar(g)
cb := C.uchar(b)
ca := C.uchar(a)
C.rlClearColor(cr, cg, cb, ca)
}
// ClearScreenBuffers - Clear used screen buffers (color and depth)
func ClearScreenBuffers() {
C.rlClearScreenBuffers()
}
// CheckErrors - Check and log OpenGL error codes
func CheckErrors() {
C.rlCheckErrors()
}
// SetBlendMode - Set blending mode
func SetBlendMode(mode int32) {
cmode := C.int(mode)
C.rlSetBlendMode(cmode)
}
// SetBlendFactors - Set blending mode factor and equation (using OpenGL factors)
func SetBlendFactors(glSrcFactor int32, glDstFactor int32, glEquation int32) {
cglSrcFactor := C.int(glSrcFactor)
cglDstFactor := C.int(glDstFactor)
cglEquation := C.int(glEquation)
C.rlSetBlendFactors(cglSrcFactor, cglDstFactor, cglEquation)
}
// SetBlendFactorsSeparate - Set blending mode factors and equations separately (using OpenGL factors)
func SetBlendFactorsSeparate(glSrcRGB int32, glDstRGB int32, glSrcAlpha int32, glDstAlpha int32, glEqRGB int32, glEqAlpha int32) {
cglSrcRGB := C.int(glSrcRGB)
cglDstRGB := C.int(glDstRGB)
cglSrcAlpha := C.int(glSrcAlpha)
cglDstAlpha := C.int(glDstAlpha)
cglEqRGB := C.int(glEqRGB)
cglEqAlpha := C.int(glEqAlpha)
C.rlSetBlendFactorsSeparate(cglSrcRGB, cglDstRGB, cglSrcAlpha, cglDstAlpha, cglEqRGB, cglEqAlpha)
}
// GlInit - Initialize rlgl (buffers, shaders, textures, states)
func GlInit(width int32, height int32) {
cwidth := C.int(width)
cheight := C.int(height)
C.rlglInit(cwidth, cheight)
}
// GlClose - De-inititialize rlgl (buffers, shaders, textures)
func GlClose() {
C.rlglClose()
}
// GetVersion - Get current OpenGL version
func GetVersion() int32 {
return int32(C.rlGetVersion())
}
// SetFramebufferWidth - Set current framebuffer width
func SetFramebufferWidth(width int32) {
cwidth := C.int(width)
C.rlSetFramebufferWidth(cwidth)
}
// GetFramebufferWidth - Get default framebuffer width
func GetFramebufferWidth() int32 {
return int32(C.rlGetFramebufferWidth())
}
// SetFramebufferHeight - Set current framebuffer height
func SetFramebufferHeight(height int32) {
cheight := C.int(height)
C.rlSetFramebufferHeight(cheight)
}
// GetFramebufferHeight - Get default framebuffer height
func GetFramebufferHeight() int32 {
return int32(C.rlGetFramebufferHeight())
}
// GetTextureIdDefault - Get default texture id
func GetTextureIdDefault() uint32 {
return uint32(C.rlGetTextureIdDefault())
}
// GetShaderIdDefault - Get default shader id
func GetShaderIdDefault() uint32 {
return uint32(C.rlGetShaderIdDefault())
}
// LoadRenderBatch - Load a render batch system
func LoadRenderBatch(numBuffers int32, bufferElements int32) RenderBatch {
ret := C.rlLoadRenderBatch(C.int(numBuffers), C.int(bufferElements))
return *(*RenderBatch)(unsafe.Pointer(&ret))
}
// UnloadRenderBatch - Unload render batch system
func UnloadRenderBatch(batch RenderBatch) {
C.rlUnloadRenderBatch(*(*C.rlRenderBatch)(unsafe.Pointer(&batch)))
}
// DrawRenderBatch - Draw render batch data (Update->Draw->Reset)
func DrawRenderBatch(batch *RenderBatch) {
C.rlDrawRenderBatch((*C.rlRenderBatch)(unsafe.Pointer(batch)))
}
// SetRenderBatchActive - Set the active render batch for rlgl (NULL for default internal)
func SetRenderBatchActive(batch *RenderBatch) {
C.rlSetRenderBatchActive((*C.rlRenderBatch)(unsafe.Pointer(batch)))
}
// DrawRenderBatchActive - Update and draw internal render batch
func DrawRenderBatchActive() {
C.rlDrawRenderBatchActive()
}
// CheckRenderBatchLimit - Check internal buffer overflow for a given number of vertex
func CheckRenderBatchLimit(vCount int32) bool {
cvCount := C.int(vCount)
return bool(C.rlCheckRenderBatchLimit(cvCount))
}
// SetTexture - Set current texture for render batch and check buffers limits
func SetTexture(id uint32) {
cid := C.uint(id)
C.rlSetTexture(cid)
}
// LoadVertexArray - Load vertex array (vao) if supported
func LoadVertexArray() uint32 {
return uint32(C.rlLoadVertexArray())
}
// UnloadVertexBuffer .
func UnloadVertexBuffer(vboId uint32) {
cvboId := C.uint(vboId)
C.rlUnloadVertexBuffer(cvboId)
}
// SetVertexAttributeDivisor .
func SetVertexAttributeDivisor(index uint32, divisor int32) {
cindex := C.uint(index)
cdivisor := C.int(divisor)
C.rlSetVertexAttributeDivisor(cindex, cdivisor)
}
// LoadTextureDepth - Load depth texture/renderbuffer (to be attached to fbo)
func LoadTextureDepth(width, height int32, useRenderBuffer bool) {
cwidth := C.int(width)
cheight := C.int(height)
cuseRenderBuffer := C.bool(useRenderBuffer)
C.rlLoadTextureDepth(cwidth, cheight, cuseRenderBuffer)
}
// LoadFramebuffer - Load an empty framebuffer
func LoadFramebuffer(width int32, height int32) uint32 {
return uint32(C.rlLoadFramebuffer())
}
// FramebufferAttach - Attach texture/renderbuffer to a framebuffer
func FramebufferAttach(fboId uint32, texId uint32, attachType int32, texType int32, mipLevel int32) {
cfboId := C.uint(fboId)
ctexId := C.uint(texId)
cattachType := C.int(attachType)
ctexType := C.int(texType)
cmipLevel := C.int(mipLevel)
C.rlFramebufferAttach(cfboId, ctexId, cattachType, ctexType, cmipLevel)
}
// FramebufferComplete - Verify framebuffer is complete
func FramebufferComplete(id uint32) bool {
cid := C.uint(id)
return bool(C.rlFramebufferComplete(cid))
}
// UnloadFramebuffer - Delete framebuffer from GPU
func UnloadFramebuffer(id uint32) {
cid := C.uint(id)
C.rlUnloadFramebuffer(cid)
}
// LoadShaderCode - Load shader from code strings
func LoadShaderCode(vsCode string, fsCode string) uint32 {
cvsCode := C.CString(vsCode)
defer C.free(unsafe.Pointer(cvsCode))
cfsCode := C.CString(fsCode)
defer C.free(unsafe.Pointer(cfsCode))
return uint32(C.rlLoadShaderCode(cvsCode, cfsCode))
}
// CompileShader - Compile custom shader and return shader id (type: VERTEX_SHADER, FRAGMENT_SHADER, COMPUTE_SHADER)
func CompileShader(shaderCode string, type_ int32) uint32 {
cshaderCode := C.CString(shaderCode)
defer C.free(unsafe.Pointer(cshaderCode))
ctype_ := C.int(type_)
return uint32(C.rlCompileShader(cshaderCode, ctype_))
}
// LoadShaderProgram - Load custom shader program
func LoadShaderProgram(vShaderId uint32, fShaderId uint32) uint32 {
cvShaderId := C.uint(vShaderId)
cfShaderId := C.uint(fShaderId)
return uint32(C.rlLoadShaderProgram(cvShaderId, cfShaderId))
}
// UnloadShaderProgram - Unload shader program
func UnloadShaderProgram(id uint32) {
cid := C.uint(id)
C.rlUnloadShaderProgram(cid)
}
// GetLocationUniform - Get shader location uniform
func GetLocationUniform(shaderId uint32, uniformName string) int32 {
cshaderId := C.uint(shaderId)
cuniformName := C.CString(uniformName)
defer C.free(unsafe.Pointer(cuniformName))
return int32(C.rlGetLocationUniform(cshaderId, cuniformName))
}
// GetLocationAttrib - Get shader location attribute
func GetLocationAttrib(shaderId uint32, attribName string) int32 {
cshaderId := C.uint(shaderId)
cattribName := C.CString(attribName)
defer C.free(unsafe.Pointer(cattribName))
return int32(C.rlGetLocationAttrib(cshaderId, cattribName))
}
// SetUniformSampler - Set shader value sampler
func SetUniformSampler(locIndex int32, textureId uint32) {
clocIndex := C.int(locIndex)
ctextureId := C.uint(textureId)
C.rlSetUniformSampler(clocIndex, ctextureId)
}
// LoadComputeShaderProgram -
func LoadComputeShaderProgram(shaderID uint32) uint32 {
cshaderID := C.uint(shaderID)
return uint32(C.rlLoadComputeShaderProgram(cshaderID))
}
// ComputeShaderDispatch - Dispatch compute shader (equivalent to *draw* for graphics pilepine)
func ComputeShaderDispatch(groupX uint32, groupY uint32, groupZ uint32) {
cgroupX := C.uint(groupX)
cgroupY := C.uint(groupY)
cgroupZ := C.uint(groupZ)
C.rlComputeShaderDispatch(cgroupX, cgroupY, cgroupZ)
}
// LoadShaderBuffer - Load shader storage buffer object (SSBO)
func LoadShaderBuffer(size uint32, data unsafe.Pointer, usageHint int32) uint32 {
csize := C.uint(size)
cdata := data
cusageHint := C.int(usageHint)
return uint32(C.rlLoadShaderBuffer(csize, cdata, cusageHint))
}
// UnloadShaderBuffer - Unload shader storage buffer object (SSBO)
func UnloadShaderBuffer(id uint32) {
cid := C.uint(id)
C.rlUnloadShaderBuffer(cid)
}
// UpdateShaderBuffer - Update SSBO buffer data
func UpdateShaderBuffer(id uint32, data unsafe.Pointer, dataSize uint32, offset uint32) {
cid := C.uint(id)
cdata := data
cdataSize := C.uint(dataSize)
coffset := C.uint(offset)
C.rlUpdateShaderBuffer(cid, cdata, cdataSize, coffset)
}
// BindShaderBuffer - Bind SSBO buffer
func BindShaderBuffer(id uint32, index uint32) {
cid := C.uint(id)
cindex := C.uint(index)
C.rlBindShaderBuffer(cid, cindex)
}
// ReadShaderBuffer - Read SSBO buffer data (GPU->CPU)
func ReadShaderBuffer(id uint32, dest unsafe.Pointer, count uint32, offset uint32) {
cid := C.uint(id)
cdest := dest
ccount := C.uint(count)
coffset := C.uint(offset)
C.rlReadShaderBuffer(cid, cdest, ccount, coffset)
}
// CopyShaderBuffer - Copy SSBO data between buffers
func CopyShaderBuffer(destId uint32, srcId uint32, destOffset uint32, srcOffset uint32, count uint32) {
cdestId := C.uint(destId)
csrcId := C.uint(srcId)
cdestOffset := C.uint(destOffset)
csrcOffset := C.uint(srcOffset)
ccount := C.uint(count)
C.rlCopyShaderBuffer(cdestId, csrcId, cdestOffset, csrcOffset, ccount)
}
// GetShaderBufferSize - Get SSBO buffer size
func GetShaderBufferSize(id uint32) uint32 {
cid := C.uint(id)
return uint32(C.rlGetShaderBufferSize(cid))
}
// BindImageTexture - Bind image texture
func BindImageTexture(id uint32, index uint32, format int32, readonly bool) {
cid := C.uint(id)
cindex := C.uint(index)
cformat := C.int(format)
creadonly := C.bool(readonly)
C.rlBindImageTexture(cid, cindex, cformat, creadonly)
}
// GetMatrixModelview - Get internal modelview matrix
func GetMatrixModelview() Matrix {
cResult := C.rlGetMatrixModelview()
var goRes Matrix
goRes.M4 = float32(cResult.m4)
goRes.M2 = float32(cResult.m2)
goRes.M14 = float32(cResult.m14)
goRes.M3 = float32(cResult.m3)
goRes.M7 = float32(cResult.m7)
goRes.M12 = float32(cResult.m12)
goRes.M6 = float32(cResult.m6)
goRes.M15 = float32(cResult.m15)
goRes.M5 = float32(cResult.m5)
goRes.M9 = float32(cResult.m9)
goRes.M13 = float32(cResult.m13)
goRes.M10 = float32(cResult.m10)
goRes.M11 = float32(cResult.m11)
goRes.M0 = float32(cResult.m0)
goRes.M8 = float32(cResult.m8)
goRes.M1 = float32(cResult.m1)
return goRes
}
// GetMatrixProjection - Get internal projection matrix
func GetMatrixProjection() Matrix {
cResult := C.rlGetMatrixProjection()
var goRes Matrix
goRes.M13 = float32(cResult.m13)
goRes.M10 = float32(cResult.m10)
goRes.M11 = float32(cResult.m11)
goRes.M15 = float32(cResult.m15)
goRes.M5 = float32(cResult.m5)
goRes.M9 = float32(cResult.m9)
goRes.M1 = float32(cResult.m1)
goRes.M0 = float32(cResult.m0)
goRes.M8 = float32(cResult.m8)
goRes.M14 = float32(cResult.m14)
goRes.M3 = float32(cResult.m3)
goRes.M7 = float32(cResult.m7)
goRes.M4 = float32(cResult.m4)
goRes.M2 = float32(cResult.m2)
goRes.M12 = float32(cResult.m12)
goRes.M6 = float32(cResult.m6)
return goRes
}
// GetMatrixTransform - Get internal accumulated transform matrix
func GetMatrixTransform() Matrix {
cResult := C.rlGetMatrixTransform()
var goRes Matrix
goRes.M0 = float32(cResult.m0)
goRes.M8 = float32(cResult.m8)
goRes.M1 = float32(cResult.m1)
goRes.M7 = float32(cResult.m7)
goRes.M4 = float32(cResult.m4)
goRes.M2 = float32(cResult.m2)
goRes.M14 = float32(cResult.m14)
goRes.M3 = float32(cResult.m3)
goRes.M12 = float32(cResult.m12)
goRes.M6 = float32(cResult.m6)
goRes.M11 = float32(cResult.m11)
goRes.M15 = float32(cResult.m15)
goRes.M5 = float32(cResult.m5)
goRes.M9 = float32(cResult.m9)
goRes.M13 = float32(cResult.m13)
goRes.M10 = float32(cResult.m10)
return goRes
}
// GetMatrixProjectionStereo - Get internal projection matrix for stereo render (selected eye)
func GetMatrixProjectionStereo(eye int32) Matrix {
ceye := C.int(eye)
cResult := C.rlGetMatrixProjectionStereo(ceye)
var goRes Matrix
goRes.M12 = float32(cResult.m12)
goRes.M6 = float32(cResult.m6)
goRes.M15 = float32(cResult.m15)
goRes.M5 = float32(cResult.m5)
goRes.M9 = float32(cResult.m9)
goRes.M13 = float32(cResult.m13)
goRes.M10 = float32(cResult.m10)
goRes.M11 = float32(cResult.m11)
goRes.M0 = float32(cResult.m0)
goRes.M8 = float32(cResult.m8)
goRes.M1 = float32(cResult.m1)
goRes.M4 = float32(cResult.m4)
goRes.M2 = float32(cResult.m2)
goRes.M14 = float32(cResult.m14)
goRes.M3 = float32(cResult.m3)
goRes.M7 = float32(cResult.m7)
return goRes
}
// GetMatrixViewOffsetStereo - Get internal view offset matrix for stereo render (selected eye)
func GetMatrixViewOffsetStereo(eye int32) Matrix {
ceye := C.int(eye)
cResult := C.rlGetMatrixViewOffsetStereo(ceye)
var goRes Matrix
goRes.M0 = float32(cResult.m0)
goRes.M8 = float32(cResult.m8)
goRes.M1 = float32(cResult.m1)
goRes.M4 = float32(cResult.m4)
goRes.M2 = float32(cResult.m2)
goRes.M14 = float32(cResult.m14)
goRes.M3 = float32(cResult.m3)
goRes.M7 = float32(cResult.m7)
goRes.M12 = float32(cResult.m12)
goRes.M6 = float32(cResult.m6)
goRes.M5 = float32(cResult.m5)
goRes.M9 = float32(cResult.m9)
goRes.M13 = float32(cResult.m13)
goRes.M10 = float32(cResult.m10)
goRes.M11 = float32(cResult.m11)
goRes.M15 = float32(cResult.m15)
return goRes
}
// SetMatrixProjectionStereo - Set eyes projection matrices for stereo rendering
func SetMatrixProjectionStereo(right Matrix, left Matrix) {
var cright C.struct_Matrix
cright.m12 = C.float(right.M12)
cright.m6 = C.float(right.M6)
cright.m5 = C.float(right.M5)
cright.m9 = C.float(right.M9)
cright.m13 = C.float(right.M13)
cright.m10 = C.float(right.M10)
cright.m11 = C.float(right.M11)
cright.m15 = C.float(right.M15)
cright.m0 = C.float(right.M0)
cright.m8 = C.float(right.M8)
cright.m1 = C.float(right.M1)
cright.m4 = C.float(right.M4)
cright.m2 = C.float(right.M2)
cright.m14 = C.float(right.M14)
cright.m3 = C.float(right.M3)
cright.m7 = C.float(right.M7)
var cleft C.struct_Matrix
cleft.m10 = C.float(left.M10)
cleft.m11 = C.float(left.M11)
cleft.m15 = C.float(left.M15)
cleft.m5 = C.float(left.M5)
cleft.m9 = C.float(left.M9)
cleft.m13 = C.float(left.M13)
cleft.m0 = C.float(left.M0)
cleft.m8 = C.float(left.M8)
cleft.m1 = C.float(left.M1)
cleft.m3 = C.float(left.M3)
cleft.m7 = C.float(left.M7)
cleft.m4 = C.float(left.M4)
cleft.m2 = C.float(left.M2)
cleft.m14 = C.float(left.M14)
cleft.m12 = C.float(left.M12)
cleft.m6 = C.float(left.M6)
C.rlSetMatrixProjectionStereo(cright, cleft)
}
// SetMatrixViewOffsetStereo - Set eyes view offsets matrices for stereo rendering
func SetMatrixViewOffsetStereo(right Matrix, left Matrix) {
var cright C.struct_Matrix
cright.m12 = C.float(right.M12)
cright.m6 = C.float(right.M6)
cright.m5 = C.float(right.M5)
cright.m9 = C.float(right.M9)
cright.m13 = C.float(right.M13)
cright.m10 = C.float(right.M10)
cright.m11 = C.float(right.M11)
cright.m15 = C.float(right.M15)
cright.m0 = C.float(right.M0)
cright.m8 = C.float(right.M8)
cright.m1 = C.float(right.M1)
cright.m4 = C.float(right.M4)
cright.m2 = C.float(right.M2)
cright.m14 = C.float(right.M14)
cright.m3 = C.float(right.M3)
cright.m7 = C.float(right.M7)
var cleft C.struct_Matrix
cleft.m12 = C.float(left.M12)
cleft.m6 = C.float(left.M6)
cleft.m5 = C.float(left.M5)
cleft.m9 = C.float(left.M9)
cleft.m13 = C.float(left.M13)
cleft.m10 = C.float(left.M10)
cleft.m11 = C.float(left.M11)
cleft.m15 = C.float(left.M15)
cleft.m0 = C.float(left.M0)
cleft.m8 = C.float(left.M8)
cleft.m1 = C.float(left.M1)
cleft.m4 = C.float(left.M4)
cleft.m2 = C.float(left.M2)
cleft.m14 = C.float(left.M14)
cleft.m3 = C.float(left.M3)
cleft.m7 = C.float(left.M7)
C.rlSetMatrixViewOffsetStereo(cright, cleft)
}
// LoadDrawCube - Load and draw a cube
func LoadDrawCube() {
C.rlLoadDrawCube()
}
// LoadDrawQuad - Load and draw a quad
func LoadDrawQuad() {
C.rlLoadDrawQuad()
}