1 module bindbc.raylib.bind.shaders;
2 import bindbc.raylib.types;
3 
4 version (BindRaylib_Static) {
5    extern (C) @nogc nothrow {
6    }
7 } else {
8    extern (C) @nogc nothrow {
9       // Shader loading/unloading functions
10       /**
11        *  Load chars array from text file
12        */
13       alias pLoadFileText = char* function(const(char)* fileName);
14       /**
15        * Load shader from files and bind default locations
16        */
17       alias pLoadShader = Shader function(const(char)* vsFileName, const(char)* fsFileName);
18       /**
19        * Load shader from code strings and bind default locations
20        */
21       alias pLoadShaderCode = Shader function(char* vsCode, char* fsCode);
22       /**
23        * Unload shader from GPU memory (VRAM)
24        */
25       alias pUnloadShader = void function(Shader shader);
26 
27       /**
28        * Get default shader
29        */
30       alias pGetShaderDefault = Shader function();
31       /**
32        * Get default texture
33        */
34       alias pGetTextureDefault = Texture2D function();
35       /**
36        * Get texture to draw shapes
37        */
38       alias pGetShapesTexture = Texture2D function();
39       /**
40        * Get texture rectangle to draw shapes
41        */
42       alias pGetShapesTextureRec = Rectangle function();
43       /**
44        * Define default texture used to draw shapes
45        */
46       alias pSetShapesTexture = void function(Texture2D texture, Rectangle source);
47 
48       // Shader configuration functions
49       /**
50        * Get shader uniform location
51        */
52       alias pGetShaderLocation = int function(Shader shader, const(char)* uniformName);
53       /**
54        * Set shader uniform value
55        */
56       alias pSetShaderValue = void function(Shader shader, int uniformLoc, const void* value, int uniformType);
57       /**
58        * Set shader uniform value vector
59        */
60       alias pSetShaderValueV = void function(Shader shader, int uniformLoc, const void* value, int uniformType, int count);
61       /**
62        * Set shader uniform value (matrix 4x4)
63        */
64       alias pSetShaderValueMatrix = void function(Shader shader, int uniformLoc, Matrix mat);
65       /**
66        * Set shader uniform value for texture
67        */
68       alias pSetShaderValueTexture = void function(Shader shader, int uniformLoc, Texture2D texture);
69       /**
70        * Set a custom projection matrix (replaces internal projection matrix)
71        */
72       alias pSetMatrixProjection = void function(Matrix proj);
73       /**
74        * Set a custom modelview matrix (replaces internal modelview matrix)
75        */
76       alias pSetMatrixModelview = void function(Matrix view);
77       /**
78        * Get internal modelview matrix
79        */
80       alias pGetMatrixModelview = Matrix function();
81       /**
82        * Get internal projection matrix
83        */
84       alias pGetMatrixProjection = Matrix function();
85 
86       // Texture maps generation (PBR)
87       // NOTE: Required shaders should be provided
88 
89       /**
90        * Generate cubemap texture from HDR texture
91        */
92       alias pGenTextureCubemap = Texture2D function(Shader shader, Texture2D map, int size);
93       /**
94        * Generate irradiance texture using cubemap data
95        */
96       alias pGenTextureIrradiance = Texture2D function(Shader shader, Texture2D cubemap, int size);
97       /**
98        * Generate prefilter texture using cubemap data
99        */
100       alias pGenTexturePrefilter = Texture2D function(Shader shader, Texture2D cubemap, int size);
101       /**
102        * Generate BRDF texture using cubemap data
103        */
104       alias pGenTextureBRDF = Texture2D function(Shader shader, int size);
105 
106       // Shading begin/end functions
107       /**
108        * Begin custom shader drawing
109        */
110       alias pBeginShaderMode = void function(Shader shader);
111       /**
112        * End custom shader drawing (use default shader)
113        */
114       alias pEndShaderMode = void function();
115       /**
116        * Begin blending mode (alpha, additive, multiplied)
117        */
118       alias pBeginBlendMode = void function(int mode);
119       /**
120        * End blending mode (reset to default: alpha blending)
121        */
122       alias pEndBlendMode = void function();
123 
124       // VR control functions
125       /**
126        * Init VR simulator for selected device parameters
127        */
128       alias pInitVrSimulator = void function();
129       /**
130        * Close VR simulator for current device
131        */
132       alias pCloseVrSimulator = void function();
133       /**
134        * Update VR tracking (position and orientation) and camera
135        */
136       alias pUpdateVrTracking = void function(Camera* camera);
137       /**
138        * Set stereo rendering configuration parameters
139        */
140       alias pSetVrConfiguration = void function(VrDeviceInfo info, Shader distortion);
141       /**
142        * Detect if VR simulator is ready
143        */
144       alias pIsVrSimulatorReady = bool function();
145       /**
146        * Enable/Disable VR experience
147        */
148       alias pToggleVrMode = void function();
149       /**
150        * Begin VR simulator stereo rendering
151        */
152       alias pBeginVrDrawing = void function();
153       /**
154        * End VR simulator stereo rendering
155        */
156       alias pEndVrDrawing = void function();
157    }
158    __gshared {
159       pLoadFileText LoadFileText;
160       pLoadShader LoadShader;
161       pLoadShaderCode LoadShaderCode;
162       pUnloadShader UnloadShader;
163       pGetShaderDefault GetShaderDefault;
164       pGetTextureDefault GetTextureDefault;
165       pGetShapesTexture GetShapesTexture;
166       pGetShapesTextureRec GetShapesTextureRec;
167       pSetShapesTexture SetShapesTexture;
168       pGetShaderLocation GetShaderLocation;
169       pSetShaderValue SetShaderValue;
170       pSetShaderValueV SetShaderValueV;
171       pSetShaderValueMatrix SetShaderValueMatrix;
172       pSetShaderValueTexture SetShaderValueTexture;
173       pSetMatrixProjection SetMatrixProjection;
174       pSetMatrixModelview SetMatrixModelview;
175       pGetMatrixModelview GetMatrixModelview;
176       pGetMatrixProjection GetMatrixProjection;
177 
178       pGenTextureCubemap GenTextureCubemap;
179       pGenTextureIrradiance GenTextureIrradiance;
180       pGenTexturePrefilter GenTexturePrefilter;
181       pGenTextureBRDF GenTextureBRDF;
182 
183       pBeginShaderMode BeginShaderMode;
184       pEndShaderMode EndShaderMode;
185       pBeginBlendMode BeginBlendMode;
186       pEndBlendMode EndBlendMode;
187       pInitVrSimulator InitVrSimulator;
188       pCloseVrSimulator CloseVrSimulator;
189       pUpdateVrTracking UpdateVrTracking;
190       pSetVrConfiguration SetVrConfiguration;
191       pIsVrSimulatorReady IsVrSimulatorReady;
192       pToggleVrMode ToggleVrMode;
193       pBeginVrDrawing BeginVrDrawing;
194       pEndVrDrawing EndVrDrawing;
195    }
196 }