Antkeeper  0.0.1
shader-input.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
21 #include <engine/gl/texture-1d.hpp>
22 #include <engine/gl/texture-2d.hpp>
23 #include <engine/gl/texture-3d.hpp>
25 #include <glad/glad.h>
26 
27 namespace gl {
28 
29 shader_input::shader_input(shader_program* program, std::size_t input_index, int gl_uniform_location, const std::string& name, shader_variable_type data_type, std::size_t element_count, int texture_unit):
30  program(program),
31  input_index(input_index),
32  gl_uniform_location(gl_uniform_location),
33  name(name),
34  data_type(data_type),
35  element_count(element_count),
36  texture_unit(texture_unit)
37 {}
38 
39 shader_input::~shader_input()
40 {}
41 
42 bool shader_input::upload(const bool& value) const
43 {
44  if (gl_uniform_location == -1)
45  return false;
46 
47  glUniform1i(gl_uniform_location, static_cast<GLint>(value));
48  return true;
49 }
50 
51 bool shader_input::upload(const bool2& value) const
52 {
53  if (gl_uniform_location == -1)
54  return false;
55 
56  const GLint values[] = {value[0], value[1]};
57  glUniform2iv(gl_uniform_location, 1, values);
58  return true;
59 }
60 
61 bool shader_input::upload(const bool3& value) const
62 {
63  if (gl_uniform_location == -1)
64  return false;
65 
66  const GLint values[] = {value[0], value[1], value[2]};
67  glUniform3iv(gl_uniform_location, 1, values);
68  return true;
69 }
70 
71 bool shader_input::upload(const bool4& value) const
72 {
73  if (gl_uniform_location == -1)
74  return false;
75 
76  const GLint values[] = {value[0], value[1], value[2], value[3]};
77  glUniform4iv(gl_uniform_location, 1, values);
78  return true;
79 }
80 
81 bool shader_input::upload(const int& value) const
82 {
83  if (gl_uniform_location == -1)
84  return false;
85 
86  glUniform1i(gl_uniform_location, value);
87  return true;
88 }
89 
90 bool shader_input::upload(const int2& value) const
91 {
92  if (gl_uniform_location == -1)
93  return false;
94 
95  glUniform2iv(gl_uniform_location, 1, value.data());
96  return true;
97 }
98 
99 bool shader_input::upload(const int3& value) const
100 {
101  if (gl_uniform_location == -1)
102  return false;
103 
104  glUniform3iv(gl_uniform_location, 1, value.data());
105  return true;
106 }
107 
108 bool shader_input::upload(const int4& value) const
109 {
110  if (gl_uniform_location == -1)
111  return false;
112 
113  glUniform4iv(gl_uniform_location, 1, value.data());
114  return true;
115 }
116 
117 bool shader_input::upload(const unsigned int& value) const
118 {
119  if (gl_uniform_location == -1)
120  return false;
121 
122  glUniform1ui(gl_uniform_location, value);
123  return true;
124 }
125 
126 bool shader_input::upload(const uint2& value) const
127 {
128  if (gl_uniform_location == -1)
129  return false;
130 
131  glUniform2uiv(gl_uniform_location, 1, value.data());
132  return true;
133 }
134 
135 bool shader_input::upload(const uint3& value) const
136 {
137  if (gl_uniform_location == -1)
138  return false;
139 
140  glUniform3uiv(gl_uniform_location, 1, value.data());
141  return true;
142 }
143 
144 bool shader_input::upload(const uint4& value) const
145 {
146  if (gl_uniform_location == -1)
147  return false;
148 
149  glUniform4uiv(gl_uniform_location, 1, value.data());
150  return true;
151 }
152 
153 bool shader_input::upload(const float& value) const
154 {
155  if (gl_uniform_location == -1)
156  return false;
157 
158  glUniform1f(gl_uniform_location, value);
159  return true;
160 }
161 
162 bool shader_input::upload(const float2& value) const
163 {
164  if (gl_uniform_location == -1)
165  return false;
166 
167  glUniform2fv(gl_uniform_location, 1, value.data());
168  return true;
169 }
170 
171 bool shader_input::upload(const float3& value) const
172 {
173  if (gl_uniform_location == -1)
174  return false;
175 
176  glUniform3fv(gl_uniform_location, 1, value.data());
177  return true;
178 }
179 
180 bool shader_input::upload(const float4& value) const
181 {
182  if (gl_uniform_location == -1)
183  return false;
184 
185  glUniform4fv(gl_uniform_location, 1, value.data());
186  return true;
187 }
188 
189 bool shader_input::upload(const float2x2& value) const
190 {
191  if (gl_uniform_location == -1)
192  return false;
193 
194  glUniformMatrix2fv(gl_uniform_location, 1, GL_FALSE, value[0].data());
195  return true;
196 }
197 
198 bool shader_input::upload(const float3x3& value) const
199 {
200  if (gl_uniform_location == -1)
201  return false;
202 
203  glUniformMatrix3fv(gl_uniform_location, 1, GL_FALSE, value[0].data());
204  return true;
205 }
206 
207 bool shader_input::upload(const float4x4& value) const
208 {
209  if (gl_uniform_location == -1)
210  return false;
211 
212  glUniformMatrix4fv(gl_uniform_location, 1, GL_FALSE, value[0].data());
213  return true;
214 }
215 
216 bool shader_input::upload(const texture_1d* value) const
217 {
218  if (gl_uniform_location == -1)
219  return false;
220 
221  // Bind texture to a texture unit reserved by this shader input
222  glActiveTexture(GL_TEXTURE0 + texture_unit);
223  glBindTexture(GL_TEXTURE_1D, value->gl_texture_id);
224 
225  // Upload texture unit index to shader
226  glUniform1i(gl_uniform_location, texture_unit);
227 
228  return true;
229 }
230 
231 bool shader_input::upload(const texture_2d* value) const
232 {
233  if (gl_uniform_location == -1)
234  return false;
235 
236  // Bind texture to a texture unit reserved by this shader input
237  glActiveTexture(GL_TEXTURE0 + texture_unit);
238  glBindTexture(GL_TEXTURE_2D, value->gl_texture_id);
239 
240  // Upload texture unit index to shader
241  glUniform1i(gl_uniform_location, texture_unit);
242 
243  return true;
244 }
245 
246 bool shader_input::upload(const texture_3d* value) const
247 {
248  if (gl_uniform_location == -1)
249  return false;
250 
251  // Bind texture to a texture unit reserved by this shader input
252  glActiveTexture(GL_TEXTURE0 + texture_unit);
253  glBindTexture(GL_TEXTURE_3D, value->gl_texture_id);
254 
255  // Upload texture unit index to shader
256  glUniform1i(gl_uniform_location, texture_unit);
257 
258  return true;
259 }
260 
261 bool shader_input::upload(const texture_cube* value) const
262 {
263  if (gl_uniform_location == -1)
264  return false;
265 
266  // Bind texture to a texture unit reserved by this shader input
267  glActiveTexture(GL_TEXTURE0 + texture_unit);
268  glBindTexture(GL_TEXTURE_CUBE_MAP, value->gl_texture_id);
269 
270  // Upload texture unit index to shader
271  glUniform1i(gl_uniform_location, texture_unit);
272 
273  return true;
274 }
275 
276 bool shader_input::upload(std::size_t index, const bool& value) const
277 {
278  if (gl_uniform_location == -1)
279  return false;
280 
281  glUniform1i(gl_uniform_location + static_cast<int>(index), static_cast<GLint>(value));
282  return true;
283 }
284 
285 bool shader_input::upload(std::size_t index, const bool2& value) const
286 {
287  if (gl_uniform_location == -1)
288  return false;
289 
290  const GLint values[] = {value[0], value[1]};
291  glUniform2iv(gl_uniform_location + static_cast<int>(index), 1, values);
292  return true;
293 }
294 
295 bool shader_input::upload(std::size_t index, const bool3& value) const
296 {
297  if (gl_uniform_location == -1)
298  return false;
299 
300  const GLint values[] = {value[0], value[1], value[3]};
301  glUniform3iv(gl_uniform_location + static_cast<int>(index), 1, values);
302  return true;
303 }
304 
305 bool shader_input::upload(std::size_t index, const bool4& value) const
306 {
307  if (gl_uniform_location == -1)
308  return false;
309 
310  const GLint values[] = {value[0], value[1], value[3], value[4]};
311  glUniform4iv(gl_uniform_location + static_cast<int>(index), 1, values);
312  return true;
313 }
314 
315 bool shader_input::upload(std::size_t index, const int& value) const
316 {
317  if (gl_uniform_location == -1)
318  return false;
319 
320  glUniform1i(gl_uniform_location + static_cast<int>(index), value);
321  return true;
322 }
323 
324 bool shader_input::upload(std::size_t index, const int2& value) const
325 {
326  if (gl_uniform_location == -1)
327  return false;
328 
329  glUniform2iv(gl_uniform_location + static_cast<int>(index), 1, value.data());
330  return true;
331 }
332 
333 bool shader_input::upload(std::size_t index, const int3& value) const
334 {
335  if (gl_uniform_location == -1)
336  return false;
337 
338  glUniform3iv(gl_uniform_location + static_cast<int>(index), 1, value.data());
339  return true;
340 }
341 
342 bool shader_input::upload(std::size_t index, const int4& value) const
343 {
344  if (gl_uniform_location == -1)
345  return false;
346 
347  glUniform4iv(gl_uniform_location + static_cast<int>(index), 1, value.data());
348  return true;
349 }
350 
351 bool shader_input::upload(std::size_t index, const unsigned int& value) const
352 {
353  if (gl_uniform_location == -1)
354  return false;
355 
356  glUniform1ui(gl_uniform_location + static_cast<int>(index), value);
357  return true;
358 }
359 
360 bool shader_input::upload(std::size_t index, const uint2& value) const
361 {
362  if (gl_uniform_location == -1)
363  return false;
364 
365  glUniform2uiv(gl_uniform_location + static_cast<int>(index), 1, value.data());
366  return true;
367 }
368 
369 bool shader_input::upload(std::size_t index, const uint3& value) const
370 {
371  if (gl_uniform_location == -1)
372  return false;
373 
374  glUniform3uiv(gl_uniform_location + static_cast<int>(index), 1, value.data());
375  return true;
376 }
377 
378 bool shader_input::upload(std::size_t index, const uint4& value) const
379 {
380  if (gl_uniform_location == -1)
381  return false;
382 
383  glUniform4uiv(gl_uniform_location + static_cast<int>(index), 1, value.data());
384  return true;
385 }
386 
387 bool shader_input::upload(std::size_t index, const float& value) const
388 {
389  if (gl_uniform_location == -1)
390  return false;
391 
392  glUniform1f(gl_uniform_location + static_cast<int>(index), value);
393  return true;
394 }
395 
396 bool shader_input::upload(std::size_t index, const float2& value) const
397 {
398  if (gl_uniform_location == -1)
399  return false;
400 
401  glUniform2fv(gl_uniform_location + static_cast<int>(index), 1, value.data());
402  return true;
403 }
404 
405 bool shader_input::upload(std::size_t index, const float3& value) const
406 {
407  if (gl_uniform_location == -1)
408  return false;
409 
410  glUniform3fv(gl_uniform_location + static_cast<int>(index), 1, value.data());
411  return true;
412 }
413 
414 bool shader_input::upload(std::size_t index, const float4& value) const
415 {
416  if (gl_uniform_location == -1)
417  return false;
418 
419  glUniform4fv(gl_uniform_location + static_cast<int>(index), 1, value.data());
420  return true;
421 }
422 
423 bool shader_input::upload(std::size_t index, const float2x2& value) const
424 {
425  if (gl_uniform_location == -1)
426  return false;
427 
428  glUniformMatrix2fv(gl_uniform_location + static_cast<int>(index) * 2, 1, GL_FALSE, value[0].data());
429  return true;
430 }
431 
432 bool shader_input::upload(std::size_t index, const float3x3& value) const
433 {
434  if (gl_uniform_location == -1)
435  return false;
436 
437  glUniformMatrix3fv(gl_uniform_location + static_cast<int>(index) * 3, 1, GL_FALSE, value[0].data());
438  return true;
439 }
440 
441 bool shader_input::upload(std::size_t index, const float4x4& value) const
442 {
443  if (gl_uniform_location == -1)
444  return false;
445 
446  glUniformMatrix4fv(gl_uniform_location + static_cast<int>(index) * 4, 1, GL_FALSE, value[0].data());
447  return true;
448 }
449 
450 bool shader_input::upload(std::size_t index, const texture_1d* value) const
451 {
452  if (gl_uniform_location == -1)
453  return false;
454 
455  // Bind texture to a texture unit reserved by this shader input
456  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index));
457  glBindTexture(GL_TEXTURE_1D, value->gl_texture_id);
458 
459  // Upload texture unit index to shader
460  glUniform1i(gl_uniform_location + static_cast<int>(index), texture_unit + static_cast<int>(index));
461 
462  return true;
463 }
464 
465 bool shader_input::upload(std::size_t index, const texture_2d* value) const
466 {
467  if (gl_uniform_location == -1)
468  return false;
469 
470  // Bind texture to a texture unit reserved by this shader input
471  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index));
472  glBindTexture(GL_TEXTURE_2D, value->gl_texture_id);
473 
474  // Upload texture unit index to shader
475  glUniform1i(gl_uniform_location + static_cast<int>(index), texture_unit + static_cast<int>(index));
476 
477  return true;
478 }
479 
480 bool shader_input::upload(std::size_t index, const texture_3d* value) const
481 {
482  if (gl_uniform_location == -1)
483  return false;
484 
485  // Bind texture to a texture unit reserved by this shader input
486  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index));
487  glBindTexture(GL_TEXTURE_3D, value->gl_texture_id);
488 
489  // Upload texture unit index to shader
490  glUniform1i(gl_uniform_location + static_cast<int>(index), texture_unit + static_cast<int>(index));
491 
492  return true;
493 }
494 
495 bool shader_input::upload(std::size_t index, const texture_cube* value) const
496 {
497  if (gl_uniform_location == -1)
498  return false;
499 
500  // Bind texture to a texture unit reserved by this shader input
501  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index));
502  glBindTexture(GL_TEXTURE_CUBE_MAP, value->gl_texture_id);
503 
504  // Upload texture unit index to shader
505  glUniform1i(gl_uniform_location + static_cast<int>(index), texture_unit + static_cast<int>(index));
506 
507  return true;
508 }
509 
510 bool shader_input::upload(std::size_t index, const bool* values, std::size_t count) const
511 {
512  if (gl_uniform_location == -1)
513  return false;
514 
515  int* int_values = new int[count];
516  for (std::size_t i = 0; i < count; ++i)
517  int_values[i] = values[i];
518  glUniform1iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), &(*int_values));
519  delete[] int_values;
520 
521  return true;
522 }
523 
524 bool shader_input::upload(std::size_t index, const bool2* values, std::size_t count) const
525 {
526  if (gl_uniform_location == -1)
527  return false;
528 
529  int2* int2_values = new int2[count];
530  for (std::size_t i = 0; i < count; ++i)
531  int2_values[i] = {values[i][0], values[i][1]};
532  glUniform2iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), &((*int2_values)[0]));
533  delete[] int2_values;
534 
535  return true;
536 }
537 
538 bool shader_input::upload(std::size_t index, const bool3* values, std::size_t count) const
539 {
540  if (gl_uniform_location == -1)
541  return false;
542 
543  int3* int3_values = new int3[count];
544  for (std::size_t i = 0; i < count; ++i)
545  int3_values[i] = {values[i][0], values[i][1], values[i][2]};
546  glUniform3iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), &((*int3_values)[0]));
547  delete[] int3_values;
548 
549  return true;
550 }
551 
552 bool shader_input::upload(std::size_t index, const bool4* values, std::size_t count) const
553 {
554  if (gl_uniform_location == -1)
555  return false;
556 
557  int4* int4_values = new int4[count];
558  for (std::size_t i = 0; i < count; ++i)
559  int4_values[i] = {values[i][0], values[i][1], values[i][2], values[i][3]};
560  glUniform4iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), &((*int4_values)[0]));
561  delete[] int4_values;
562 
563  return true;
564 }
565 
566 bool shader_input::upload(std::size_t index, const int* values, std::size_t count) const
567 {
568  if (gl_uniform_location == -1)
569  return false;
570 
571  glUniform1iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), &(*values));
572  return true;
573 }
574 
575 bool shader_input::upload(std::size_t index, const int2* values, std::size_t count) const
576 {
577  if (gl_uniform_location == -1)
578  return false;
579 
580  glUniform2iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
581  return true;
582 }
583 
584 bool shader_input::upload(std::size_t index, const int3* values, std::size_t count) const
585 {
586  if (gl_uniform_location == -1)
587  return false;
588 
589  glUniform3iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
590  return true;
591 }
592 
593 bool shader_input::upload(std::size_t index, const int4* values, std::size_t count) const
594 {
595  if (gl_uniform_location == -1)
596  return false;
597 
598  glUniform4iv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
599  return true;
600 }
601 
602 bool shader_input::upload(std::size_t index, const unsigned int* values, std::size_t count) const
603 {
604  if (gl_uniform_location == -1)
605  return false;
606 
607  glUniform1uiv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), &(*values));
608  return true;
609 }
610 
611 bool shader_input::upload(std::size_t index, const uint2* values, std::size_t count) const
612 {
613  if (gl_uniform_location == -1)
614  return false;
615 
616  glUniform2uiv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
617  return true;
618 }
619 
620 bool shader_input::upload(std::size_t index, const uint3* values, std::size_t count) const
621 {
622  if (gl_uniform_location == -1)
623  return false;
624 
625  glUniform3uiv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
626  return true;
627 }
628 
629 bool shader_input::upload(std::size_t index, const uint4* values, std::size_t count) const
630 {
631  if (gl_uniform_location == -1)
632  return false;
633 
634  glUniform4uiv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
635  return true;
636 }
637 
638 bool shader_input::upload(std::size_t index, const float* values, std::size_t count) const
639 {
640  if (gl_uniform_location == -1)
641  return false;
642 
643  glUniform1fv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), &(*values));
644  return true;
645 }
646 
647 bool shader_input::upload(std::size_t index, const float2* values, std::size_t count) const
648 {
649  if (gl_uniform_location == -1)
650  return false;
651 
652  glUniform2fv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
653  return true;
654 }
655 
656 bool shader_input::upload(std::size_t index, const float3* values, std::size_t count) const
657 {
658  if (gl_uniform_location == -1)
659  return false;
660 
661  glUniform3fv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
662  return true;
663 }
664 
665 bool shader_input::upload(std::size_t index, const float4* values, std::size_t count) const
666 {
667  if (gl_uniform_location == -1)
668  return false;
669 
670  glUniform4fv(gl_uniform_location + static_cast<int>(index), static_cast<GLsizei>(count), (*values).data());
671  return true;
672 }
673 
674 bool shader_input::upload(std::size_t index, const float2x2* values, std::size_t count) const
675 {
676  if (gl_uniform_location == -1)
677  return false;
678 
679  glUniformMatrix2fv(gl_uniform_location + static_cast<int>(index) * 2, static_cast<GLsizei>(count), GL_FALSE, (*values)[0].data());
680  return true;
681 }
682 
683 bool shader_input::upload(std::size_t index, const float3x3* values, std::size_t count) const
684 {
685  if (gl_uniform_location == -1)
686  return false;
687 
688  glUniformMatrix3fv(gl_uniform_location + static_cast<int>(index) * 3, static_cast<GLsizei>(count), GL_FALSE, (*values)[0].data());
689  return true;
690 }
691 
692 bool shader_input::upload(std::size_t index, const float4x4* values, std::size_t count) const
693 {
694  if (gl_uniform_location == -1)
695  return false;
696 
697  glUniformMatrix4fv(gl_uniform_location + static_cast<int>(index) * 4, static_cast<GLsizei>(count), GL_FALSE, (*values)[0].data());
698  return true;
699 }
700 
701 bool shader_input::upload(std::size_t index, const texture_1d** values, std::size_t count) const
702 {
703  if (gl_uniform_location == -1)
704  return false;
705 
706  for (std::size_t i = 0; i < count; ++i)
707  {
708  // Bind texture to a texture unit reserved by this shader input
709  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index + i));
710  glBindTexture(GL_TEXTURE_1D, values[i]->gl_texture_id);
711 
712  // Upload texture unit index to shader
713  glUniform1i(gl_uniform_location + static_cast<int>(index + i), texture_unit + static_cast<int>(index + i));
714  }
715 
716  return true;
717 }
718 
719 bool shader_input::upload(std::size_t index, const texture_2d** values, std::size_t count) const
720 {
721  if (gl_uniform_location == -1)
722  return false;
723 
724  for (std::size_t i = 0; i < count; ++i)
725  {
726  // Bind texture to a texture unit reserved by this shader input
727  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index + i));
728  glBindTexture(GL_TEXTURE_2D, values[i]->gl_texture_id);
729 
730  // Upload texture unit index to shader
731  glUniform1i(gl_uniform_location + static_cast<int>(index + i), texture_unit + static_cast<int>(index + i));
732  }
733 
734  return true;
735 }
736 
737 bool shader_input::upload(std::size_t index, const texture_3d** values, std::size_t count) const
738 {
739  if (gl_uniform_location == -1)
740  return false;
741 
742  for (std::size_t i = 0; i < count; ++i)
743  {
744  // Bind texture to a texture unit reserved by this shader input
745  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index + i));
746  glBindTexture(GL_TEXTURE_3D, values[i]->gl_texture_id);
747 
748  // Upload texture unit index to shader
749  glUniform1i(gl_uniform_location + static_cast<int>(index + i), texture_unit + static_cast<int>(index + i));
750  }
751 
752  return true;
753 }
754 
755 bool shader_input::upload(std::size_t index, const texture_cube** values, std::size_t count) const
756 {
757  if (gl_uniform_location == -1)
758  return false;
759 
760  for (std::size_t i = 0; i < count; ++i)
761  {
762  // Bind texture to a texture unit reserved by this shader input
763  glActiveTexture(GL_TEXTURE0 + texture_unit + static_cast<int>(index + i));
764  glBindTexture(GL_TEXTURE_CUBE_MAP, values[i]->gl_texture_id);
765 
766  // Upload texture unit index to shader
767  glUniform1i(gl_uniform_location + static_cast<int>(index + i), texture_unit + static_cast<int>(index + i));
768  }
769 
770  return true;
771 }
772 
773 } // namespace gl
A 1D texture which can be uploaded to shaders via shader inputs.
Definition: texture-1d.hpp:31
A 2D texture which can be uploaded to shaders via shader inputs.
Definition: texture-2d.hpp:31
A 3D texture which can be uploaded to shaders via shader inputs.
Definition: texture-3d.hpp:31
A cube texture which can be uploaded to shaders via shader inputs.
constexpr int count(T x) noexcept
Returns the number of set bits in a value, known as a population count or Hamming weight.
Definition: bit-math.hpp:211
Graphics library interface.
@ index
General purpose index (uint)
n by m column-major matrix.
Definition: math/matrix.hpp:44
n-dimensional vector.
Definition: vector.hpp:43
constexpr element_type * data() noexcept
Returns a pointer to the element array.
Definition: vector.hpp:151