forked from MajorHard/vraylib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rlgl.v
189 lines (152 loc) · 4.38 KB
/
rlgl.v
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
module vraylib
pub struct C.Shader {
pub mut:
id u32
locs &u32
}
pub struct C.VrDeviceInfo {
pub mut:
hResolution int
vResolution int
hScreenSize f32
vScreenSize f32
vScreenCenter f32
eyeToScreenDistance f32
lensSeparationDistance f32
interpupillaryDistance f32
lensDistortionValues [4]f32
chromaAbCorrection [4]f32
}
pub const (
albedo = 0
diffuse = 0
metalness = 1
normal = 2
roughness = 4
occlusion = 5
emission = 6
height = 7
cubemap = 8
irradiance = 9
prefilter = 10
brdf = 11
)
// // Shader loading/unloading functions
//
// Load chars array from text file
[inline] pub fn load_text(fileName string) string {
return string(byteptr(fileName.str))
}
// Load shader from files and bind default locations
[inline] pub fn load_shader(vsFileName, fsFileName string) Shader {
return C.LoadShader(vsFileName.str, fsFileName.str)
}
// Load shader from code strings and bind default locations
[inline] pub fn load_shader_code(vsCode string, fsCode string) Shader {
return C.LoadShaderCode(vsCode.str, fsCode.str)
}
// Unload shader from GPU memory (VRAM)
[inline] pub fn unload_shader(shader Shader) {
C.UnloadShader(shader)
}
// Get default shader
[inline] pub fn get_shader_default() Shader {
return C.GetShaderDefault()
}
// Get default texture
[inline] pub fn get_texture_default() Texture2D {
return C.GetTextureDefault()
}
// Shader configuration functions
// Get shader uniform location
[inline] pub fn get_shader_location(shader Shader, uniformName string) int {
return C.GetShaderLocation(shader, uniformName.str)
}
// Set shader uniform value
[inline] pub fn set_shader_value(shader Shader, uniformLoc int, value voidptr, uniformType int) {
C.SetShaderValue(shader, uniformLoc, value, uniformType)
}
// Set shader uniform value vector
[inline] pub fn set_shader_value_v(shader Shader, uniformLoc int, value voidptr, uniformType, count int) {
C.SetShaderValueV(shader, uniformLoc, value, uniformType, count)
}
// Set shader uniform value (matrix 4x4)
[inline] pub fn set_shader_value_matrix(shader Shader, uniformLoc int, mat Matrix) {
C.SetShaderValueMatrix(shader, uniformLoc, mat)
}
// Set shader uniform value for texture
[inline] pub fn set_shader_value_texture(shader Shader, uniformLoc int, texture Texture2D) {
C.SetShaderValueTexture(shader, uniformLoc, texture)
}
// Set a custom projection matrix (replaces internal projection matrix)
[inline] pub fn set_matrix_projection(proj Matrix) {
C.SetMatrixProjection(proj)
}
// Set a custom modelview matrix (replaces internal modelview matrix)
[inline] pub fn set_matrix_modelview(view Matrix) {
C.SetMatrixModelview(view)
}
// Get internal modelview matrix
[inline] pub fn get_matrix_model_view() Matrix {
return C.GetMatrixModelview()
}
// Shading begin/end functions
//
// Begin custom shader drawing
[inline] pub fn begin_shader_mode(shader Shader) {
C.BeginShaderMode(shader)
}
// End custom shader drawing (use default shader)
[inline] pub fn end_shader_model() {
C.EndShaderMode()
}
// Begin blending mode (alpha, additive, multiplied)
[inline] pub fn begin_blend_mode(mode int) {
C.BeginBlendMode(mode)
}
// End blending mode (reset to default: alpha blending)
[inline] pub fn end_blend_mode() {
C.EndBlendMode()
}
// Begin scissor mode (define screen area for following drawing)
[inline] pub fn begin_scissor_mode(x, y, width, height int) {
C.BeginScissorMode(x, y, width, height)
}
// End scissor mode
[inline] pub fn end_scissor_mode() {
C.EndScissorMode()
}
// VR control functions
//
// Init VR simulator for selected device parameters
[inline] pub fn init_vr_simulator() {
C.InitVrSimulator()
}
// Close VR simulator for current device
[inline] pub fn close_vr_simulator() {
C.CloseVrSimulator()
}
// Update VR tracking (position and orientation) and camera
[inline] pub fn update_vr_tracking(camera &Camera3D) {
C.UpdateVrTracking(camera)
}
// Set stereo rendering configuration parameters
[inline] pub fn set_vr_configuration(info VrDeviceInfo, distortion Shader) {
C.SetVrConfiguration(info, distortion)
}
// Detect if VR simulator is ready
[inline] pub fn is_vr_simulator_ready() bool {
return C.IsVrSimulatorReady()
}
// Enable/Disable VR experience
[inline] pub fn toggle_vr_mode() {
C.ToggleVrMode()
}
// Begin VR simulator stereo rendering
[inline] pub fn begin_vr_drawing() {
C.BeginVrDrawing()
}
// End VR simulator stereo rendering
[inline] pub fn end_vr_drawing() {
C.EndVrDrawing()
}