FS2_Open
Open source remastering of the Freespace 2 engine
gropenglstate.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on the
6  * source.
7  *
8 */
9 
10 
11 #include "graphics/gropengllight.h"
13 #include "graphics/gropenglstate.h"
14 #include "math/vecmat.h"
15 
17 
18 
20 
21 
23 {
24  if (units != NULL) {
25  vm_free(units);
26  }
27 }
28 
30 {
31  Assert( n_units > 0 );
32  units = (opengl_texture_unit*) vm_malloc(n_units * sizeof(opengl_texture_unit));
33  num_texture_units = n_units;
34 
35  for (unsigned int unit = 0; unit < num_texture_units; unit++) {
36  units[unit].active = GL_FALSE;
37  units[unit].enabled = GL_FALSE;
38  units[unit].used = GL_FALSE;
39 
40  default_values(unit);
41 
43  if (unit < (GLuint)GL_supported_texture_units) {
48  }
49 
50  units[unit].texgen_S = GL_FALSE;
51  units[unit].texgen_T = GL_FALSE;
52  units[unit].texgen_R = GL_FALSE;
53  units[unit].texgen_Q = GL_FALSE;
54 
55  if (unit < (GLuint)GL_supported_texture_units) {
60  }
61 
62  units[unit].texgen_mode_S = GL_EYE_LINEAR;
63  units[unit].texgen_mode_T = GL_EYE_LINEAR;
64  units[unit].texgen_mode_R = GL_EYE_LINEAR;
65  units[unit].texgen_mode_Q = GL_EYE_LINEAR;
66 
67  if (unit < (GLuint)GL_supported_texture_units) {
71  }
72 
73  units[unit].env_mode = GL_MODULATE;
74  units[unit].env_combine_rgb = GL_MODULATE;
75  units[unit].env_combine_alpha = GL_MODULATE;
76 
77  if (unit < (GLuint)GL_supported_texture_units) {
80  }
81 
82  units[unit].rgb_scale = 1.0f;
83  units[unit].alpha_scale = 1.0f;
84  }
85 
86  DisableAll();
87 }
88 
89 void opengl_texture_state::default_values(GLint unit, GLenum target)
90 {
92 
93  if (target == GL_INVALID_ENUM) {
94  if (unit < GL_supported_texture_units) {
97  }
98 
101 
102  units[unit].texture_target = GL_TEXTURE_2D;
103  units[unit].texture_id = 0;
104  }
105 }
106 
108 {
109  GLboolean save_state = units[active_texture_unit].texgen_S;
110 
111  if ( !((state == -1) || (state == units[active_texture_unit].texgen_S)) ) {
112  if (state) {
113  Assert( state == GL_TRUE );
115  units[active_texture_unit].texgen_S = GL_TRUE;
116  } else {
118  units[active_texture_unit].texgen_S = GL_FALSE;
119  }
120  }
121 
122  return save_state;
123 }
124 
126 {
127  GLboolean save_state = units[active_texture_unit].texgen_T;
128 
129  if ( !((state == -1) || (state == units[active_texture_unit].texgen_T)) ) {
130  if (state) {
131  Assert( state == GL_TRUE );
133  units[active_texture_unit].texgen_T = GL_TRUE;
134  } else {
136  units[active_texture_unit].texgen_T = GL_FALSE;
137  }
138  }
139 
140  return save_state;
141 }
142 
144 {
145  GLboolean save_state = units[active_texture_unit].texgen_R;
146 
147  if ( !((state == -1) || (state == units[active_texture_unit].texgen_R)) ) {
148  if (state) {
149  Assert( state == GL_TRUE );
151  units[active_texture_unit].texgen_R = GL_TRUE;
152  } else {
154  units[active_texture_unit].texgen_R = GL_FALSE;
155  }
156  }
157 
158  return save_state;
159 }
160 
162 {
163  GLboolean save_state = units[active_texture_unit].texgen_Q;
164 
165  if ( !((state == -1) || (state == units[active_texture_unit].texgen_Q)) ) {
166  if (state) {
167  Assert( state == GL_TRUE );
169  units[active_texture_unit].texgen_Q = GL_TRUE;
170  } else {
172  units[active_texture_unit].texgen_Q = GL_FALSE;
173  }
174  }
175 
176  return save_state;
177 }
178 
180 {
181  if (units[active_texture_unit].texture_target != tex_target) {
182  Disable();
183 
184  if (units[active_texture_unit].texture_id) {
185  glBindTexture(units[active_texture_unit].texture_target, 0);
186  units[active_texture_unit].texture_id = 0;
187  }
188 
189  // reset modes, since those were only valid for the previous texture target
190  default_values(active_texture_unit, tex_target);
191  units[active_texture_unit].texture_target = tex_target;
192  }
193 }
194 
196 {
197  if (id >= num_texture_units) {
198  Int3();
199  id = 0;
200  }
201 
203 
204  active_texture_unit = id;
205 }
206 
208 {
209  units[active_texture_unit].used = GL_TRUE;
210 
211  if ( units[active_texture_unit].active && (units[active_texture_unit].texture_id == tex_id) ) {
212  return;
213  }
214 
215  if ( !shader_mode && (active_texture_unit < (uint)GL_supported_texture_units) ) {
216  if( units[active_texture_unit].texture_target != GL_TEXTURE_2D_ARRAY_EXT)
217  glEnable( units[active_texture_unit].texture_target );
218  units[active_texture_unit].enabled = GL_TRUE;
219  }
220 
221  if (units[active_texture_unit].texture_id != tex_id) {
222  glBindTexture(units[active_texture_unit].texture_target, tex_id);
223  units[active_texture_unit].texture_id = tex_id;
224  }
225 
226  units[active_texture_unit].active = GL_TRUE;
227 }
228 
230 {
231  if ( !units[active_texture_unit].active ) {
232  return;
233  }
234 
235  if ( units[active_texture_unit].enabled ) {
236  if( units[active_texture_unit].texture_target != GL_TEXTURE_2D_ARRAY_EXT)
237  glDisable( units[active_texture_unit].texture_target );
238  units[active_texture_unit].enabled = GL_FALSE;
239  }
240 
241  units[active_texture_unit].active = GL_FALSE;
242  units[active_texture_unit].used = GL_FALSE;
243 }
244 
246 {
247  for (unsigned int i = 0; i < num_texture_units; i++) {
248  units[i].used = GL_FALSE;
249  }
250 }
251 
253 {
254  for (unsigned int i = 0; i < num_texture_units; i++) {
255  if (!units[i].used) {
256  SetActiveUnit(i);
257  Disable();
258  }
259  }
260 }
261 
263 {
264  for (unsigned int i = 0; i < num_texture_units; i++) {
265  if (units[i].active) {
266  SetActiveUnit(i);
267  Disable();
268  }
269  }
270 
271  SetActiveUnit();
272 
274 }
275 
277 {
278  if (tex_id == 0) {
279  Int3();
280  return;
281  }
282 
283  GLuint atu_save = active_texture_unit;
284 
285  for (unsigned int i = 0; i < num_texture_units; i++) {
286  if (units[i].texture_id == tex_id) {
287  SetActiveUnit(i);
288  Disable();
289 
290  glBindTexture(units[i].texture_target, 0);
291  units[i].texture_id = 0;
292 
293  default_values(i, units[i].texture_target);
294 
295  if (i == atu_save) {
296  atu_save = 0;
297  }
298  }
299  }
300 
301  SetActiveUnit(atu_save);
302 }
303 
305 {
306 #if 0
307  GLfloat rval = units[active_texture_unit].aniso_filter;
308 
309  if ( (aniso > 0.0f) /*&& (aniso != rval)*/ ) {
311  units[active_texture_unit].aniso_filter = aniso;
312  CLAMP(units[active_texture_unit].aniso_filter, 1.0f, GL_max_anisotropy);
313 
314  glTexParameterf(units[active_texture_unit].texture_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, units[active_texture_unit].aniso_filter);
315  }
316 
318  if (units[active_texture_unit].aniso_filter > 1.0f) {
320  } else {
322  }
323  }
324  }
325 
326  return rval;
327 #endif
328 
329  return GL_anisotropy;
330 }
331 
333 {
334  if (light_Status != NULL) {
335  vm_free(light_Status);
336  }
337 }
338 
340 {
341  int i;
342 
343  glDisable(GL_FOG);
344  fog_Status = GL_FALSE;
345 
347  blend_Status = GL_FALSE;
348 
350  alphatest_Status = GL_FALSE;
351 
353  depthtest_Status = GL_FALSE;
354 
356  scissortest_Status = GL_FALSE;
357 
359  cullface_Status = GL_FALSE;
360 
362  polygonoffsetfill_Status = GL_FALSE;
363 
364  polygon_offset_Factor = 0.0f;
365  polygon_offset_Unit = 0.0f;
366 
368  normalize_Status = GL_FALSE;
369 
370  for (i = 0; i < (int)(sizeof(clipplane_Status) / sizeof(GLboolean)); i++) {
371  //glDisable(GL_CLIP_PLANE0+i);
372  clipplane_Status[i] = GL_FALSE;
373  }
374 
375  if (GL_version >= 30) {
376  for (i = 0; i < (int)(sizeof(clipdistance_Status) / sizeof(GLboolean)); i++) {
377  //glDisable(GL_CLIP_DISTANCE0+i);
378  clipdistance_Status[i] = GL_FALSE;
379  }
380  }
381 
382  Assert( GL_max_lights > 0 );
383  light_Status = (GLboolean*) vm_malloc(GL_max_lights * sizeof(GLboolean));
384 
385  for (i = 0; i < GL_max_lights; i++) {
386  glDisable(GL_LIGHT0+i);
387  light_Status[i] = GL_FALSE;
388  }
389 
391  depthmask_Status = GL_FALSE;
392 
394  lighting_Status = GL_FALSE;
395 
397  frontface_Value = GL_CCW;
398 
400  cullface_Value = GL_BACK;
401 
403  blendfunc_Value[0] = GL_ONE;
404  blendfunc_Value[1] = GL_ZERO;
405 
407  depthfunc_Value = GL_LESS;
408 
409  Current_alpha_blend_mode = ALPHA_BLEND_NONE;
410  Current_zbuffer_type = ZBUFFER_TYPE_READ;
411 
412  red_Status = 255;
413  blue_Status = 255;
414  green_Status = 255;
415  alpha_Status = 255;
416  color_invalid = true;
417 }
418 
420 {
421  GLboolean save_state = lighting_Status;
422 
423  if ( !((state == -1) || (state == lighting_Status)) ) {
424  if (state) {
425  Assert( state == GL_TRUE );
427  lighting_Status = GL_TRUE;
428  } else {
430  lighting_Status = GL_FALSE;
431  }
432  }
433 
434  return save_state;
435 }
436 
438 {
439  GLboolean save_state = fog_Status;
440 
441  if ( !((state == -1) || (state == fog_Status)) ) {
442  if (state) {
443  Assert( state == GL_TRUE );
444  glEnable(GL_FOG);
445  fog_Status = GL_TRUE;
446  } else {
447  glDisable(GL_FOG);
448  fog_Status = GL_FALSE;
449  }
450  }
451 
452  return save_state;
453 }
454 
456 {
457  GLboolean save_state = blend_Status;
458 
459  if ( !((state == -1) || (state == blend_Status)) ) {
460  if (state) {
461  Assert( state == GL_TRUE );
463  blend_Status = GL_TRUE;
464  } else {
466  blend_Status = GL_FALSE;
467  }
468 
469  Current_alpha_blend_mode = (gr_alpha_blend)(-1);
470  }
471 
472  return save_state;
473 }
474 
476 {
477  GLboolean save_state = alphatest_Status;
478 
479  if ( !((state == -1) || (state == alphatest_Status)) ) {
480  if (state) {
481  Assert( state == GL_TRUE );
483  alphatest_Status = GL_TRUE;
484  } else {
486  alphatest_Status = GL_FALSE;
487  }
488  }
489 
490  return save_state;
491 }
492 
494 {
495  GLboolean save_state = depthtest_Status;
496 
497  if ( !((state == -1) || (state == depthtest_Status)) ) {
498  if (state) {
499  Assert( state == GL_TRUE );
501  depthtest_Status = GL_TRUE;
502  } else {
504  depthtest_Status = GL_FALSE;
505  }
506  }
507 
508  return save_state;
509 }
510 
512 {
513  GLboolean save_state = scissortest_Status;
514 
515  if ( !((state == -1) || (state == scissortest_Status)) ) {
516  if (state) {
517  Assert( state == GL_TRUE );
519  scissortest_Status = GL_TRUE;
520  } else {
522  scissortest_Status = GL_FALSE;
523  }
524  }
525 
526  return save_state;
527 }
528 
530 {
531  GLboolean save_state = stenciltest_Status;
532 
533  if ( !((state == -1) || (state == stenciltest_Status)) ) {
534  if (state) {
535  Assert( state == GL_TRUE );
537  stenciltest_Status = GL_TRUE;
538  } else {
540  stenciltest_Status = GL_FALSE;
541  }
542  }
543 
544  return save_state;
545 }
546 
548 {
549  GLboolean save_state = cullface_Status;
550 
551  if ( !((state == -1) || (state == cullface_Status)) ) {
552  if (state) {
553  Assert( state == GL_TRUE );
555  cullface_Status = GL_TRUE;
556  } else {
558  cullface_Status = GL_FALSE;
559  }
560  }
561 
562  return save_state;
563 }
564 
566 {
567  if ( polygon_mode_Face != face || polygon_mode_Mode != mode ) {
568  glPolygonMode(face, mode);
569 
570  polygon_mode_Face = face;
571  polygon_mode_Mode = mode;
572  }
573 }
574 
576 {
577  if ( polygon_offset_Factor != factor || polygon_offset_Unit != units) {
578  glPolygonOffset(factor, units);
579 
580  polygon_offset_Factor = factor;
581  polygon_offset_Unit = units;
582  }
583 }
584 
586 {
587  GLboolean save_state = polygonoffsetfill_Status;
588 
589  if ( !((state == -1) || (state == polygonoffsetfill_Status)) ) {
590  if (state) {
591  Assert( state == GL_TRUE );
593  polygonoffsetfill_Status = GL_TRUE;
594  } else {
596  polygonoffsetfill_Status = GL_FALSE;
597  }
598  }
599 
600  return save_state;
601 }
602 
604 {
605  GLboolean save_state = normalize_Status;
606 
607  if ( !((state == -1) || (state == normalize_Status)) ) {
608  if (state) {
609  Assert( state == GL_TRUE );
611  normalize_Status = GL_TRUE;
612  } else {
614  normalize_Status = GL_FALSE;
615  }
616  }
617 
618  return save_state;
619 }
620 
622 {
623  Assert( (light_Status != NULL) && (num >= 0) && (num < GL_max_lights) );
624 
625  GLboolean save_state = light_Status[num];
626 
627  if ( !((state == -1) || (state == light_Status[num])) ) {
628  if (state) {
629  Assert( state == GL_TRUE );
630  glEnable(GL_LIGHT0+num);
631  light_Status[num] = GL_TRUE;
632  } else {
633  glDisable(GL_LIGHT0+num);
634  light_Status[num] = GL_FALSE;
635  }
636  }
637 
638  return save_state;
639 }
640 
642 {
643  Assert( (num >= 0) || (num < (int)(sizeof(clipplane_Status) / sizeof(GLboolean))) );
644 
645  GLboolean save_state = clipplane_Status[num];
646 
647  if ( !((state == -1) || (state == clipplane_Status[num])) ) {
648  if (state) {
649  Assert( state == GL_TRUE );
651  clipplane_Status[num] = GL_TRUE;
652  } else {
654  clipplane_Status[num] = GL_FALSE;
655  }
656  }
657 
658  return save_state;
659 }
660 
662 {
663  Assert( (num >= 0) || (num < (int)(sizeof(clipdistance_Status) / sizeof(GLboolean))) || GL_version >= 30 );
664 
665  GLboolean save_state = clipdistance_Status[num];
666 
667  if ( !((state == -1) || (state == clipdistance_Status[num])) ) {
668  if (state) {
669  Assert( state == GL_TRUE );
670  //glEnable(GL_CLIP_DISTANCE0+num);
671  clipdistance_Status[num] = GL_TRUE;
672  } else {
673  //glDisable(GL_CLIP_DISTANCE0+num);
674  clipdistance_Status[num] = GL_FALSE;
675  }
676  }
677 
678  return save_state;
679 }
680 
682 {
683  GLboolean save_state = depthmask_Status;
684 
685  if ( !((state == -1) || (state == depthmask_Status)) ) {
686  if (state) {
687  Assert( state == GL_TRUE );
689  depthmask_Status = GL_TRUE;
690  } else {
692  depthmask_Status = GL_FALSE;
693  }
694 
695  Current_zbuffer_type = (gr_zbuffer_type)(-1);
696  }
697 
698  return save_state;
699 }
700 
702 {
703  GLboolean save_state = colormask_Status;
704 
705  if ( !((state == -1) || (state == colormask_Status)) ) {
706  if (state) {
707  Assert( state == GL_TRUE );
709  colormask_Status = GL_TRUE;
710  } else {
712  colormask_Status = GL_FALSE;
713  }
714  }
715 
716  return save_state;
717 }
718 
720 {
721  if (ts == Texture.Current_texture_source) {
722  return;
723  }
724 
725  switch (ts) {
727  GL_state.Texture.SetActiveUnit();
728  GL_state.Texture.SetEnvMode(GL_MODULATE);
729  break;
730 
732  GL_state.Texture.SetActiveUnit();
733  GL_state.Texture.SetEnvMode(GL_MODULATE);
734  break;
735 
736  case TEXTURE_SOURCE_NONE:
737  GL_state.Texture.DisableAll();
738  break;
739 
740  default:
741  Int3();
742  break;
743  }
744 
746 }
747 
749 {
750  if (ab == Current_alpha_blend_mode) {
751  return;
752  }
753 
754  switch (ab) {
757  break;
758 
759  case ALPHA_BLEND_NONE:
760  GL_state.BlendFunc(GL_ONE, GL_ZERO);
761  break;
762 
764  GL_state.BlendFunc(GL_ONE, GL_ONE);
765  break;
766 
768  GL_state.BlendFunc(GL_SRC_ALPHA, GL_ONE);
769  break;
770 
772  GL_state.BlendFunc(/*GL_SRC_COLOR*/GL_SRC_ALPHA, GL_ONE_MINUS_SRC_COLOR);
773  break;
774 
777  break;
778 
779  default:
780  break;
781  }
782 
783  GL_state.Blend( (ab == ALPHA_BLEND_NONE) ? GL_FALSE : GL_TRUE );
784 
785  Current_alpha_blend_mode = ab;
786 }
787 
789 {
790  if (zt == Current_zbuffer_type) {
791  return;
792  }
793 
794  switch (zt) {
795  case ZBUFFER_TYPE_NONE:
796  GL_state.DepthFunc(GL_ALWAYS);
797  GL_state.DepthMask(GL_FALSE);
798  break;
799 
800  case ZBUFFER_TYPE_READ:
801  GL_state.DepthFunc(GL_LESS);
802  GL_state.DepthMask(GL_FALSE);
803  break;
804 
805  case ZBUFFER_TYPE_WRITE:
806  GL_state.DepthFunc(GL_ALWAYS);
807  GL_state.DepthMask(GL_TRUE);
808  break;
809 
810  case ZBUFFER_TYPE_FULL:
811  GL_state.DepthFunc(GL_LESS);
812  GL_state.DepthMask(GL_TRUE);
813  break;
814 
815  default:
816  break;
817  }
818 
819  GL_state.DepthTest( (zt == ZBUFFER_TYPE_NONE) ? GL_FALSE : GL_TRUE );
820 
821  Current_zbuffer_type = zt;
822 }
823 
825 {
826  if (st == Current_stencil_type) {
827  return;
828  }
829 
830  switch (st) {
831  case STENCIL_TYPE_NONE:
832  glStencilFunc( GL_NEVER, 1, 0xFFFF );
834  break;
835 
836  case STENCIL_TYPE_READ:
837  glStencilFunc( GL_NOTEQUAL, 1, 0XFFFF );
839  break;
840 
841  case STENCIL_TYPE_WRITE:
842  glStencilFunc( GL_ALWAYS, 1, 0xFFFF );
844  break;
845 
846  default:
847  break;
848  }
849 
850  GL_state.StencilTest( (st == STENCIL_TYPE_NONE) ? GL_FALSE : GL_TRUE );
851 
852  Current_stencil_type = st;
853 }
854 
856 {
857  if ( client_texture_units != NULL ) {
858  vm_free(client_texture_units);
859  }
860 }
861 
863 {
864  Assert( n_units > 0 );
865  client_texture_units = (opengl_client_texture_unit*) vm_malloc(n_units * sizeof(opengl_client_texture_unit));
866  num_client_texture_units = n_units;
867  active_client_texture_unit = 0;
868 
869  for (unsigned int i = 0; i < num_client_texture_units; i++) {
870  client_texture_units[i].pointer = 0;
871  client_texture_units[i].size = 4;
872  client_texture_units[i].status = GL_FALSE;
873  client_texture_units[i].stride = 0;
874  client_texture_units[i].type = GL_FLOAT;
875  client_texture_units[i].buffer = 0;
876  client_texture_units[i].reset_ptr = false;
877  client_texture_units[i].used_for_draw = false;
878  }
879 
880  color_array_Buffer = 0;
881  color_array_Status = GL_FALSE;
882  color_array_size = 4;
883  color_array_type = GL_FLOAT;
884  color_array_stride = 0;
885  color_array_pointer = 0;
886  color_array_reset_ptr = false;
887  color_array_used_for_draw = false;
888 
889  normal_array_Buffer = 0;
890  normal_array_Status = GL_FALSE;
891  normal_array_Type = GL_FLOAT;
892  normal_array_Stride = 0;
893  normal_array_Pointer = 0;
894  normal_array_reset_ptr = false;
895  normal_array_used_for_draw = false;
896 
897  vertex_array_Buffer = 0;
898  vertex_array_Status = GL_FALSE;
899  vertex_array_Size = 4;
900  vertex_array_Type = GL_FLOAT;
901  vertex_array_Stride = 0;
902  vertex_array_Pointer = 0;
903  vertex_array_reset_ptr = false;
904  vertex_array_used_for_draw = false;
905 
906  array_buffer = 0;
907  element_array_buffer = 0;
908  texture_array_buffer = 0;
909  uniform_buffer = 0;
910 }
911 
913 {
914  if ( id >= num_client_texture_units ) {
915  Int3();
916  id = 0;
917  }
918 
919  if ( active_client_texture_unit == id ) {
920  return;
921  }
922 
924 
925  active_client_texture_unit = id;
926 }
927 
929 {
930  client_texture_units[active_client_texture_unit].used_for_draw = true;
931 
932  if ( client_texture_units[active_client_texture_unit].status == GL_TRUE ) {
933  return;
934  }
935 
937 
938  client_texture_units[active_client_texture_unit].status = GL_TRUE;
939 }
940 
942 {
943  if ( client_texture_units[active_client_texture_unit].status == GL_FALSE ) {
944  return;
945  }
946 
948 
949  client_texture_units[active_client_texture_unit].status = GL_FALSE;
950 }
951 
953 {
954  opengl_client_texture_unit *ct_unit = &client_texture_units[active_client_texture_unit];
955 
956  if (
957  !ct_unit->reset_ptr
958  && ct_unit->pointer == pointer
959  && ct_unit->size == size
960  && ct_unit->type == type
961  && ct_unit->stride == stride
962  && ct_unit->buffer == array_buffer
963  ) {
964  return;
965  }
966 
967  glTexCoordPointer(size, type, stride, pointer);
968 
969  ct_unit->size = size;
970  ct_unit->type = type;
971  ct_unit->stride = stride;
972  ct_unit->pointer = pointer;
973  ct_unit->buffer = array_buffer;
974  ct_unit->reset_ptr = false;
975 }
976 
978 {
979  color_array_used_for_draw = true;
980 
981  if ( color_array_Status == GL_TRUE ) {
982  return;
983  }
984 
986 
987  color_array_Status = GL_TRUE;
988 }
989 
991 {
992  if ( color_array_Status == GL_FALSE ) {
993  return;
994  }
995 
997 
998  color_array_Status = GL_FALSE;
999 }
1000 
1002 {
1003  if (
1004  !color_array_reset_ptr
1005  && color_array_size == size
1006  && color_array_type == type
1007  && color_array_stride == stride
1008  && color_array_pointer == pointer
1009  && color_array_Buffer == array_buffer
1010  ) {
1011  return;
1012  }
1013 
1014  glColorPointer(size, type, stride, pointer);
1015 
1016  color_array_size = size;
1017  color_array_type = type;
1018  color_array_stride = stride;
1019  color_array_pointer = pointer;
1020  color_array_Buffer = array_buffer;
1021  color_array_reset_ptr = false;
1022 }
1023 
1025 {
1026  normal_array_used_for_draw = true;
1027 
1028  if ( normal_array_Status == GL_TRUE ) {
1029  return;
1030  }
1031 
1033 
1034  normal_array_Status = GL_TRUE;
1035 }
1036 
1038 {
1039  if ( normal_array_Status == GL_FALSE ) {
1040  return;
1041  }
1042 
1044 
1045  normal_array_Status = GL_FALSE;
1046 }
1047 
1049 {
1050  if (
1051  !normal_array_reset_ptr
1052  && normal_array_Type == type
1053  && normal_array_Stride == stride
1054  && normal_array_Pointer == pointer
1055  && normal_array_Buffer == array_buffer
1056  ) {
1057  return;
1058  }
1059 
1060  glNormalPointer(type, stride, pointer);
1061 
1062  normal_array_Type = type;
1063  normal_array_Stride = stride;
1064  normal_array_Pointer = pointer;
1065  normal_array_Buffer = array_buffer;
1066  normal_array_reset_ptr = false;
1067 }
1068 
1070 {
1071  vertex_array_used_for_draw = true;
1072 
1073  if ( vertex_array_Status == GL_TRUE ) {
1074  return;
1075  }
1076 
1078 
1079  vertex_array_Status = GL_TRUE;
1080 }
1081 
1083 {
1084  if ( vertex_array_Status == GL_FALSE ) {
1085  return;
1086  }
1087 
1089 
1090  vertex_array_Status = GL_FALSE;
1091 }
1092 
1094 {
1095  if (
1096  !vertex_array_reset_ptr
1097  && vertex_array_Size == size
1098  && vertex_array_Type == type
1099  && vertex_array_Stride == stride
1100  && vertex_array_Pointer == pointer
1101  && vertex_array_Buffer == array_buffer
1102  ) {
1103  return;
1104  }
1105 
1106  glVertexPointer(size, type, stride, pointer);
1107 
1108  vertex_array_Size = size;
1109  vertex_array_Type = type;
1110  vertex_array_Stride = stride;
1111  vertex_array_Pointer = pointer;
1112  vertex_array_Buffer = array_buffer;
1113  vertex_array_reset_ptr = false;
1114 }
1115 
1117 {
1118  opengl_vertex_attrib_unit *va_unit = &vertex_attrib_units[index];
1119 
1120  va_unit->used_for_draw = true;
1121 
1122  if ( va_unit->status_init && va_unit->status == GL_TRUE ) {
1123  return;
1124  }
1125 
1127  va_unit->status = GL_TRUE;
1128  va_unit->status_init = true;
1129 }
1130 
1132 {
1133  opengl_vertex_attrib_unit *va_unit = &vertex_attrib_units[index];
1134 
1135  if ( va_unit->status_init && va_unit->status == GL_FALSE ) {
1136  return;
1137  }
1138 
1140  va_unit->status = GL_FALSE;
1141  va_unit->status_init = true;
1142 }
1143 
1145 {
1146  opengl_vertex_attrib_unit *va_unit = &vertex_attrib_units[index];
1147 
1148  if (
1149  !va_unit->reset_ptr
1150  && va_unit->ptr_init
1151  && va_unit->normalized == normalized
1152  && va_unit->pointer == pointer
1153  && va_unit->size == size
1154  && va_unit->stride == stride
1155  && va_unit->type == type
1156  && va_unit->buffer == array_buffer
1157  ) {
1158  return;
1159  }
1160 
1161  vglVertexAttribPointerARB(index, size, type, normalized, stride, pointer);
1162 
1163  va_unit->normalized = normalized;
1164  va_unit->pointer = pointer;
1165  va_unit->size = size;
1166  va_unit->stride = stride;
1167  va_unit->type = type;
1168  va_unit->buffer = array_buffer;
1169  va_unit->reset_ptr = false;
1170 
1171  va_unit->ptr_init = true;
1172 }
1173 
1175 {
1176  // set all available client states to not used
1177  vertex_array_used_for_draw = false;
1178  color_array_used_for_draw = false;
1179  normal_array_used_for_draw = false;
1180 
1181  for (unsigned int i = 0; i < num_client_texture_units; i++) {
1182  client_texture_units[i].used_for_draw = false;
1183  }
1184 
1186 
1187  for (it = vertex_attrib_units.begin(); it != vertex_attrib_units.end(); ++it) {
1188  it->second.used_for_draw = false;
1189  }
1190 }
1191 
1193 {
1194  // any client states not used, disable them
1195  if ( !vertex_array_used_for_draw ) DisableClientVertex();
1196  if ( !color_array_used_for_draw ) DisableClientColor();
1197  if ( !normal_array_used_for_draw ) DisableClientNormal();
1198 
1199  for (unsigned int i = 0; i < num_client_texture_units; i++) {
1200  if ( !client_texture_units[i].used_for_draw ) {
1203  }
1204  }
1205 
1207 
1208  for (it = vertex_attrib_units.begin(); it != vertex_attrib_units.end(); ++it) {
1209  if ( !it->second.used_for_draw ) DisableVertexAttrib(it->first);
1210  }
1211 }
1212 
1214 {
1215  if ( array_buffer == id ) {
1216  return;
1217  }
1218 
1220 
1221  array_buffer = id;
1222 
1223  vertex_array_reset_ptr = true;
1224  color_array_reset_ptr = true;
1225  normal_array_reset_ptr = true;
1226 
1227  for (unsigned int i = 0; i < num_client_texture_units; i++) {
1228  client_texture_units[i].reset_ptr = true;
1229  }
1230 
1232 
1233  for ( it = vertex_attrib_units.begin(); it != vertex_attrib_units.end(); ++it ) {
1234  it->second.reset_ptr = true;
1235  }
1236 }
1237 
1239 {
1240  if ( element_array_buffer == id ) {
1241  return;
1242  }
1243 
1245 
1246  element_array_buffer = id;
1247 }
1248 
1250 {
1252  return;
1253  }
1254 
1255  if ( texture_array_buffer == id ) {
1256  return;
1257  }
1258 
1260 
1261  texture_array_buffer = id;
1262 }
1263 
1265 {
1267  return;
1268  }
1269 
1270  if ( uniform_buffer_index_bindings[index] == id ) {
1271  return;
1272  }
1273 
1275 
1276  uniform_buffer_index_bindings[index] = id;
1277 }
1278 
1280 {
1282  return;
1283  }
1284 
1285  if ( uniform_buffer == id ) {
1286  return;
1287  }
1288 
1290 
1291  uniform_buffer = id;
1292 }
1293 
1295 {
1296 }
1297 
1298 int opengl_uniform_state::findUniform(const SCP_string &name)
1299 {
1301 
1302  iter = uniform_lookup.find(name);
1303 
1304  if ( iter == uniform_lookup.end() ) {
1305  return -1;
1306  } else {
1307  return iter->second;
1308  }
1309 }
1310 
1312 {
1313  int uniform_index = findUniform(name);
1314  bool resident = false;
1315 
1316  if ( uniform_index >= 0) {
1317  Assert( (size_t)uniform_index < uniforms.size() );
1318 
1319  uniform_bind *bind_info = &uniforms[uniform_index];
1320 
1321  if ( bind_info->type == uniform_bind::INT ) {
1322  if ( uniform_data_ints[bind_info->index] == val ) {
1323  return;
1324  }
1325 
1326  uniform_data_ints[bind_info->index] = val;
1327  resident = true;
1328  }
1329  }
1330 
1331  if ( !resident ) {
1332  // uniform doesn't exist in our previous uniform block so queue this new value
1333  uniform_data_ints.push_back(val);
1334 
1335  uniform_bind new_bind;
1336 
1337  new_bind.count = 1;
1338  new_bind.index = uniform_data_ints.size() - 1;
1339  new_bind.type = uniform_bind::INT;
1340  new_bind.name = name;
1341 
1342  uniforms.push_back(new_bind);
1343 
1344  uniform_lookup[name] = uniforms.size()-1;
1345  }
1346 
1347  vglUniform1iARB(opengl_shader_get_uniform(name.c_str()), val);
1348 }
1349 
1350 void opengl_uniform_state::setUniformf(const SCP_string &name, const float val)
1351 {
1352  int uniform_index = findUniform(name);
1353  bool resident = false;
1354 
1355  if ( uniform_index >= 0) {
1356  Assert( (size_t)uniform_index < uniforms.size() );
1357 
1358  uniform_bind *bind_info = &uniforms[uniform_index];
1359 
1360  if ( bind_info->type == uniform_bind::FLOAT ) {
1361  if ( fl_equal(uniform_data_floats[bind_info->index], val) ) {
1362  return;
1363  }
1364 
1365  uniform_data_floats[bind_info->index] = val;
1366  resident = true;
1367  }
1368  }
1369 
1370  if ( !resident ) {
1371  // uniform doesn't exist in our previous uniform block so queue this new value
1372  uniform_data_floats.push_back(val);
1373 
1374  uniform_bind new_bind;
1375 
1376  new_bind.count = 1;
1377  new_bind.index = uniform_data_floats.size() - 1;
1378  new_bind.type = uniform_bind::FLOAT;
1379  new_bind.name = name;
1380 
1381  uniforms.push_back(new_bind);
1382 
1383  uniform_lookup[name] = uniforms.size()-1;
1384  }
1385 
1386  vglUniform1fARB(opengl_shader_get_uniform(name.c_str()), val);
1387 }
1388 
1389 void opengl_uniform_state::setUniform2f(const SCP_string &name, const float x, const float y)
1390 {
1391  vec2d temp;
1392 
1393  temp.x = x;
1394  temp.y = y;
1395 
1396  setUniform2f(name, temp);
1397 }
1398 
1400 {
1401  int uniform_index = findUniform(name);
1402  bool resident = false;
1403 
1404  if ( uniform_index >= 0 ) {
1405  Assert( (size_t)uniform_index < uniforms.size() );
1406 
1407  uniform_bind *bind_info = &uniforms[uniform_index];
1408 
1409  if ( bind_info->type == uniform_bind::VEC2 ) {
1410  if ( vm_vec_equal(uniform_data_vec2d[bind_info->index], val) ) {
1411  return;
1412  }
1413 
1414  uniform_data_vec2d[bind_info->index] = val;
1415  resident = true;
1416  }
1417  }
1418 
1419  if ( !resident ) {
1420  // uniform doesn't exist in our previous uniform block so queue this new value
1421  uniform_data_vec2d.push_back(val);
1422 
1423  uniform_bind new_bind;
1424 
1425  new_bind.count = 1;
1426  new_bind.index = uniform_data_vec2d.size() - 1;
1427  new_bind.type = uniform_bind::VEC2;
1428  new_bind.name = name;
1429 
1430  uniforms.push_back(new_bind);
1431 
1432  uniform_lookup[name] = uniforms.size()-1;
1433  }
1434 
1435  vglUniform2fARB(opengl_shader_get_uniform(name.c_str()), val.x, val.y);
1436 }
1437 
1438 void opengl_uniform_state::setUniform3f(const SCP_string &name, const float x, const float y, const float z)
1439 {
1440  vec3d temp;
1441 
1442  temp.xyz.x = x;
1443  temp.xyz.y = y;
1444  temp.xyz.z = z;
1445 
1446  setUniform3f(name, temp);
1447 }
1448 
1450 {
1451  int uniform_index = findUniform(name);
1452  bool resident = false;
1453 
1454  if ( uniform_index >= 0 ) {
1455  Assert( (size_t)uniform_index < uniforms.size() );
1456 
1457  uniform_bind *bind_info = &uniforms[uniform_index];
1458 
1459  if ( bind_info->type == uniform_bind::VEC3 ) {
1460  if ( vm_vec_equal(uniform_data_vec3d[bind_info->index], val) ) {
1461  return;
1462  }
1463 
1464  uniform_data_vec3d[bind_info->index] = val;
1465  resident = true;
1466  }
1467  }
1468 
1469  if ( !resident ) {
1470  // uniform doesn't exist in our previous uniform block so queue this new value
1471  uniform_data_vec3d.push_back(val);
1472 
1473  uniform_bind new_bind;
1474 
1475  new_bind.count = 1;
1476  new_bind.index = uniform_data_vec3d.size() - 1;
1477  new_bind.type = uniform_bind::VEC3;
1478  new_bind.name = name;
1479 
1480  uniforms.push_back(new_bind);
1481 
1482  uniform_lookup[name] = uniforms.size()-1;
1483  }
1484 
1485  vglUniform3fARB(opengl_shader_get_uniform(name.c_str()), val.a1d[0], val.a1d[1], val.a1d[2]);
1486 }
1487 
1489 {
1490  int uniform_index = findUniform(name);
1491  bool resident = false;
1492 
1493  if ( uniform_index >= 0 ) {
1494  Assert( (size_t)uniform_index < uniforms.size() );
1495 
1496  uniform_bind *bind_info = &uniforms[uniform_index];
1497 
1498  if ( bind_info->type == uniform_bind::VEC4 ) {
1499  if ( vm_vec_equal(uniform_data_vec4[bind_info->index], val) ) {
1500  // if the values are close enough, pass.
1501  return;
1502  }
1503 
1504  uniform_data_vec4[bind_info->index] = val;
1505  resident = true;
1506  }
1507  }
1508 
1509  if ( !resident ) {
1510  // uniform doesn't exist in our previous uniform block so queue this new value
1511  uniform_data_vec4.push_back(val);
1512 
1513  uniform_bind new_bind;
1514 
1515  new_bind.count = 1;
1516  new_bind.index = uniform_data_vec4.size() - 1;
1517  new_bind.type = uniform_bind::VEC4;
1518  new_bind.name = name;
1519 
1520  uniforms.push_back(new_bind);
1521 
1522  uniform_lookup[name] = uniforms.size()-1;
1523  }
1524 
1525  vglUniform4fARB(opengl_shader_get_uniform(name.c_str()), val.a1d[0], val.a1d[1], val.a1d[2], val.a1d[3]);
1526 }
1527 
1529 {
1530  int uniform_index = findUniform(name);
1531  bool resident = false;
1532 
1533  if ( uniform_index >= 0) {
1534  Assert( (size_t)uniform_index < uniforms.size() );
1535 
1536  uniform_bind *bind_info = &uniforms[uniform_index];
1537 
1538  if ( bind_info->type == uniform_bind::MATRIX4 && bind_info->count == 1 ) {
1539  if ( vm_matrix_equal(uniform_data_matrix4[bind_info->index], val) ) {
1540  return;
1541  }
1542 
1543  uniform_data_matrix4[bind_info->index] = val;
1544  resident = true;
1545  }
1546  }
1547 
1548  if ( !resident ) {
1549  // uniform doesn't exist in our previous uniform block so queue this new value
1550  //matrix_uniform_data[num_matrix_uniforms] = val;
1551  //memcpy(&(matrix_uniform_data[num_matrix_uniforms]), &val, sizeof(matrix4));
1552  uniform_data_matrix4.push_back(val);
1553  // num_matrix_uniforms += 1;
1554 
1555  uniform_bind new_bind;
1556  new_bind.count = 1;
1557  new_bind.index = uniform_data_matrix4.size() - 1;
1558  // new_bind.index = num_matrix_uniforms - 1;
1559  new_bind.type = uniform_bind::MATRIX4;
1560  new_bind.name = name;
1561 
1562  uniforms.push_back(new_bind);
1563 
1564  uniform_lookup[name] = uniforms.size()-1;
1565  }
1566 
1568 }
1569 
1571 {
1572  int uniform_index = findUniform(name);
1573  bool resident = false;
1574 
1575  if ( uniform_index >= 0) {
1576  Assert( (size_t)uniform_index < uniforms.size() );
1577 
1578  uniform_bind *bind_info = &uniforms[uniform_index];
1579 
1580  if ( bind_info->type == uniform_bind::MATRIX4 && bind_info->count == count ) {
1581  bool equal = true;
1582 
1583  // if the values are close enough, pass.
1584  for ( int i = 0; i < count; ++i ) {
1585  if ( !vm_matrix_equal(val[i], uniform_data_matrix4[bind_info->index+i]) ) {
1586  equal = false;
1587  break;
1588  }
1589  }
1590 
1591  if ( equal ) {
1592  return;
1593  }
1594 
1595  resident = true;
1596  for ( int i = 0; i < count; ++i ) {
1597  uniform_data_matrix4[bind_info->index+i] = val[i];
1598  }
1599  }
1600  }
1601 
1602  if ( !resident ) {
1603  // uniform doesn't exist in our previous uniform block so queue this new value
1604  for ( int i = 0; i < count; ++i ) {
1605  uniform_data_matrix4.push_back(val[i]);
1606  }
1607 
1608  uniform_bind new_bind;
1609  new_bind.count = count;
1610  new_bind.index = uniform_data_matrix4.size() - count;
1611  // new_bind.index = num_matrix_uniforms - count;
1612  new_bind.type = uniform_bind::MATRIX4;
1613  new_bind.name = name;
1614 
1615  uniforms.push_back(new_bind);
1616 
1617  uniform_lookup[name] = uniforms.size()-1;
1618  }
1619 
1620  vglUniformMatrix4fvARB(opengl_shader_get_uniform(name.c_str()), count, GL_FALSE, (const GLfloat*)val);
1621 }
1622 
1624 {
1625  uniforms.clear();
1626 
1627  uniform_data_ints.clear();
1628  uniform_data_floats.clear();
1629  uniform_data_vec2d.clear();
1630  uniform_data_vec3d.clear();
1631  uniform_data_vec4.clear();
1632  uniform_data_matrix4.clear();
1633 
1634  uniform_lookup.clear();
1635 }
1636 
1638 {
1639  GL_state.Texture.DisableAll();
1640 
1641  gr_zbias(0);
1643  gr_set_cull(0);
1646  gr_set_lighting(false, false);
1647 
1649 }
1650 
1651 void opengl_setup_render_states(int &r, int &g, int &b, int &alpha, int &tmap_type, int flags, int is_scaler)
1652 {
1653  gr_texture_source texture_source = (gr_texture_source)(-1);
1654  gr_alpha_blend alpha_blend = (gr_alpha_blend)(-1);
1655  gr_zbuffer_type zbuffer_type = (gr_zbuffer_type)(-1);
1656 
1657  if (gr_zbuffering) {
1658  if ( is_scaler || (gr_screen.current_alphablend_mode == GR_ALPHABLEND_FILTER) ) {
1659  zbuffer_type = ZBUFFER_TYPE_READ;
1660  } else {
1661  zbuffer_type = ZBUFFER_TYPE_FULL;
1662  }
1663  } else {
1664  zbuffer_type = ZBUFFER_TYPE_NONE;
1665  }
1666 
1667  tmap_type = TCACHE_TYPE_NORMAL;
1668 
1669  if (flags & TMAP_FLAG_TEXTURED) {
1670  r = g = b = 255;
1671  } else {
1675  }
1676 
1677  if (flags & TMAP_FLAG_BW_TEXTURE) {
1681  }
1682 
1685  tmap_type = TCACHE_TYPE_XPARENT;
1686 
1687  alpha_blend = ALPHA_BLEND_ALPHA_BLEND_ALPHA;
1688 
1689  // Blend with screen pixel using src*alpha+dst
1690  float factor = gr_screen.current_alpha;
1691 
1692  if (factor >= 1.0f) {
1693  alpha = 255;
1694  } else {
1695  alpha = fl2i(gr_screen.current_alpha*255.0f);
1696  }
1697  } else {
1698  tmap_type = TCACHE_TYPE_NORMAL;
1699  alpha_blend = ALPHA_BLEND_ADDITIVE; // ALPHA_BLEND_ALPHA_ADDITIVE;
1700 
1701  // Blend with screen pixel using src*alpha+dst
1702  float factor = gr_screen.current_alpha;
1703 
1704  alpha = 255;
1705 
1706  if (factor < 1.0f) {
1707  r = fl2i(r * gr_screen.current_alpha);
1708  g = fl2i(g * gr_screen.current_alpha);
1709  b = fl2i(b * gr_screen.current_alpha);
1710  }
1711  }
1712  } else {
1713  alpha_blend = ALPHA_BLEND_ALPHA_BLEND_ALPHA;
1714  alpha = fl2i(gr_screen.current_alpha * 255.0f);
1715  }
1716 
1717 
1718  if (flags & TMAP_FLAG_TEXTURED) {
1719  // use nonfiltered textures for interface graphics
1720  if (flags & TMAP_FLAG_INTERFACE) {
1721  tmap_type = TCACHE_TYPE_INTERFACE;
1722  texture_source = TEXTURE_SOURCE_NO_FILTERING;
1723  } else {
1724  texture_source = TEXTURE_SOURCE_DECAL;
1725  }
1726  } else {
1727  texture_source = TEXTURE_SOURCE_NONE;
1728  }
1729 
1730  GL_state.SetTextureSource(texture_source);
1731  GL_state.SetAlphaBlendMode(alpha_blend);
1732  GL_state.SetZbufferType(zbuffer_type);
1733 }
unsigned int GLuint
Definition: Gl.h:52
GLboolean ColorMask(GLint state=-1)
#define GL_TEXTURE_GEN_T
Definition: Gl.h:470
WINGDIAPI void APIENTRY glEnableClientState(GLenum array)
void EnableVertexAttrib(GLuint index)
int GLsizei
Definition: Gl.h:49
void setUniformMatrix4fv(const SCP_string &name, const int count, const matrix4 *value)
#define gr_zbuffer_set
Definition: 2d.h:817
void SetPolygonMode(GLenum face, GLenum mode)
int i
Definition: multi_pxo.cpp:466
#define vm_free(ptr)
Definition: pstypes.h:548
WINGDIAPI void APIENTRY glCullFace(GLenum mode)
float current_alpha
Definition: 2d.h:400
#define GL_SRC_ALPHA
Definition: Gl.h:121
#define GL_ELEMENT_ARRAY_BUFFER_ARB
Definition: Glext.h:1370
#define GL_COLOR_ARRAY
Definition: Gl.h:1029
uniform_bind::data_type type
WINGDIAPI void APIENTRY glTexGeni(GLenum coord, GLenum pname, GLint param)
#define GL_TEXTURE0
Definition: Glext.h:183
void setUniformf(const SCP_string &name, const float value)
#define vglVertexAttribPointerARB
gr_texture_source
Definition: grinternal.h:59
void init(GLuint n_units)
#define GL_NORMAL_ARRAY
Definition: Gl.h:1028
#define vglUniformMatrix4fvARB
bool vm_vec_equal(const vec4 &self, const vec4 &other)
Definition: vecmat.cpp:34
#define GL_TEXTURE_GEN_R
Definition: Gl.h:471
void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLvoid *pointer)
void setUniformi(const SCP_string &name, const int value)
void BindUniformBufferBindingIndex(GLuint id, GLuint index)
float a1d[4]
Definition: pstypes.h:81
GLint opengl_shader_get_uniform(const char *uniform_text)
#define vglUniform1iARB
GLuint index
Definition: Glext.h:5608
void opengl_setup_render_states(int &r, int &g, int &b, int &alpha, int &tmap_type, int flags, int is_scaler)
#define GL_ONE_MINUS_SRC_ALPHA
Definition: Gl.h:122
#define GL_TEXTURE_2D_ARRAY_EXT
Definition: Glext.h:4389
gr_stencil_type
Definition: grinternal.h:83
void SetTextureSource(gr_texture_source ts)
#define GL_LESS
Definition: Gl.h:73
gr_alpha_blend
Definition: grinternal.h:66
GLboolean StencilTest(GLint state=-1)
WINGDIAPI void APIENTRY glDisable(GLenum cap)
#define GL_POLYGON_OFFSET_FILL
Definition: Gl.h:975
#define GL_ALPHA_SCALE
Definition: Gl.h:517
GLboolean ScissorTest(GLint state=-1)
Assert(pm!=NULL)
WINGDIAPI void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param)
WINGDIAPI void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param)
Definition: pstypes.h:88
#define GL_MODULATE
Definition: Gl.h:907
#define GL_EYE_LINEAR
Definition: Gl.h:920
GLboolean DepthTest(GLint state=-1)
GLboolean TexgenR(GLint state=-1)
WINGDIAPI void APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
struct vec3d::@225::@227 xyz
WINGDIAPI void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
#define OGL_ARB_TEXTURE_BUFFER
GLclampf f
Definition: Glext.h:7097
float y
Definition: pstypes.h:107
#define GL_VERTEX_ARRAY
Definition: Gl.h:1027
void SetZbufferType(gr_zbuffer_type zt)
void BindElementBuffer(GLuint id)
#define GL_Q
Definition: Gl.h:898
#define OGL_ARB_UNIFORM_BUFFER_OBJECT
void setUniform3f(const SCP_string &name, const float x, const float y, const float z)
float factor
Definition: lua.cpp:440
#define GL_ONE_MINUS_SRC_COLOR
Definition: Gl.h:120
#define GL_SCISSOR_TEST
Definition: Gl.h:454
#define GL_BACK
Definition: Gl.h:220
GLenum mode
Definition: Glext.h:5794
opengl_texture_state Texture
#define GR_FILL_MODE_SOLID
Definition: 2d.h:670
ubyte blue
Definition: 2d.h:102
GLboolean CullFace(GLint state=-1)
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
Definition: vmallocator.h:21
#define vglUniform4fARB
GLsizeiptr size
Definition: Glext.h:5496
#define Int3()
Definition: pstypes.h:292
bool fl_equal(float a, float b)
Definition: floating.h:94
bool bm_has_alpha_channel(int handle)
Checks to see if the indexed bitmap has an alpha channel.
Definition: bmpman.cpp:903
WINGDIAPI void APIENTRY glEnable(GLenum cap)
#define TMAP_FLAG_BW_TEXTURE
Definition: tmapper.h:73
#define GL_RGB_SCALE
Definition: Glext.h:273
void gr_opengl_clear_states()
GLboolean TexgenQ(GLint state=-1)
GLenum type
Definition: Gl.h:1492
GLfloat AnisoFilter(GLfloat aniso=0.0f)
GLenum GLsizei GLsizei const GLvoid * pointer
Definition: Gl.h:1492
#define CLAMP(x, min, max)
Definition: pstypes.h:488
void SetEnvMode(GLenum mode)
void SetStencilType(gr_stencil_type st)
ubyte green
Definition: 2d.h:101
int GL_version
Definition: gropengl.cpp:57
#define gr_set_lighting
Definition: 2d.h:924
GLint GLenum GLboolean normalized
Definition: Glext.h:5694
#define vglBindBufferBaseEXT
GLenum GLuint GLint GLenum face
Definition: Glext.h:6586
#define vglUniform2fARB
#define GL_FALSE
Definition: Gl.h:139
#define GL_UNIFORM_BUFFER
Definition: Glext.h:1729
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
float a1d[3]
Definition: pstypes.h:93
#define GR_ALPHABLEND_FILTER
Definition: 2d.h:349
GLboolean DepthMask(GLint state=-1)
#define GL_S
Definition: Gl.h:895
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
Definition: pstypes.h:76
unsigned int uint
Definition: pstypes.h:64
GLboolean GLboolean g
Definition: Glext.h:5781
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: Glext.h:7307
#define GL_NEVER
Definition: Gl.h:72
#define OGL_EXT_TEXTURE_LOD_BIAS
#define vglEnableVertexAttribArrayARB
void SetPolygonOffset(GLfloat factor, GLfloat units)
GLfloat GL_max_anisotropy
GLboolean Light(GLint num, GLint state=-1)
#define GL_COMBINE_RGB
Definition: Glext.h:259
GLboolean AlphaTest(GLint state=-1)
WINGDIAPI void APIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param)
#define TCACHE_TYPE_INTERFACE
Definition: grinternal.h:53
GLint GL_supported_texture_units
WINGDIAPI void APIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
void SetAlphaBlendMode(gr_alpha_blend ab)
#define vglBindBufferARB
#define GL_CLIP_PLANE0
Definition: Gl.h:156
GLdouble GLdouble z
Definition: Glext.h:5451
#define GL_TEXTURE_MAX_ANISOTROPY_EXT
Definition: Glext.h:3107
ubyte red
Definition: 2d.h:100
void VertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
SCP_string name
WINGDIAPI void APIENTRY glDepthFunc(GLenum func)
#define GL_DEPTH_TEST
Definition: Gl.h:415
#define GL_T
Definition: Gl.h:896
WINGDIAPI void APIENTRY glFrontFace(GLenum mode)
gr_zbuffer_type
Definition: grinternal.h:75
#define GL_COMBINE_ALPHA
Definition: Glext.h:260
#define GL_TRUE
Definition: Gl.h:138
GLenum GLuint id
Definition: Glext.h:5156
#define GL_TEXTURE_LOD_BIAS
Definition: Glext.h:295
WINGDIAPI void APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
void TexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
#define TMAP_FLAG_INTERFACE
Definition: tmapper.h:57
#define GL_LIGHT0
Definition: Gl.h:645
WINGDIAPI void APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
#define Is_Extension_Enabled(x)
void BlendFunc(GLenum s_val, GLenum d_val)
void SetTarget(GLenum tex_target)
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
GLboolean Normalize(GLint state=-1)
void Enable(GLuint tex_id=0)
#define GL_ZERO
Definition: Gl.h:117
void NormalPointer(GLenum type, GLsizei stride, GLvoid *pointer)
#define gr_set_cull
Definition: 2d.h:838
GLboolean Blend(GLint state=-1)
#define TCACHE_TYPE_XPARENT
Definition: grinternal.h:52
GLboolean TexgenT(GLint state=-1)
void ColorPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
GLbitfield flags
Definition: Glext.h:6722
#define vglActiveTextureARB
unsigned char GLboolean
Definition: Gl.h:44
#define vm_malloc(size)
Definition: pstypes.h:547
void init(GLuint n_units)
GLint GL_max_lights
#define vglUniform3fARB
GLuint const GLchar * name
Definition: Glext.h:5608
void BindArrayBuffer(GLuint id)
GLfloat GL_anisotropy
GLuint GLfloat * val
Definition: Glext.h:6741
float x
Definition: pstypes.h:107
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
#define GL_TEXTURE_2D
Definition: Gl.h:570
GLboolean PolygonOffsetFill(GLint state=-1)
#define GL_TEXTURE_GEN_Q
Definition: Gl.h:472
void DisableVertexAttrib(GLuint index)
#define GL_TEXTURE_GEN_S
Definition: Gl.h:469
GLboolean ClipPlane(GLint num, GLint state=-1)
GLuint GLuint num
Definition: Glext.h:9089
#define GL_ARRAY_BUFFER_ARB
Definition: Glext.h:1369
#define gr_zbias
Definition: 2d.h:932
#define GL_TEXTURE_ENV_MODE
Definition: Gl.h:913
opengl_state GL_state
#define GL_NOTEQUAL
Definition: Gl.h:77
GLboolean Fog(GLint state=-1)
WINGDIAPI void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
Definition: pstypes.h:106
#define fl2i(fl)
Definition: floating.h:33
#define GL_TEXTURE_CUBE_MAP
Definition: Glext.h:224
#define vglClientActiveTextureARB
int gr_zbuffering
Definition: 2d.cpp:71
#define GL_LIGHTING
Definition: Gl.h:399
GLenum target
Definition: Glext.h:6872
WINGDIAPI void APIENTRY glDepthMask(GLboolean flag)
screen gr_screen
Definition: 2d.cpp:46
#define TCACHE_TYPE_NORMAL
Definition: grinternal.h:51
#define vglUniform1fARB
bool vm_matrix_equal(const matrix &self, const matrix &other)
Definition: vecmat.cpp:49
#define GL_CCW
Definition: Gl.h:339
WINGDIAPI void APIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
#define GL_ALWAYS
Definition: Gl.h:79
#define GL_TEXTURE_GEN_MODE
Definition: Gl.h:925
#define OGL_EXT_TEXTURE_FILTER_ANISOTROPIC
#define TMAP_FLAG_TEXTURED
Definition: tmapper.h:36
#define gr_set_fill_mode
Definition: 2d.h:933
color current_color
Definition: 2d.h:396
WINGDIAPI void APIENTRY glBindTexture(GLenum target, GLuint texture)
#define GL_STENCIL_TEST
Definition: Gl.h:420
#define GL_ONE
Definition: Gl.h:118
WINGDIAPI void APIENTRY glPolygonMode(GLenum face, GLenum mode)
WINGDIAPI void APIENTRY glDisableClientState(GLenum array)
int current_alphablend_mode
Definition: 2d.h:392
#define gr_reset_lighting
Definition: 2d.h:907
WINGDIAPI void APIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
void Delete(GLuint tex_id)
#define GL_FOG
Definition: Gl.h:407
GLint GLsizei count
Definition: Gl.h:1491
void SetActiveClientUnit(GLuint id)
void setUniformMatrix4f(const SCP_string &name, const matrix4 &val)
unsigned int GLenum
Definition: Gl.h:43
GLenum DepthFunc(GLenum new_val=GL_INVALID_ENUM)
void BindTextureBuffer(GLuint id)
int temp
Definition: lua.cpp:4996
#define GL_NORMALIZE
Definition: Gl.h:430
void BindUniformBuffer(GLuint id)
#define vglDisableVertexAttribArrayARB
GLboolean TexgenS(GLint state=-1)
#define GL_KEEP
Definition: Gl.h:882
void opengl_shader_set_current(opengl_shader_t *shader_obj)
void setUniform4f(const SCP_string &name, const vec4 &val)
#define GL_REPLACE
Definition: Gl.h:883
#define GL_TEXTURE0_ARB
Definition: Glext.h:1051
#define GL_TEXTURE_ENV
Definition: Gl.h:917
GLclampf GLclampf GLclampf alpha
Definition: Glext.h:5177
gr_texture_source Current_texture_source
Definition: gropenglstate.h:64
#define GL_TEXTURE_FILTER_CONTROL
Definition: Glext.h:324
#define GL_TEXTURE_COORD_ARRAY
Definition: Gl.h:1031
#define GL_TEXTURE_BUFFER_ARB
Definition: Glext.h:1685
#define GL_FLOAT
Definition: Gl.h:197
GLboolean ClipDistance(GLint num, GLint state=-1)
void GLvoid
Definition: Gl.h:57
#define GL_INVALID_ENUM
Definition: Gl.h:299
#define GL_R
Definition: Gl.h:897
void setUniform2f(const SCP_string &name, const float x, const float y)
void SetActiveUnit(GLuint id=0)
#define GL_ALPHA_TEST
Definition: Gl.h:440
WINGDIAPI void APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
GLint y
Definition: Gl.h:1505
int GLint
Definition: Gl.h:48
int current_bitmap
Definition: 2d.h:395
float GLfloat
Definition: Gl.h:53
GLenum GLsizei stride
Definition: Gl.h:1492
#define GL_BLEND
Definition: Gl.h:446
GLboolean Lighting(GLint state=-1)
#define GL_CULL_FACE
Definition: Gl.h:396