FS2_Open
Open source remastering of the Freespace 2 engine
gropengl.cpp
Go to the documentation of this file.
1 
2 
3 
4 
5 
6 #include "bmpman/bmpman.h"
7 #include "cfile/cfile.h"
8 #include "cmdline/cmdline.h"
9 #include "ddsutils/ddsutils.h"
10 #include "debugconsole/console.h"
11 #include "globalincs/systemvars.h"
12 #include "graphics/2d.h"
13 #include "graphics/gropengl.h"
15 #include "graphics/gropengldraw.h"
17 #include "graphics/gropengllight.h"
20 #include "graphics/gropenglstate.h"
22 #include "graphics/gropengltnl.h"
23 #include "graphics/line.h"
24 #include "io/mouse.h"
25 #include "io/timer.h"
26 #include "math/floating.h"
27 #include "model/model.h"
28 #include "nebula/neb.h"
29 #include "osapi/osapi.h"
30 #include "osapi/osregistry.h"
31 #include "palman/palman.h"
32 #include "render/3d.h"
33 
34 
35 #if defined(_WIN32)
36 #include <windows.h>
37 #include <windowsx.h>
38 #include <direct.h>
39 #elif defined(__APPLE__)
40 #include "OpenGL.h"
41 #else
42 typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
43 #endif
44 
45 
46 #if defined(_WIN32) && !defined(__GNUC__)
47 #pragma comment (lib, "opengl32")
48 #pragma comment (lib, "glu32")
49 #endif
50 
51 // minimum GL version we can reliably support is 1.2
52 static const int MIN_REQUIRED_GL_VERSION = 12;
53 
54 // minimum GLSL version we can reliably support is 110
55 static const int MIN_REQUIRED_GLSL_VERSION = 110;
56 
57 int GL_version = 0;
58 int GLSL_version = 0;
59 
60 bool GL_initted = 0;
61 
62 //0==no fog
63 //1==linear
64 //2==fog coord EXT
65 //3==NV Radial
66 int OGL_fogmode = 0;
67 
68 #ifdef _WIN32
69 static HDC GL_device_context = NULL;
70 static HGLRC GL_render_context = NULL;
71 static PIXELFORMATDESCRIPTOR GL_pfd;
72 #endif
73 
74 static ushort *GL_original_gamma_ramp = NULL;
75 
76 int Use_VBOs = 0;
77 int Use_PBOs = 0;
78 
79 static ubyte *GL_saved_screen = NULL;
80 static ubyte *GL_saved_mouse_data = NULL;
81 static int GL_saved_screen_id = -1;
82 static GLuint GL_cursor_pbo = 0;
83 static GLuint GL_screen_pbo = 0;
84 
85 static int GL_mouse_saved = 0;
86 static int GL_mouse_saved_x1 = 0;
87 static int GL_mouse_saved_y1 = 0;
88 static int GL_mouse_saved_x2 = 0;
89 static int GL_mouse_saved_y2 = 0;
90 
91 void opengl_save_mouse_area(int x, int y, int w, int h);
92 
93 extern const char *Osreg_title;
94 
95 extern GLfloat GL_anisotropy;
96 
97 extern float FreeSpace_gamma;
98 void gr_opengl_set_gamma(float gamma);
99 
100 extern float FreeSpace_gamma;
101 void gr_opengl_set_gamma(float gamma);
102 
103 static int GL_fullscreen = 0;
104 static int GL_windowed = 0;
105 static int GL_minimized = 0;
106 
107 static GLenum GL_read_format = GL_BGRA;
108 
109 
111 {
112  if (Cmdline_fullscreen_window || Cmdline_window || GL_fullscreen || Fred_running)
113  return;
114 
115 #ifdef _WIN32
116  DEVMODE dm;
117  RECT cursor_clip;
118  HWND wnd = (HWND)os_get_window();
119 
120  Assert( wnd );
121 
122  os_suspend();
123 
124  memset((void*)&dm, 0, sizeof(DEVMODE));
125 
126  dm.dmSize = sizeof(DEVMODE);
127  dm.dmPelsHeight = gr_screen.max_h;
128  dm.dmPelsWidth = gr_screen.max_w;
129  dm.dmBitsPerPel = gr_screen.bits_per_pixel;
130  dm.dmDisplayFrequency = os_config_read_uint( NULL, NOX("OGL_RefreshRate"), 0 );
131  dm.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
132 
133  if (dm.dmDisplayFrequency)
134  dm.dmFields |= DM_DISPLAYFREQUENCY;
135 
136  if ( (ChangeDisplaySettings(&dm, CDS_FULLSCREEN)) != DISP_CHANGE_SUCCESSFUL ) {
137  if (dm.dmDisplayFrequency) {
138  // failed to switch with freq change so try without it just in case
139  dm.dmDisplayFrequency = 0;
140  dm.dmFields &= ~DM_DISPLAYFREQUENCY;
141 
142  if ( (ChangeDisplaySettings(&dm, CDS_FULLSCREEN)) != DISP_CHANGE_SUCCESSFUL ) {
143  Warning( LOCATION, "Unable to go fullscreen on second attempt!" );
144  }
145  } else {
146  Warning( LOCATION, "Unable to go fullscreen!" );
147  }
148  }
149 
150  ShowWindow( wnd, SW_SHOWNORMAL );
151  UpdateWindow( wnd );
152 
153  SetForegroundWindow( wnd );
154  SetActiveWindow( wnd );
155  SetFocus( wnd );
156 
157  GetWindowRect((HWND)os_get_window(), &cursor_clip);
158  ClipCursor(&cursor_clip);
159  ShowCursor(FALSE);
160 
161  os_resume();
162 #else
163  if ( (os_config_read_uint(NULL, NOX("Fullscreen"), 1) == 1) && !(SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) ) {
164  os_suspend();
165  // SDL_WM_ToggleFullScreen( SDL_GetVideoSurface() );
166  if ( (SDL_SetVideoMode(gr_screen.max_w, gr_screen.max_h, 0, SDL_OPENGL | SDL_FULLSCREEN)) == NULL ) {
167  mprintf(("Couldn't go fullscreen!\n"));
168  if ( (SDL_SetVideoMode(gr_screen.max_w, gr_screen.max_h, 0, SDL_OPENGL)) == NULL ) {
169  mprintf(("Couldn't drop back to windowed mode either!\n"));
170  exit(1);
171  }
172  }
173  os_resume();
174  }
175 #endif
176 
178 
179  GL_fullscreen = 1;
180  GL_minimized = 0;
181  GL_windowed = 0;
182 }
183 
185 {
186  if ( ( !Cmdline_fullscreen_window && !Cmdline_window ) /*|| GL_windowed*/ || Fred_running )
187  return;
188 
189 #ifdef _WIN32
190  HWND wnd = (HWND)os_get_window();
191  Assert( wnd );
192 
193  // if we are already in a windowed state, then just make sure that we are sane and bail
194  if (GL_windowed) {
195  SetForegroundWindow( wnd );
196  SetActiveWindow( wnd );
197  SetFocus( wnd );
198 
199  ClipCursor(NULL);
200  ShowCursor(FALSE);
201  return;
202  }
203 
204  os_suspend();
205 
206  ShowWindow( wnd, SW_SHOWNORMAL );
207  UpdateWindow( wnd );
208 
209  SetForegroundWindow( wnd );
210  SetActiveWindow( wnd );
211  SetFocus( wnd );
212 
213  ClipCursor(NULL);
214  ShowCursor(FALSE);
215 
216  os_resume();
217 
218 #else
219  if (SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) {
220  os_suspend();
221 
222  // SDL_WM_ToggleFullScreen( SDL_GetVideoSurface() );
223  if ( (SDL_SetVideoMode(gr_screen.max_w, gr_screen.max_h, 0, SDL_OPENGL)) == NULL ) {
224  Warning( LOCATION, "Unable to enter windowed mode!" );
225  }
226 
227  os_resume();
228  }
229 #endif
230 
231  GL_windowed = 1;
232  GL_minimized = 0;
233  GL_fullscreen = 0;
234 }
235 
237 {
238  // don't attempt to minimize if we are already in a window, or already minimized, or when playing a movie
239  if (GL_minimized /*|| GL_windowed || Cmdline_window*/ || Fred_running)
240  return;
241 
242 #ifdef _WIN32
243  HWND wnd = (HWND)os_get_window();
244  Assert( wnd );
245 
246  // if we are a window then just show the cursor and bail
247  if ( Cmdline_fullscreen_window || Cmdline_window || GL_windowed) {
248  ClipCursor(NULL);
249  ShowCursor(TRUE);
250  return;
251  }
252 
253  os_suspend();
254 
255  // restore original gamma settings
256  if (GL_original_gamma_ramp != NULL) {
257  SetDeviceGammaRamp( GL_device_context, GL_original_gamma_ramp );
258  }
259 
260  ShowWindow(wnd, SW_MINIMIZE);
261  ChangeDisplaySettings(NULL, 0);
262 
263  ClipCursor(NULL);
264  ShowCursor(TRUE);
265 
266  os_resume();
267 #else
268  // lets not minimize if we are in windowed mode
269  if ( !(SDL_GetVideoSurface()->flags & SDL_FULLSCREEN) )
270  return;
271 
272  os_suspend();
273 
274  if (GL_original_gamma_ramp != NULL) {
275  SDL_SetGammaRamp( GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
276  }
277 
278  SDL_WM_IconifyWindow();
279  os_resume();
280 #endif
281 
282  GL_minimized = 1;
283  GL_windowed = 0;
284  GL_fullscreen = 0;
285 }
286 
287 void gr_opengl_activate(int active)
288 {
289  if (active) {
292  else
294 
295 #ifdef SCP_UNIX
296  // Check again and if we didn't go fullscreen turn on grabbing if possible
297  if(!Cmdline_no_grab && !(SDL_GetVideoSurface()->flags & SDL_FULLSCREEN)) {
298  SDL_WM_GrabInput(SDL_GRAB_ON);
299  }
300 #endif
301  } else {
302  opengl_minimize();
303 
304 #ifdef SCP_UNIX
305  // let go of mouse/keyboard
306  if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
307  SDL_WM_GrabInput(SDL_GRAB_OFF);
308 #endif
309  }
310 }
311 
313 {
317 
319 }
320 
322 {
323  if ( !GL_initted )
324  return;
325 
326  gr_reset_clip();
327 
329 
330  GL_mouse_saved = 0;
331 
332  if ( mouse_is_visible() ) {
333  int mx, my;
334 
335  gr_reset_clip();
336  mouse_get_pos( &mx, &my );
337 
338  // opengl_save_mouse_area(mx, my, Gr_cursor_size, Gr_cursor_size);
339 
340  if (Gr_cursor != -1 && bm_is_valid(Gr_cursor)) {
342  gr_bitmap( mx, my, GR_RESIZE_NONE);
343  }
344  }
345 
346 #ifdef _WIN32
347  SwapBuffers(GL_device_context);
348 #else
349  if (Cmdline_gl_finish)
350  glFinish ();
351  SDL_GL_SwapBuffers();
352 #endif
353 
355 
356 #ifndef NDEBUG
357  int ic = opengl_check_for_errors();
358 
359  if (ic) {
360  mprintf(("!!DEBUG!! OpenGL Errors this frame: %i\n", ic));
361  }
362 #endif
363 }
364 
365 void gr_opengl_set_clip(int x, int y, int w, int h, int resize_mode)
366 {
367  // check for sanity of parameters
368  if (x < 0) {
369  x = 0;
370  }
371 
372  if (y < 0) {
373  y = 0;
374  }
375 
376  int to_resize = (resize_mode != GR_RESIZE_NONE && (gr_screen.custom_size || (gr_screen.rendering_to_texture != -1)));
377 
378  int max_w = ((to_resize) ? gr_screen.max_w_unscaled : gr_screen.max_w);
379  int max_h = ((to_resize) ? gr_screen.max_h_unscaled : gr_screen.max_h);
380 
381  if ((gr_screen.rendering_to_texture != -1) && to_resize) {
382  gr_unsize_screen_pos(&max_w, &max_h);
383  }
384 
385  if (x >= max_w) {
386  x = max_w - 1;
387  }
388 
389  if (y >= max_h) {
390  y = max_h - 1;
391  }
392 
393  if (x + w > max_w) {
394  w = max_w - x;
395  }
396 
397  if (y + h > max_h) {
398  h = max_h - y;
399  }
400 
401  if (w > max_w) {
402  w = max_w;
403  }
404 
405  if (h > max_h) {
406  h = max_h;
407  }
408 
417 
418  if (to_resize) {
419  gr_resize_screen_pos(&x, &y, &w, &h, resize_mode);
420  } else {
424  }
425 
426  gr_screen.offset_x = x;
427  gr_screen.offset_y = y;
428  gr_screen.clip_left = 0;
429  gr_screen.clip_right = w-1;
430  gr_screen.clip_top = 0;
431  gr_screen.clip_bottom = h-1;
434 
435  gr_screen.clip_aspect = i2fl(w) / i2fl(h);
438 
439  // just return early if we aren't actually going to need the scissor test
440  if ( (x == 0) && (y == 0) && (w == max_w) && (h == max_h) ) {
442  return;
443  }
444 
447  glScissor(x, y, w, h);
448  } else {
449  glScissor(x, gr_screen.max_h-y-h, w, h);
450  }
451 }
452 
454 {
463 
464  if (gr_screen.custom_size) {
467  }
468 
472 
474 }
475 
476 void gr_opengl_set_palette(const ubyte *new_palette, int is_alphacolor)
477 {
478 }
479 
481 {
482  char tmp[MAX_PATH_LEN];
483  ubyte tga_hdr[18];
484  int i;
486  GLubyte *pixels = NULL;
487  GLuint pbo = 0;
488 
489  // save to a "screenshots" directory and tack on the filename
490 #ifdef SCP_UNIX
491  snprintf( tmp, MAX_PATH_LEN-1, "%s/%s/screenshots/%s.tga", detect_home(), Osreg_user_dir, filename);
492  _mkdir( tmp );
493 #else
494  _getcwd( tmp, MAX_PATH_LEN-1 );
495  strcat_s( tmp, "\\screenshots\\" );
496  _mkdir( tmp );
497 
498  strcat_s( tmp, filename );
499  strcat_s( tmp, ".tga" );
500 #endif
501 
502  FILE *fout = fopen(tmp, "wb");
503 
504  if (fout == NULL) {
505  return;
506  }
507 
508 // glReadBuffer(GL_FRONT);
509 
510  // now for the data
511  if (Use_PBOs) {
512  Assert( !pbo );
513  vglGenBuffersARB(1, &pbo);
514 
515  if ( !pbo ) {
516  if (fout != NULL)
517  fclose(fout);
518 
519  return;
520  }
521 
524 
527 
528  // map the image data so that we can save it to file
530  } else {
531  pixels = (GLubyte*) vm_malloc_q(gr_screen.max_w * gr_screen.max_h * 4);
532 
533  if (pixels == NULL) {
534  if (fout != NULL) {
535  fclose(fout);
536  }
537 
538  return;
539  }
540 
541  glReadPixels(0, 0, gr_screen.max_w, gr_screen.max_h, GL_read_format, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
542  glFlush();
543  }
544 
545  // Write the TGA header
546  width = INTEL_SHORT((ushort)gr_screen.max_w);
547  height = INTEL_SHORT((ushort)gr_screen.max_h);
548 
549  memset( tga_hdr, 0, sizeof(tga_hdr) );
550 
551  tga_hdr[2] = 2; // ImageType 2 = 24bpp, uncompressed
552  memcpy( tga_hdr + 12, &width, sizeof(ushort) ); // Width
553  memcpy( tga_hdr + 14, &height, sizeof(ushort) ); // Height
554  tga_hdr[16] = 24; // PixelDepth
555 
556  fwrite( tga_hdr, sizeof(tga_hdr), 1, fout );
557 
558  // now for the data, we convert it from 32-bit to 24-bit
559  for (i = 0; i < (gr_screen.max_w * gr_screen.max_h * 4); i += 4) {
560 #if BYTE_ORDER == BIG_ENDIAN
561  int pix, *pix_tmp;
562 
563  pix_tmp = (int*)(pixels + i);
564  pix = INTEL_INT(*pix_tmp);
565 
566  fwrite( &pix, 1, 3, fout );
567 #else
568  fwrite( pixels + i, 1, 3, fout );
569 #endif
570  }
571 
572  if (pbo) {
574  pixels = NULL;
576  vglDeleteBuffersARB(1, &pbo);
577  }
578 
579  // done!
580  fclose(fout);
581 
582  if (pixels != NULL) {
583  vm_free(pixels);
584  }
585 }
586 
587 void gr_opengl_cleanup(int minimize)
588 {
589  if ( !GL_initted ) {
590  return;
591  }
592 
593  if ( !Fred_running ) {
594  gr_reset_clip();
595  gr_clear();
596  gr_flip();
597  gr_clear();
598  gr_flip();
599  gr_clear();
600  }
601 
602  GL_initted = false;
603 
605 
606 #ifdef _WIN32
607  HWND wnd = (HWND)os_get_window();
608 
609  if (GL_render_context) {
610  if ( !wglMakeCurrent(NULL, NULL) ) {
611  MessageBox(wnd, "SHUTDOWN ERROR", "error", MB_OK);
612  }
613 
614  if ( !wglDeleteContext(GL_render_context) ) {
615  MessageBox(wnd, "Unable to delete rendering context", "error", MB_OK);
616  }
617 
618  GL_render_context = NULL;
619  }
620 #endif
621 
622  opengl_minimize();
623 
624  if (minimize) {
625 #ifdef _WIN32
627  ChangeDisplaySettings(NULL, 0);
628  }
629 #endif
630  }
631 }
632 
633 void gr_opengl_fog_set(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
634 {
635 // mprintf(("gr_opengl_fog_set(%d,%d,%d,%d,%f,%f)\n",fog_mode,r,g,b,fog_near,fog_far));
636 
637  Assert((r >= 0) && (r < 256));
638  Assert((g >= 0) && (g < 256));
639  Assert((b >= 0) && (b < 256));
640 
641  if (fog_mode == GR_FOGMODE_NONE) {
642  if ( GL_state.Fog() ) {
644  }
645 
646  gr_screen.current_fog_mode = fog_mode;
647 
648  return;
649  }
650 
651  if (OGL_fogmode == 3) {
654  }
655  // Um.. this is not the correct way to fog in software, probably doesn't matter though
656  else if ( (OGL_fogmode == 2) && Cmdline_nohtl ) {
658  fog_near *= fog_near; // it's faster this way
659  fog_far *= fog_far;
660  } else {
662  }
663 
666  glFogf(GL_FOG_START, fog_near);
667  glFogf(GL_FOG_END, fog_far);
668 
669  gr_screen.current_fog_mode = fog_mode;
670 
671  if ( (gr_screen.current_fog_color.red != r) ||
674  {
675  GLfloat fc[4];
676 
678 
679  fc[0] = (float)r/255.0f;
680  fc[1] = (float)g/255.0f;
681  fc[2] = (float)b/255.0f;
682  fc[3] = 1.0f;
683 
684  glFogfv(GL_FOG_COLOR, fc);
685  }
686 
687 }
688 
689 int gr_opengl_set_cull(int cull)
690 {
692 
693  if (cull) {
694  enabled = GL_state.CullFace(GL_TRUE);
697  } else {
698  enabled = GL_state.CullFace(GL_FALSE);
699  }
700 
701  return (enabled) ? 1 : 0;
702 }
703 
704 void gr_opengl_set_clear_color(int r, int g, int b)
705 {
707 }
708 
710 {
712 
713  if ( mode ) {
714  enabled = GL_state.ColorMask(GL_TRUE);
715  } else {
716  enabled = GL_state.ColorMask(GL_FALSE);
717  }
718 
720 
721  return (enabled) ? 1 : 0;
722 }
723 
725 {
726  if ( !gr_global_zbuffering ) {
727  return GR_ZBUFF_NONE;
728  }
729 
730  return gr_zbuffering_mode;
731 }
732 
734 {
735  int tmp = gr_zbuffering_mode;
736 
738 
740  gr_zbuffering = 0;
742  } else if ( gr_zbuffering_mode == GR_ZBUFF_READ ) {
743  gr_zbuffering = 1;
745  } else {
746  gr_zbuffering = 1;
748  }
749 
750  return tmp;
751 }
752 
754 {
755  if (mode) {
756  gr_zbuffering = 1;
759 
763 
765  } else {
766  gr_zbuffering = 0;
769 
771  }
772 }
773 
775 {
776  int tmp = gr_stencil_mode;
777 
779 
780  if ( mode == GR_STENCIL_READ ) {
783  } else if ( mode == GR_STENCIL_WRITE ) {
786  } else {
789  }
790 
791  return tmp;
792 }
793 
795 {
797 }
798 
800 {
801  int tmp = gr_alpha_test;
802 
804 
805  if ( mode ) {
807  GL_state.AlphaFunc(GL_GREATER, alpha);
808  } else {
811  }
812 
813  return tmp;
814 }
815 
816 // I feel dirty...
817 static void opengl_make_gamma_ramp(float gamma, ushort *ramp)
818 {
819  ushort x, y;
820  ushort base_ramp[256];
821 
822  Assert( ramp != NULL );
823 
824  // generate the base ramp values first off
825 
826  // if no gamma set then just do this quickly
827  if (gamma <= 0.0f) {
828  memset( ramp, 0, 3 * 256 * sizeof(ushort) );
829  return;
830  }
831  // identity gamma, avoid all of the math
832  else if ( (gamma == 1.0f) || (GL_original_gamma_ramp == NULL) ) {
833  if (GL_original_gamma_ramp != NULL) {
834  memcpy( ramp, GL_original_gamma_ramp, 3 * 256 * sizeof(ushort) );
835  }
836  // set identity if no original ramp
837  else {
838  for (x = 0; x < 256; x++) {
839  ramp[x] = (x << 8) | x;
840  ramp[x + 256] = (x << 8) | x;
841  ramp[x + 512] = (x << 8) | x;
842  }
843  }
844 
845  return;
846  }
847  // for everything else we need to actually figure it up
848  else {
849  double g = 1.0 / (double)gamma;
850  double val;
851 
852  Assert( GL_original_gamma_ramp != NULL );
853 
854  for (x = 0; x < 256; x++) {
855  val = (pow(x/255.0, g) * 65535.0 + 0.5);
856  CLAMP( val, 0, 65535 );
857 
858  base_ramp[x] = (ushort)val;
859  }
860 
861  for (y = 0; y < 3; y++) {
862  for (x = 0; x < 256; x++) {
863  val = (base_ramp[x] * 2) - GL_original_gamma_ramp[x + y * 256];
864  CLAMP( val, 0, 65535 );
865 
866  ramp[x + y * 256] = (ushort)val;
867  }
868  }
869  }
870 }
871 
872 void gr_opengl_set_gamma(float gamma)
873 {
874  ushort *gamma_ramp = NULL;
875 
876  Gr_gamma = gamma;
877  Gr_gamma_int = int (Gr_gamma*10);
878 
879  // new way - but not while running FRED
881  gamma_ramp = (ushort*) vm_malloc_q( 3 * 256 * sizeof(ushort) );
882 
883  if (gamma_ramp == NULL) {
884  Int3();
885  return;
886  }
887 
888  memset( gamma_ramp, 0, 3 * 256 * sizeof(ushort) );
889 
890  // Create the Gamma lookup table
891  opengl_make_gamma_ramp(gamma, gamma_ramp);
892 
893 #ifdef _WIN32
894  SetDeviceGammaRamp( GL_device_context, gamma_ramp );
895 #else
896  SDL_SetGammaRamp( gamma_ramp, (gamma_ramp+256), (gamma_ramp+512) );
897 #endif
898 
899  vm_free(gamma_ramp);
900  }
901 }
902 
903 void gr_opengl_get_region(int front, int w, int h, ubyte *data)
904 {
905 
906 // if (front) {
907 // glReadBuffer(GL_FRONT);
908 // } else {
910 // }
911 
915 
916  if (gr_screen.bits_per_pixel == 16) {
918  } else if (gr_screen.bits_per_pixel == 32) {
920  }
921 
922 
923 }
924 
925 void opengl_save_mouse_area(int x, int y, int w, int h)
926 {
927  int cursor_size;
928 
929  GL_CHECK_FOR_ERRORS("start of save_mouse_area()");
930 
931  // lazy - taylor
932  cursor_size = (Gr_cursor_size * Gr_cursor_size);
933 
934  // no reason to be bigger than the cursor, should never be smaller
935  if (w != Gr_cursor_size)
936  w = Gr_cursor_size;
937  if (h != Gr_cursor_size)
938  h = Gr_cursor_size;
939 
940  GL_mouse_saved_x1 = x;
941  GL_mouse_saved_y1 = y;
942  GL_mouse_saved_x2 = x+w-1;
943  GL_mouse_saved_y2 = y+h-1;
944 
945  CLAMP(GL_mouse_saved_x1, gr_screen.clip_left, gr_screen.clip_right );
946  CLAMP(GL_mouse_saved_x2, gr_screen.clip_left, gr_screen.clip_right );
947  CLAMP(GL_mouse_saved_y1, gr_screen.clip_top, gr_screen.clip_bottom );
948  CLAMP(GL_mouse_saved_y2, gr_screen.clip_top, gr_screen.clip_bottom );
949 
953 
954  if ( Use_PBOs ) {
955  // since this is used a lot, and is pretty small in size, we just create it once and leave it until exit
956  if (!GL_cursor_pbo) {
957  vglGenBuffersARB(1, &GL_cursor_pbo);
960  }
961 
964  glReadPixels(x, gr_screen.max_h-y-1-h, w, h, GL_read_format, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
966  } else {
967  // this should really only have to be malloc'd once
968  if (GL_saved_mouse_data == NULL)
969  GL_saved_mouse_data = (ubyte*)vm_malloc_q(cursor_size * 4);
970 
971  if (GL_saved_mouse_data == NULL)
972  return;
973 
975  glReadPixels(x, gr_screen.max_h-y-1-h, w, h, GL_read_format, GL_UNSIGNED_INT_8_8_8_8_REV, GL_saved_mouse_data);
976  }
977 
978  GL_CHECK_FOR_ERRORS("end of save_mouse_area()");
979 
980  GL_mouse_saved = 1;
981 }
982 
984 {
985  int i;
986  ubyte *sptr = NULL, *dptr = NULL;
987  ubyte *opengl_screen_tmp = NULL;
988  int width_times_pixel, mouse_times_pixel;
989 
991 
992  if (GL_saved_screen || GL_screen_pbo) {
993  // already have a screen saved so just bail...
994  return -1;
995  }
996 
997  GL_saved_screen = (ubyte*)vm_malloc_q( gr_screen.max_w * gr_screen.max_h * 4 );
998 
999  if (!GL_saved_screen) {
1000  mprintf(( "Couldn't get memory for saved screen!\n" ));
1001  return -1;
1002  }
1003 
1004  GLboolean save_state = GL_state.DepthTest(GL_FALSE);
1006 
1007  if ( Use_PBOs ) {
1008  GLubyte *pixels = NULL;
1009 
1010  vglGenBuffersARB(1, &GL_screen_pbo);
1011 
1012  if (!GL_screen_pbo) {
1013  if (GL_saved_screen) {
1014  vm_free(GL_saved_screen);
1015  GL_saved_screen = NULL;
1016  }
1017 
1018  return -1;
1019  }
1020 
1023 
1024  glReadPixels(0, 0, gr_screen.max_w, gr_screen.max_h, GL_read_format, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
1025 
1027 
1028  width_times_pixel = (gr_screen.max_w * 4);
1029  mouse_times_pixel = (Gr_cursor_size * 4);
1030 
1031  sptr = (ubyte *)pixels;
1032  dptr = (ubyte *)&GL_saved_screen[gr_screen.max_w * gr_screen.max_h * 4];
1033 
1034  for (i = 0; i < gr_screen.max_h; i++) {
1035  dptr -= width_times_pixel;
1036  memcpy(dptr, sptr, width_times_pixel);
1037  sptr += width_times_pixel;
1038  }
1039 
1042 
1043  if (GL_mouse_saved && GL_cursor_pbo) {
1045 
1047 
1048  sptr = (ubyte *)pixels;
1049  dptr = (ubyte *)&GL_saved_screen[(GL_mouse_saved_x1 + GL_mouse_saved_y2 * gr_screen.max_w) * 4];
1050 
1051  for (i = 0; i < Gr_cursor_size; i++) {
1052  memcpy(dptr, sptr, mouse_times_pixel);
1053  sptr += mouse_times_pixel;
1054  dptr -= width_times_pixel;
1055  }
1056 
1059  }
1060 
1061  vglDeleteBuffersARB(1, &GL_screen_pbo);
1062  GL_screen_pbo = 0;
1063 
1064  GL_saved_screen_id = bm_create(32, gr_screen.max_w, gr_screen.max_h, GL_saved_screen, 0);
1065  } else {
1066  opengl_screen_tmp = (ubyte*)vm_malloc_q( gr_screen.max_w * gr_screen.max_h * 4 );
1067 
1068  if (!opengl_screen_tmp) {
1069  if (GL_saved_screen) {
1070  vm_free(GL_saved_screen);
1071  GL_saved_screen = NULL;
1072  }
1073 
1074  mprintf(( "Couldn't get memory for temporary saved screen!\n" ));
1075  GL_state.DepthTest(save_state);
1076  return -1;
1077  }
1078 
1079  glReadPixels(0, 0, gr_screen.max_w, gr_screen.max_h, GL_read_format, GL_UNSIGNED_INT_8_8_8_8_REV, opengl_screen_tmp);
1080 
1081  sptr = (ubyte *)&opengl_screen_tmp[gr_screen.max_w * gr_screen.max_h * 4];
1082  dptr = (ubyte *)GL_saved_screen;
1083 
1084  width_times_pixel = (gr_screen.max_w * 4);
1085  mouse_times_pixel = (Gr_cursor_size * 4);
1086 
1087  for (i = 0; i < gr_screen.max_h; i++) {
1088  sptr -= width_times_pixel;
1089  memcpy(dptr, sptr, width_times_pixel);
1090  dptr += width_times_pixel;
1091  }
1092 
1093  vm_free(opengl_screen_tmp);
1094 
1095  if (GL_mouse_saved && GL_saved_mouse_data) {
1096  sptr = (ubyte *)GL_saved_mouse_data;
1097  dptr = (ubyte *)&GL_saved_screen[(GL_mouse_saved_x1 + GL_mouse_saved_y2 * gr_screen.max_w) * 4];
1098 
1099  for (i = 0; i < Gr_cursor_size; i++) {
1100  memcpy(dptr, sptr, mouse_times_pixel);
1101  sptr += mouse_times_pixel;
1102  dptr -= width_times_pixel;
1103  }
1104  }
1105 
1106  GL_saved_screen_id = bm_create(32, gr_screen.max_w, gr_screen.max_h, GL_saved_screen, 0);
1107  }
1108 
1109  GL_state.DepthTest(save_state);
1110 
1111  return GL_saved_screen_id;
1112 }
1113 
1115 {
1116  gr_reset_clip();
1117 
1118  if ( !GL_saved_screen ) {
1119  gr_clear();
1120  return;
1121  }
1122 
1123  Assert( (bmp_id < 0) || (bmp_id == GL_saved_screen_id) );
1124 
1125  if (GL_saved_screen_id < 0)
1126  return;
1127 
1128  gr_set_bitmap(GL_saved_screen_id);
1129  gr_bitmap(0, 0, GR_RESIZE_NONE); // don't scale here since we already have real screen size
1130 }
1131 
1132 void gr_opengl_free_screen(int bmp_id)
1133 {
1134  if (!GL_saved_screen)
1135  return;
1136 
1137  vm_free(GL_saved_screen);
1138  GL_saved_screen = NULL;
1139 
1140  Assert( (bmp_id < 0) || (bmp_id == GL_saved_screen_id) );
1141 
1142  if (GL_saved_screen_id < 0)
1143  return;
1144 
1145  bm_release(GL_saved_screen_id);
1146  GL_saved_screen_id = -1;
1147 }
1148 
1149 //fill mode, solid/wire frame
1151 {
1152  if (mode == GR_FILL_MODE_SOLID) {
1154  return;
1155  }
1156 
1157  if (mode == GR_FILL_MODE_WIRE) {
1159  return;
1160  }
1161 
1162  // default setting
1164 }
1165 
1167 {
1168  if (bias) {
1170  if(bias < 0) {
1171  GL_state.SetPolygonOffset(1.0, -i2fl(bias));
1172  }
1173  else {
1174  GL_state.SetPolygonOffset(0.0, -i2fl(bias));
1175  }
1176  } else {
1178  }
1179 }
1180 
1182 {
1183  GLint current_matrix;
1184 
1185  if (unit > GL_supported_texture_units)
1186  return;
1187 
1188  glGetIntegerv(GL_MATRIX_MODE, &current_matrix);
1190 
1192  glPushMatrix();
1193 
1194  glMatrixMode(current_matrix);
1195 }
1196 
1198 {
1199  GLint current_matrix;
1200 
1201  if (unit > GL_supported_texture_units)
1202  return;
1203 
1204  glGetIntegerv(GL_MATRIX_MODE, &current_matrix);
1206 
1208  glPopMatrix();
1209 
1210  glMatrixMode(current_matrix);
1211 }
1212 
1213 void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
1214 {
1215  GLint current_matrix;
1216 
1217  if (unit > GL_supported_texture_units) {
1218  /*tex_shift=*shift;*/
1219  return;
1220  }
1221 
1222  glGetIntegerv(GL_MATRIX_MODE, &current_matrix);
1224 
1226  glTranslated(shift->xyz.x, shift->xyz.y, shift->xyz.z);
1227 
1228  glMatrixMode(current_matrix);
1229 
1230 // tex_shift=vmd_zero_vector;
1231 }
1232 
1234 {
1235  glLineWidth(width);
1236 }
1237 
1238 // Returns the human readable error string if there is an error or NULL if not
1239 const char *opengl_error_string()
1240 {
1241  GLenum error = GL_NO_ERROR;
1242 
1243  error = glGetError();
1244 
1245  if ( error != GL_NO_ERROR ) {
1246  return (const char *)gluErrorString(error);
1247  }
1248 
1249  return NULL;
1250 }
1251 
1252 int opengl_check_for_errors(char *err_at)
1253 {
1254 #ifdef NDEBUG
1255  return 0;
1256 #endif
1257  const char *error_str = NULL;
1258  int num_errors = 0;
1259 
1260  error_str = opengl_error_string();
1261 
1262  if (error_str) {
1263  if (err_at != NULL) {
1264  nprintf(("OpenGL", "OpenGL Error from %s: %s\n", err_at, error_str));
1265  } else {
1266  nprintf(("OpenGL", "OpenGL Error: %s\n", error_str));
1267  }
1268 
1269  num_errors++;
1270  }
1271 
1272  return num_errors;
1273 }
1274 
1275 void opengl_set_vsync(int status)
1276 {
1277  if ( (status < 0) || (status > 1) ) {
1278  Int3();
1279  return;
1280  }
1281 
1282 #if defined(__APPLE__)
1283  // GLInt on 10.6 is an actual int now, instead of a long
1284  // This will need further testing once Snow Leopard 10.6 goes RTM
1285  CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, (GLint*)&status);
1286 #elif defined(_WIN32)
1287  vwglSwapIntervalEXT(status);
1288 #else
1289  // NOTE: this may not work well with the closed NVIDIA drivers since those use the
1290  // special "__GL_SYNC_TO_VBLANK" environment variable to manage sync
1291  vglXSwapIntervalSGI(status);
1292 #endif
1293 
1294  GL_CHECK_FOR_ERRORS("end of set_vsync()");
1295 }
1296 
1298 {
1300 
1302  glLoadIdentity();
1303 
1304  // the top and bottom positions are reversed on purpose, but RTT needs them the other way
1306  glOrtho(0, gr_screen.max_w, 0, gr_screen.max_h, -1.0, 1.0);
1307  } else {
1308  glOrtho(0, gr_screen.max_w, gr_screen.max_h, 0, -1.0, 1.0);
1309  }
1310 
1312  glLoadIdentity();
1313 }
1314 
1315 // NOTE: This should only ever be called through os_cleanup(), or when switching video APIs
1317 {
1318  if (GL_cursor_pbo) {
1319  vglDeleteBuffersARB(1, &GL_cursor_pbo);
1320  GL_cursor_pbo = 0;
1321  }
1322 
1323  if (GL_saved_mouse_data != NULL) {
1324  vm_free(GL_saved_mouse_data);
1325  GL_saved_mouse_data = NULL;
1326  }
1327 
1334 
1335  GL_initted = false;
1336 
1337 #ifdef _WIN32
1338  // restore original gamma settings
1339  if (GL_original_gamma_ramp != NULL) {
1340  SetDeviceGammaRamp( GL_device_context, GL_original_gamma_ramp );
1341  }
1342 
1343  // swap out our window mode and un-jail the cursor
1344  ShowWindow((HWND)os_get_window(), SW_HIDE);
1345  ClipCursor(NULL);
1346  ChangeDisplaySettings( NULL, 0 );
1347 #else
1348  if (GL_original_gamma_ramp != NULL) {
1349  SDL_SetGammaRamp( GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
1350  }
1351 #endif
1352 
1353  if (GL_original_gamma_ramp != NULL) {
1354  vm_free(GL_original_gamma_ramp);
1355  GL_original_gamma_ramp = NULL;
1356  }
1357 
1358 #ifdef _WIN32
1359  wglMakeCurrent(NULL, NULL);
1360 
1361  if (GL_render_context) {
1362  wglDeleteContext(GL_render_context);
1363  GL_render_context = NULL;
1364  }
1365 
1366  GL_device_context = NULL;
1367 #endif
1368 }
1369 
1370 // NOTE: This should only ever be called through atexit()!!!
1372 {
1373 // if ( !GL_initted )
1374 // return;
1375 }
1376 
1378 {
1379  int bpp = gr_screen.bits_per_pixel;
1380 
1381  if ( (bpp != 16) && (bpp != 32) ) {
1382  Int3();
1383  return 1;
1384  }
1385 
1386 
1387  // screen format
1388  switch (bpp) {
1389  case 16: {
1390  Gr_red.bits = 5;
1391  Gr_red.shift = 11;
1392  Gr_red.scale = 8;
1393  Gr_red.mask = 0xF800;
1394 
1395  Gr_green.bits = 6;
1396  Gr_green.shift = 5;
1397  Gr_green.scale = 4;
1398  Gr_green.mask = 0x7E0;
1399 
1400  Gr_blue.bits = 5;
1401  Gr_blue.shift = 0;
1402  Gr_blue.scale = 8;
1403  Gr_blue.mask = 0x1F;
1404 
1405  break;
1406  }
1407 
1408  case 32: {
1409  Gr_red.bits = 8;
1410  Gr_red.shift = 16;
1411  Gr_red.scale = 1;
1412  Gr_red.mask = 0xff0000;
1413 
1414  Gr_green.bits = 8;
1415  Gr_green.shift = 8;
1416  Gr_green.scale = 1;
1417  Gr_green.mask = 0x00ff00;
1418 
1419  Gr_blue.bits = 8;
1420  Gr_blue.shift = 0;
1421  Gr_blue.scale = 1;
1422  Gr_blue.mask = 0x0000ff;
1423 
1424  Gr_alpha.bits = 8;
1425  Gr_alpha.shift = 24;
1426  Gr_alpha.mask = 0xff000000;
1427  Gr_alpha.scale = 1;
1428 
1429  break;
1430  }
1431  }
1432 
1433  // texture format
1434  Gr_t_red.bits = 5;
1435  Gr_t_red.mask = 0x7c00;
1436  Gr_t_red.shift = 10;
1437  Gr_t_red.scale = 8;
1438 
1439  Gr_t_green.bits = 5;
1440  Gr_t_green.mask = 0x03e0;
1441  Gr_t_green.shift = 5;
1442  Gr_t_green.scale = 8;
1443 
1444  Gr_t_blue.bits = 5;
1445  Gr_t_blue.mask = 0x001f;
1446  Gr_t_blue.shift = 0;
1447  Gr_t_blue.scale = 8;
1448 
1449  Gr_t_alpha.bits = 1;
1450  Gr_t_alpha.mask = 0x8000;
1451  Gr_t_alpha.scale = 255;
1452  Gr_t_alpha.shift = 15;
1453 
1454  // alpha-texture format
1455  Gr_ta_red.bits = 4;
1456  Gr_ta_red.mask = 0x0f00;
1457  Gr_ta_red.shift = 8;
1458  Gr_ta_red.scale = 17;
1459 
1460  Gr_ta_green.bits = 4;
1461  Gr_ta_green.mask = 0x00f0;
1462  Gr_ta_green.shift = 4;
1463  Gr_ta_green.scale = 17;
1464 
1465  Gr_ta_blue.bits = 4;
1466  Gr_ta_blue.mask = 0x000f;
1467  Gr_ta_blue.shift = 0;
1468  Gr_ta_blue.scale = 17;
1469 
1470  Gr_ta_alpha.bits = 4;
1471  Gr_ta_alpha.mask = 0xf000;
1472  Gr_ta_alpha.shift = 12;
1473  Gr_ta_alpha.scale = 17;
1474 
1475  // allocate storage for original gamma settings
1476  if ( !Cmdline_no_set_gamma && (GL_original_gamma_ramp == NULL) ) {
1477  GL_original_gamma_ramp = (ushort*) vm_malloc_q( 3 * 256 * sizeof(ushort) );
1478 
1479  if (GL_original_gamma_ramp == NULL) {
1480  mprintf((" Unable to allocate memory for gamma ramp! Disabling...\n"));
1482  } else {
1483  // assume identity ramp by default, to be overwritten by true ramp later
1484  for (ushort x = 0; x < 256; x++) {
1485  GL_original_gamma_ramp[x] = GL_original_gamma_ramp[x + 256] = GL_original_gamma_ramp[x + 512] = (x << 8) | x;
1486  }
1487  }
1488  }
1489 
1490 
1491  // now init the display device
1492 #ifdef _WIN32
1493  int PixelFormat;
1494  HWND wnd = 0;
1495  PIXELFORMATDESCRIPTOR pfd_test;
1496 
1497  mprintf((" Initializing WGL...\n"));
1498 
1499  memset(&GL_pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
1500  memset(&pfd_test, 0, sizeof(PIXELFORMATDESCRIPTOR));
1501 
1502  GL_pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
1503  GL_pfd.nVersion = 1;
1504  GL_pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
1505  GL_pfd.iPixelType = PFD_TYPE_RGBA;
1506  GL_pfd.cColorBits = (ubyte)bpp;
1507  GL_pfd.cRedBits = (ubyte)Gr_red.bits;
1508  GL_pfd.cGreenBits = (ubyte)Gr_green.bits;
1509  GL_pfd.cBlueBits = (ubyte)Gr_blue.bits;
1510  GL_pfd.cAlphaBits = (bpp == 32) ? (ubyte)Gr_alpha.bits : 0;
1511  GL_pfd.cDepthBits = (bpp == 32) ? 24 : 16;
1512  GL_pfd.cStencilBits = (bpp == 32) ? 8 : 1;
1513 
1514  wnd = (HWND)os_get_window();
1515 
1516  Assert( wnd != NULL );
1517 
1518  extern uint os_get_dc();
1519  GL_device_context = (HDC)os_get_dc();
1520 
1521  if ( !GL_device_context ) {
1522  MessageBox(wnd, "Unable to get device context for OpenGL W32!", "error", MB_ICONERROR | MB_OK);
1523  return 1;
1524  }
1525 
1526  PixelFormat = ChoosePixelFormat(GL_device_context, &GL_pfd);
1527 
1528  if ( !PixelFormat ) {
1529  MessageBox(wnd, "Unable to choose pixel format for OpenGL W32!","error", MB_ICONERROR | MB_OK);
1530  return 1;
1531  } else {
1532  DescribePixelFormat(GL_device_context, PixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd_test);
1533 
1534  // make sure that we are hardware accelerated and not using the generic implementation
1535  if ( !Fred_running && (pfd_test.dwFlags & PFD_GENERIC_FORMAT) && !(pfd_test.dwFlags & PFD_GENERIC_ACCELERATED) ) {
1536  Assert( bpp == 32 );
1537 
1538  // if we failed at 32-bit then we are probably a 16-bit desktop, so try and init a 16-bit visual instead
1539  GL_pfd.cAlphaBits = 0;
1540  GL_pfd.cDepthBits = 16;
1541  GL_pfd.cStencilBits = 1;
1542  // NOTE: the bit values for colors should get updated automatically by ChoosePixelFormat()
1543 
1544  PixelFormat = ChoosePixelFormat(GL_device_context, &GL_pfd);
1545 
1546  if (!PixelFormat) {
1547  MessageBox(wnd, "Unable to choose pixel format for OpenGL W32!","error", MB_ICONERROR | MB_OK);
1548  return 1;
1549  }
1550 
1551  // double-check that we are correct now
1552  DescribePixelFormat(GL_device_context, PixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd_test);
1553 
1554  if ( (pfd_test.dwFlags & PFD_GENERIC_FORMAT) && !(pfd_test.dwFlags & PFD_GENERIC_ACCELERATED) ) {
1555  MessageBox(wnd, "Unable to get proper pixel format for OpenGL W32!", "Error", MB_ICONERROR | MB_OK);
1556  return 1;
1557  }
1558  }
1559  }
1560 
1561  if ( !SetPixelFormat(GL_device_context, PixelFormat, &GL_pfd) ) {
1562  MessageBox(wnd, "Unable to set pixel format for OpenGL W32!", "error", MB_ICONERROR | MB_OK);
1563  return 1;
1564  }
1565 
1566  GL_render_context = wglCreateContext(GL_device_context);
1567  if ( !GL_render_context ) {
1568  MessageBox(wnd, "Unable to create rendering context for OpenGL W32!", "error", MB_ICONERROR | MB_OK);
1569  return 1;
1570  }
1571 
1572  if ( !wglMakeCurrent(GL_device_context, GL_render_context) ) {
1573  MessageBox(wnd, "Unable to make current thread for OpenGL W32!", "error", MB_ICONERROR | MB_OK);
1574  return 1;
1575  }
1576 
1577  mprintf((" Requested WGL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d\n", Gr_red.bits, Gr_green.bits, Gr_blue.bits, GL_pfd.cDepthBits, GL_pfd.cStencilBits, (GL_pfd.dwFlags & PFD_DOUBLEBUFFER) > 0));
1578 
1579  // now report back as to what we ended up getting
1580 
1581  DescribePixelFormat(GL_device_context, PixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &GL_pfd);
1582 
1583  int r = GL_pfd.cRedBits;
1584  int g = GL_pfd.cGreenBits;
1585  int b = GL_pfd.cBlueBits;
1586  int depth = GL_pfd.cDepthBits;
1587  int stencil = GL_pfd.cStencilBits;
1588  int db = ((GL_pfd.dwFlags & PFD_DOUBLEBUFFER) > 0);
1589 
1590  mprintf((" Actual WGL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d\n", r, g, b, depth, stencil, db));
1591 
1592  // get the default gamma ramp so that we can restore it on close
1593  if (GL_original_gamma_ramp != NULL) {
1594  GetDeviceGammaRamp( GL_device_context, GL_original_gamma_ramp );
1595  }
1596 
1597 #else
1598 
1599  int flags = SDL_OPENGL;
1600  int r = 0, g = 0, b = 0, depth = 0, stencil = 1, db = 1;
1601 
1602  mprintf((" Initializing SDL...\n"));
1603 
1604  if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
1605  fprintf (stderr, "Couldn't init SDL: %s", SDL_GetError());
1606  return 1;
1607  }
1608 
1609  // grab mouse/key unless told otherwise, ignore when we are going fullscreen
1610  if ( (Cmdline_fullscreen_window|| Cmdline_window || os_config_read_uint(NULL, "Fullscreen", 1) == 0) && !Cmdline_no_grab ) {
1611  SDL_WM_GrabInput(SDL_GRAB_ON);
1612  }
1613 
1614  SDL_GL_SetAttribute(SDL_GL_RED_SIZE, Gr_red.bits);
1615  SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, Gr_green.bits);
1616  SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, Gr_blue.bits);
1617  SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, (bpp == 32) ? 24 : 16);
1618  SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, (bpp == 32) ? 8 : 1);
1619  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, db);
1620 
1621  int fsaa_samples = os_config_read_uint(NULL, "OGL_AntiAliasSamples", 0);
1622 
1623  SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, (fsaa_samples == 0) ? 0 : 1);
1624  SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa_samples);
1625 
1626  // Slight hack to make Mesa advertise S3TC support without libtxc_dxtn
1627  setenv("force_s3tc_enable", "true", 1);
1628 
1629  mprintf((" Requested SDL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d, FSAA: %d\n", Gr_red.bits, Gr_green.bits, Gr_blue.bits, (bpp == 32) ? 24 : 16, (bpp == 32) ? 8 : 1, db, fsaa_samples));
1630 
1631  if (SDL_SetVideoMode(gr_screen.max_w, gr_screen.max_h, bpp, flags) == NULL) {
1632  fprintf (stderr, "Couldn't set video mode: %s", SDL_GetError());
1633  return 1;
1634  }
1635 
1636  SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &r);
1637  SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &g);
1638  SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &b);
1639  SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &depth);
1640  SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &db);
1641  SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil);
1642  SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &fsaa_samples);
1643 
1644  mprintf((" Actual SDL Video values = R: %d, G: %d, B: %d, depth: %d, stencil: %d, double-buffer: %d, FSAA: %d\n", r, g, b, depth, stencil, db, fsaa_samples));
1645 
1646  SDL_ShowCursor(0);
1647 
1648  /* might as well put this here */
1649  SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
1650 
1651  if (GL_original_gamma_ramp != NULL) {
1652  SDL_GetGammaRamp( GL_original_gamma_ramp, (GL_original_gamma_ramp+256), (GL_original_gamma_ramp+512) );
1653  }
1654 #endif
1655 
1656  return 0;
1657 }
1658 
1659 
1661 {
1662  // *****************************************************************************
1663  // NOTE: All function pointers here should have a Cmdline_nohtl check at the top
1664  // if they shouldn't be run in non-HTL mode, Don't keep separate entries.
1665 
1669 
1671 // gr_screen.gf_bitmap = gr_opengl_bitmap;
1675 
1676 // gr_screen.gf_rect = gr_opengl_rect;
1677 // gr_screen.gf_shade = gr_opengl_shade;
1683 
1691 
1693 
1696 
1699 
1703 
1706 
1708 
1712 
1714 
1716 
1717  // UnknownPlayer : Don't recognize this - MAY NEED DEBUGGING
1719 
1720  // now for the bitmap functions
1728 
1731 
1733 
1735 
1737 
1739 
1743 
1748 
1756 
1759 
1762 
1766 
1773 
1776 
1780 
1784 
1788 
1791 
1794 
1797 
1800 
1805 
1807 
1809 
1812 
1814 
1818 
1821 
1823 
1825 
1826  // NOTE: All function pointers here should have a Cmdline_nohtl check at the top
1827  // if they shouldn't be run in non-HTL mode, Don't keep separate entries.
1828  // *****************************************************************************
1829 }
1830 
1831 
1833 {
1834  const char *ver;
1835  int major = 0, minor = 0;
1836 
1837  if ( !GL_initted )
1838  atexit(opengl_close);
1839 
1840  if (GL_initted) {
1842  GL_initted = false;
1843  }
1844 
1845  mprintf(( "Initializing OpenGL graphics device at %ix%i with %i-bit color...\n",
1846  gr_screen.max_w,
1847  gr_screen.max_h,
1849 
1850  if ( opengl_init_display_device() ) {
1851  Error(LOCATION, "Unable to initialize display device!\n");
1852  }
1853 
1854  // version check
1855  ver = (const char *)glGetString(GL_VERSION);
1856  sscanf(ver, "%d.%d", &major, &minor);
1857 
1858  GL_version = (major * 10) + minor;
1859 
1860  if (GL_version < MIN_REQUIRED_GL_VERSION) {
1861  Error(LOCATION, "Current GL Version of %d.%d is less than the "
1862  "required version of %d.%d.\n"
1863  "Switch video modes or update your drivers.",
1864  major,
1865  minor,
1866  (MIN_REQUIRED_GL_VERSION / 10),
1867  (MIN_REQUIRED_GL_VERSION % 10));
1868  }
1869 
1870  GL_initted = true;
1871 
1872  // this MUST be done before any other gr_opengl_* or
1873  // opengl_* function calls!!
1875 
1876  mprintf(( " OpenGL Vendor : %s\n", glGetString(GL_VENDOR) ));
1877  mprintf(( " OpenGL Renderer : %s\n", glGetString(GL_RENDERER) ));
1878  mprintf(( " OpenGL Version : %s\n", ver ));
1879  mprintf(( "\n" ));
1880 
1883  } else {
1885  }
1886 
1887  // initialize the extensions and make sure we aren't missing something
1888  // that we need
1890 
1891  // setup the lighting stuff that will get used later
1893 
1894  // init state system (must come AFTER light is set up)
1895  GL_state.init();
1896 
1897  GLint max_texture_units = GL_supported_texture_units;
1898  GLint max_texture_coords = GL_supported_texture_units;
1899 
1900  if (is_minimum_GLSL_version()) {
1901  glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &max_texture_units);
1902  }
1903 
1904  glGetIntegerv(GL_MAX_TEXTURE_COORDS, &max_texture_coords);
1905 
1906  GL_state.Texture.init(max_texture_units);
1907  GL_state.Array.init(max_texture_coords);
1908 
1913 
1914  // ready the texture system
1916 
1917  opengl_tnl_init();
1918 
1919  // setup default shaders, and shader related items
1921 
1922  // post processing effects, after shaders are initialized
1925 
1926  // must be called after extensions are setup
1928 
1930 
1933 
1935 
1938 
1939  glDepthRange(0.0, 1.0);
1940 
1943 
1944  glFlush();
1945 
1950 
1951  Mouse_hidden++;
1953  gr_opengl_clear();
1954  gr_opengl_flip();
1955  gr_opengl_clear();
1956  gr_opengl_flip();
1957  gr_opengl_clear();
1958  Mouse_hidden--;
1959 
1962 
1963  mprintf(( " Max texture units: %i (%i)\n", GL_supported_texture_units, max_texture_units ));
1964  mprintf(( " Max client texture states: %i (%i)\n", GL_supported_texture_units, max_texture_coords ));
1965  mprintf(( " Max elements vertices: %i\n", GL_max_elements_vertices ));
1966  mprintf(( " Max elements indices: %i\n", GL_max_elements_indices ));
1967  mprintf(( " Max texture size: %ix%i\n", GL_max_texture_width, GL_max_texture_height ));
1968 
1970  mprintf(( " Max render buffer size: %ix%i\n",
1973  }
1974 
1975  mprintf(( " Can use compressed textures: %s\n", Use_compressed_textures ? NOX("YES") : NOX("NO") ));
1976  mprintf(( " Texture compression available: %s\n", Texture_compression_available ? NOX("YES") : NOX("NO") ));
1977  mprintf(( " Post-processing enabled: %s\n", (Cmdline_postprocess) ? "YES" : "NO"));
1978  mprintf(( " Using %s texture filter.\n", (GL_mipmap_filter) ? NOX("trilinear") : NOX("bilinear") ));
1979 
1980  if (is_minimum_GLSL_version()) {
1981  mprintf(( " OpenGL Shader Version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION) ));
1982  }
1983 
1984  // This stops fred crashing if no textures are set
1986 
1987  mprintf(("... OpenGL init is complete!\n"));
1988 
1990  GL_read_format = GL_RGBA;
1991 
1992  return true;
1993 }
1994 
1995 DCF(ogl_minimize, "Minimizes opengl")
1996 {
1997  bool minimize_ogl = false;
1998 
1999  if ( gr_screen.mode != GR_OPENGL ) {
2000  dc_printf("Command only available in OpenGL mode.\n");
2001  return;
2002  }
2003 
2004  if (dc_optional_string_either("help", "--help")) {
2005  dc_printf("[bool] If true is passed, then the OpenGL window will minimize.\n");
2006  return;
2007  }
2008  dc_stuff_boolean(&minimize_ogl);
2009 
2010  if (minimize_ogl) {
2011  opengl_minimize();
2012  }
2013 }
2014 
2015 DCF(ogl_anisotropy, "toggles anisotropic filtering")
2016 {
2017  bool process = true;
2018  int value;
2019 
2020  if ( gr_screen.mode != GR_OPENGL ) {
2021  dc_printf("Can only set anisotropic filter in OpenGL mode.\n");
2022  return;
2023  }
2024 
2025  if (dc_optional_string_either("help", "--help")) {
2026  dc_printf("Sets OpenGL anisotropic filtering level.\n");
2027  dc_printf("GL_anisotropy [int] Valid values are 0 to %i. 0 turns off anisotropic filtering.\n", (int)opengl_get_max_anisotropy());
2028  process = false;
2029  }
2030 
2031  if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
2032  dc_printf("Current anisotropic filter value is %i\n", (int)GL_anisotropy);
2033  process = false;
2034  }
2035 
2036  if (!process) {
2037  return;
2038  }
2039 
2041  dc_printf("Error: Anisotropic filter is not settable!\n");
2042  return;
2043  }
2044 
2045  if (!dc_maybe_stuff_int(&value)) {
2046  // No arg passed, set to default
2047  GL_anisotropy = 1.0f;
2048  // opengl_set_anisotropy();
2049  dc_printf("Anisotropic filter value reset to default level.\n");
2050  } else {
2051  GL_anisotropy = (GLfloat)value;
2052  // opengl_set_anisotropy( (float)Dc_arg_float );
2053  }
2054 }
2055 
2065  return GLSL_version >= MIN_REQUIRED_GLSL_VERSION ? true : false;
2066 }
unsigned int GLuint
Definition: Gl.h:52
int gr_alpha_test
Definition: 2d.cpp:79
GLboolean ColorMask(GLint state=-1)
WINGDIAPI void APIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
bool gr_opengl_init()
Definition: gropengl.cpp:1832
int bits
Definition: grinternal.h:28
#define vm_malloc_q(size)
Definition: pstypes.h:554
void SetPolygonMode(GLenum face, GLenum mode)
#define GL_PACK_ALIGNMENT
Definition: Gl.h:504
void(* gf_aaline)(vertex *v1, vertex *v2)
Definition: 2d.h:451
void * HWND
Definition: config.h:104
int i
Definition: multi_pxo.cpp:466
#define vm_free(ptr)
Definition: pstypes.h:548
void(* gf_set_proj_matrix)(float, float, float, float)
Definition: 2d.h:567
uint os_config_read_uint(const char *section, const char *name, uint default_value)
Definition: osregistry.cpp:372
#define OGL_EXT_FRAMEBUFFER_OBJECT
void gr_opengl_copy_effect_texture()
color_gun Gr_ta_alpha
Definition: 2d.cpp:50
void gr_opengl_aaline(vertex *v1, vertex *v2)
#define gr_clear
Definition: 2d.h:749
void(* gf_destroy_light)(int)
Definition: 2d.h:582
void gr_opengl_clear()
Definition: gropengl.cpp:312
bool GL_initted
Definition: gropengl.cpp:60
void gr_opengl_shadow_map_end()
WINGDIAPI void APIENTRY glFinish(void)
void opengl_post_process_shutdown()
void(* gf_fog_set)(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
Definition: 2d.h:516
void(* gf_bm_create)(int n)
Definition: 2d.h:538
void gr_opengl_end_projection_matrix()
#define GL_FOG_COORDINATE_SOURCE_EXT
Definition: Glext.h:2937
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
WINGDIAPI void APIENTRY glLineWidth(GLfloat width)
void gr_flip()
Definition: 2d.cpp:2113
void init(GLuint n_units)
void(* gf_set_palette)(const ubyte *new_pal, int restrict_alphacolor)
Definition: 2d.h:412
int offset_y_unscaled
Definition: 2d.h:377
int current_fog_mode
Definition: 2d.h:394
void(* gf_bm_free_data)(int n, bool release)
Definition: 2d.h:537
color_gun Gr_t_red
Definition: 2d.cpp:49
void(* gf_push_texture_matrix)(int unit)
Definition: 2d.h:547
#define GL_FRONT_LEFT
Definition: Gl.h:215
void(* gf_free_screen)(int id)
Definition: 2d.h:502
int gr_opengl_zbuffer_set(int mode)
Definition: gropengl.cpp:733
void gr_opengl_set_texture_panning(float u, float v, bool enable)
void(* gf_shadow_map_start)(const matrix4 *shadow_view_matrix, const matrix *light_matrix)
Definition: 2d.h:634
GLfloat opengl_get_max_anisotropy()
color_gun Gr_ta_blue
Definition: 2d.cpp:50
#define GL_FRONT
Definition: Gl.h:219
int shift
Definition: grinternal.h:29
GLsizei const GLfloat * value
Definition: Glext.h:5646
int mode
Definition: 2d.h:371
color_gun Gr_ta_red
Definition: 2d.cpp:50
WINGDIAPI void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
opengl_array_state Array
int Fred_running
Definition: fred.cpp:44
int gr_opengl_make_light(light *fs_light, int idx, int priority)
GLint GLfloat GLint stencil
Definition: Glext.h:5837
GLint GL_max_elements_vertices
Definition: gropengltnl.cpp:74
void(* gf_sphere_htl)(float rad)
Definition: 2d.h:621
void SetTextureSource(gr_texture_source ts)
#define GR_STENCIL_WRITE
Definition: 2d.h:679
GLboolean StencilTest(GLint state=-1)
void gr_opengl_set_line_width(float width)
Definition: gropengl.cpp:1233
WINGDIAPI void APIENTRY glMatrixMode(GLenum mode)
void(* gf_aabitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode, bool mirror)
Definition: 2d.h:431
#define GR_ZBUFF_READ
Definition: 2d.h:674
GLboolean ScissorTest(GLint state=-1)
WINGDIAPI void APIENTRY glLoadIdentity(void)
WINGDIAPI void APIENTRY glClear(GLbitfield mask)
void(* gf_stencil_clear)()
Definition: 2d.h:491
void(* gf_reset_lighting)()
Definition: 2d.h:584
#define GL_UNPACK_ALIGNMENT
Definition: Gl.h:498
void opengl_set_vsync(int status)
Definition: gropengl.cpp:1275
void(* gf_center_alpha)(int)
Definition: 2d.h:605
void(* gf_get_bitmap_from_texture)(void *data_out, int bitmap_num)
Definition: 2d.h:632
void(* gf_render_effect)(int nv, vertex *verts, float *radius_list, uint flags)
Definition: 2d.h:467
void(* gf_shadow_map_end)()
Definition: 2d.h:635
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void(* gf_line)(int x1, int y1, int x2, int y2, int resize_mode)
Definition: 2d.h:444
Assert(pm!=NULL)
int clip_width_unscaled
Definition: 2d.h:379
int(* gf_bm_set_render_target)(int n, int face)
Definition: 2d.h:544
bool dc_maybe_stuff_int(int *i)
Tries to stuff an int from the Command_string.
Definition: pstypes.h:88
#define mprintf(args)
Definition: pstypes.h:238
void gr_opengl_end_clip_plane()
void gr_opengl_set_thrust_scale(float scale)
GLint GLint GLsizei GLsizei GLsizei depth
Definition: Glext.h:5180
void(* gf_set_animated_effect)(int effect, float timer)
Definition: 2d.h:625
GLboolean DepthTest(GLint state=-1)
void gr_opengl_set_lighting(bool set, bool state)
GLint GL_max_elements_indices
Definition: gropengltnl.cpp:75
int max_h_unscaled
Definition: 2d.h:361
void(* gf_flash)(int r, int g, int b)
Definition: 2d.h:415
void(* gf_set_view_matrix)(const vec3d *, const matrix *)
Definition: 2d.h:570
void gr_opengl_set_fill_mode(int mode)
Definition: gropengl.cpp:1150
#define GR_ZBUFF_FULL
Definition: 2d.h:675
void gr_opengl_set_transform_buffer_offset(int offset)
void(* gf_deferred_lighting_end)()
Definition: 2d.h:596
struct vec3d::@225::@227 xyz
void(* gf_post_process_set_effect)(const char *, int)
Definition: 2d.h:588
GLclampf f
Definition: Glext.h:7097
#define INTEL_SHORT(x)
Definition: pstypes.h:389
void(* gf_scene_texture_begin)()
Definition: 2d.h:599
GLfloat bias
Definition: Glext.h:7380
void SetZbufferType(gr_zbuffer_type zt)
int Cmdline_ati_color_swap
Definition: cmdline.cpp:445
#define GR_ZBUFF_NONE
Definition: 2d.h:672
const char * Osreg_user_dir
void gr_opengl_zbias(int bias)
Definition: gropengl.cpp:1166
#define TRUE
Definition: pstypes.h:399
int Mouse_hidden
Definition: mouse.cpp:52
int bits_per_pixel
Definition: 2d.h:374
void gr_opengl_push_texture_matrix(int unit)
Definition: gropengl.cpp:1181
int(* gf_set_cull)(int cull)
Definition: 2d.h:519
float clip_center_y
Definition: 2d.h:381
void gr_opengl_destroy_light(int idx)
#define GL_FOG_START
Definition: Gl.h:410
void gr_opengl_aabitmap(int x, int y, int resize_mode, bool mirror)
bool gr_opengl_config_buffer(const int buffer_id, vertex_buffer *vb, bool update_ibuffer_only)
void gr_opengl_restore_screen(int bmp_id)
Definition: gropengl.cpp:1114
bool(* gf_pack_buffer)(const int buffer_id, vertex_buffer *vb)
Definition: 2d.h:553
#define vglUnmapBufferARB
void gr_opengl_reset_lighting()
#define GL_BACK
Definition: Gl.h:220
GLenum mode
Definition: Glext.h:5794
int opengl_init_display_device()
Definition: gropengl.cpp:1377
int gr_stencil_mode
Definition: 2d.cpp:76
int(* gf_maybe_create_shader)(shader_type type, unsigned int flags)
Definition: 2d.h:623
void gr_opengl_cross_fade(int bmap1, int bmap2, int x1, int y1, int x2, int y2, float pct, int resize_mode)
#define GL_UNSIGNED_SHORT_1_5_5_5_REV
Definition: Glext.h:74
int(* gf_set_color_buffer)(int mode)
Definition: 2d.h:522
int mouse_get_pos(int *xpos, int *ypos)
Definition: mouse.cpp:512
opengl_texture_state Texture
#define GR_FILL_MODE_SOLID
Definition: 2d.h:670
void gr_opengl_update_texture(int bitmap_handle, int bpp, const ubyte *data, int width, int height)
ubyte blue
Definition: 2d.h:102
GLboolean CullFace(GLint state=-1)
void gr_opengl_activate(int active)
Definition: gropengl.cpp:287
void gr_opengl_sphere_htl(float rad)
typedef HGLRC(WINAPI *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC
const char * detect_home(void)
Definition: osapi.cpp:101
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
Definition: 2d.cpp:2105
int max_w_unscaled
Definition: 2d.h:361
bool(* gf_bm_data)(int n, bitmap *bm)
Definition: 2d.h:541
#define Int3()
Definition: pstypes.h:292
void(* gf_draw_line_list)(const colored_vector *lines, int num)
Definition: 2d.h:616
int gr_opengl_stencil_set(int mode)
Definition: gropengl.cpp:774
bool Cmdline_gl_finish
Definition: cmdline.cpp:450
float clip_center_x
Definition: 2d.h:381
int gr_opengl_create_buffer()
color current_clear_color
Definition: 2d.h:398
int(* gf_stencil_set)(int mode)
Definition: 2d.h:488
void(* gf_bm_page_in_start)()
Definition: 2d.h:540
color_gun * Gr_current_green
Definition: 2d.cpp:51
#define GR_RESIZE_NONE
Definition: 2d.h:681
void(* gf_flip)()
Definition: 2d.h:409
void(* gf_pixel)(int x, int y, int resize_mode)
Definition: 2d.h:453
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
Definition: bmpman.cpp:2603
void(* gf_set_gamma)(float gamma)
Definition: 2d.h:505
#define GR_OPENGL
Definition: 2d.h:648
void gr_opengl_end_instance_matrix()
void gr_opengl_clear_states()
void gr_opengl_center_alpha(int type)
#define GL_VENDOR
Definition: Gl.h:889
int(* gf_create_buffer)()
Definition: 2d.h:552
void(* gf_translate_texture_matrix)(int unit, const vec3d *shift)
Definition: 2d.h:546
void opengl_close()
Definition: gropengl.cpp:1371
void opengl_tcache_shutdown()
WINGDIAPI void APIENTRY glPopMatrix(void)
GLenum CullFaceValue(GLenum new_val=GL_INVALID_ENUM)
int clip_height
Definition: 2d.h:378
void gr_opengl_modify_light(light *fs_light, int idx, int priority)
#define GL_FOG_COORDINATE_EXT
Definition: Glext.h:2938
#define CLAMP(x, min, max)
Definition: pstypes.h:488
GLint GLsizei width
Definition: Gl.h:1505
void(* gf_circle)(int x, int y, int r, int resize_mode)
Definition: 2d.h:438
#define GL_BGRA
Definition: Glext.h:78
void SetStencilType(gr_stencil_type st)
ubyte green
Definition: 2d.h:101
int GL_version
Definition: gropengl.cpp:57
void(* gf_arc)(int x, int y, float r, float angle_start, float angle_end, bool fill, int resize_mode)
Definition: 2d.h:440
unsigned char GLubyte
Definition: Gl.h:50
WINGDIAPI void APIENTRY glFlush(void)
int _getcwd(char *buffer, unsigned int len)
int bm_is_valid(int handle)
Checks if the bitmap indexed by handle is valid.
Definition: bmpman.cpp:1006
void(* gf_set_clip)(int x, int y, int w, int h, int resize_mode)
Definition: 2d.h:419
int gr_opengl_bm_set_render_target(int n, int face)
void opengl_setup_viewport()
Definition: gropengl.cpp:1297
void(* gf_post_process_set_defaults)()
Definition: 2d.h:589
int Gr_cursor_size
Definition: 2d.cpp:61
uint os_get_window()
Definition: osapi.cpp:208
#define GL_FALSE
Definition: Gl.h:139
#define GL_FOG_END
Definition: Gl.h:411
WINGDIAPI void APIENTRY glDepthRange(GLclampd zNear, GLclampd zFar)
void gr_opengl_flash_alpha(int r, int g, int b, int a)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
const char * Osreg_title
Definition: osregistry.cpp:36
GLint GL_max_texture_height
#define gr_reset_clip
Definition: 2d.h:745
void gr_opengl_line(int x1, int y1, int x2, int y2, int resize_mode)
void(* gf_unfilled_circle)(int x, int y, int r, int resize_mode)
Definition: 2d.h:439
void gr_opengl_set_light_factor(float factor)
void gr_opengl_render_stream_buffer(int buffer_handle, int offset, int n_verts, int flags)
void(* gf_destroy_buffer)(int)
Definition: 2d.h:555
int Cmdline_nohtl
Definition: cmdline.cpp:438
float FreeSpace_gamma
Definition: gropengl.cpp:100
void gr_opengl_bm_free_data(int n, bool release)
int clip_left_unscaled
Definition: 2d.h:390
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
int(* gf_alpha_mask_set)(int mode, float alpha)
Definition: 2d.h:493
#define GL_LINEAR
Definition: Gl.h:931
void gr_opengl_scene_texture_begin()
int Texture_compression_available
Definition: ddsutils.cpp:19
void(* gf_start_clip_plane)()
Definition: 2d.h:608
unsigned int uint
Definition: pstypes.h:64
#define GL_FOG_DISTANCE_MODE_NV
Definition: Glext.h:3200
void opengl_extensions_init()
void opengl_go_fullscreen()
Definition: gropengl.cpp:110
int offset_x
Definition: 2d.h:376
GLboolean GLboolean g
Definition: Glext.h:5781
void gr_opengl_render_buffer(int start, const vertex_buffer *bufferp, int texi, int flags)
#define nprintf(args)
Definition: pstypes.h:239
void(* gf_set_light_factor)(float)
Definition: 2d.h:604
int clip_top_unscaled
Definition: 2d.h:390
void opengl_shader_shutdown()
void gr_opengl_deferred_lighting_finish()
#define vglDeleteBuffersARB
int clip_right_unscaled
Definition: 2d.h:390
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: Glext.h:7307
int _mkdir(const char *path)
void gr_opengl_deferred_lighting_end()
float clip_aspect
Definition: 2d.h:372
void gr_opengl_set_clear_color(int r, int g, int b)
Definition: gropengl.cpp:704
void gr_opengl_update_buffer_object(int handle, uint size, void *data)
void gr_opengl_reset_clip()
Definition: gropengl.cpp:453
int offset_x_unscaled
Definition: 2d.h:377
void opengl_tcache_flush()
const char * opengl_error_string()
Definition: gropengl.cpp:1239
bool GL_rendering_to_texture
char * filename
void gr_opengl_stencil_clear()
Definition: gropengl.cpp:794
void SetPolygonOffset(GLfloat factor, GLfloat units)
void(* gf_set_transform_buffer_offset)(int offset)
Definition: 2d.h:561
int Use_compressed_textures
Definition: ddsutils.cpp:20
GLboolean AlphaTest(GLint state=-1)
int mask
Definition: grinternal.h:31
void(* gf_set_texture_panning)(float u, float v, bool enable)
Definition: 2d.h:614
#define GL_PERSPECTIVE_CORRECTION_HINT
Definition: Gl.h:464
void(* gf_tmapper)(int nv, vertex *verts[], uint flags)
Definition: 2d.h:462
void gr_opengl_destroy_buffer(int idx)
void gr_opengl_shutdown()
Definition: gropengl.cpp:1316
#define w(p)
Definition: modelsinc.h:68
#define GL_EYE_RADIAL_NV
Definition: Glext.h:3201
void(* gf_end_view_matrix)()
Definition: 2d.h:571
int(* gf_bm_make_render_target)(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags)
Definition: 2d.h:543
GLint GL_supported_texture_units
void SetAlphaBlendMode(gr_alpha_blend ab)
void gr_opengl_unfilled_circle(int xc, int yc, int d, int resize_mode)
color_gun Gr_ta_green
Definition: 2d.cpp:50
color_gun * Gr_current_red
Definition: 2d.cpp:51
#define vglBindBufferARB
ubyte red
Definition: 2d.h:100
void gr_opengl_pixel(int x, int y, int resize_mode)
void(* gf_update_texture)(int bitmap_handle, int bpp, const ubyte *data, int width, int height)
Definition: 2d.h:631
void(* gf_restore_screen)(int id)
Definition: 2d.h:499
void opengl_light_shutdown()
void os_resume()
Definition: osapi.cpp:244
int(* gf_zbuffer_set)(int mode)
Definition: 2d.h:482
void gr_opengl_cleanup(int minimize)
Definition: gropengl.cpp:587
void(* gf_update_transform_buffer)(void *data, uint size)
Definition: 2d.h:560
int GL_mipmap_filter
void(* gf_end_clip_plane)()
Definition: 2d.h:609
void(* gf_clear_states)()
Definition: 2d.h:627
int Use_PBOs
Definition: gropengl.cpp:77
#define MB_OK
Definition: config.h:179
void gr_opengl_set_buffer(int idx)
#define GL_LINE
Definition: Gl.h:843
void gr_opengl_bm_page_in_start()
#define GL_NICEST
Definition: Gl.h:623
WINGDIAPI void APIENTRY glTranslated(GLdouble x, GLdouble y, GLdouble z)
void(* gf_start_angles_instance_matrix)(const vec3d *, const angles *)
Definition: 2d.h:577
void gr_opengl_post_process_end()
bool dc_optional_string_either(const char *str1, const char *str2)
Searches for an optional string and it's alias.
color_gun * Gr_current_blue
Definition: 2d.cpp:51
void gr_opengl_push_scale_matrix(const vec3d *scale_factor)
#define GL_TRUE
Definition: Gl.h:138
void opengl_setup_function_pointers()
Definition: gropengl.cpp:1660
void gr_opengl_end_view_matrix()
void gr_opengl_string(float sx, float sy, const char *s, int resize_mode)
#define GL_CHECK_FOR_ERRORS(s)
Definition: gropengl.h:661
void gr_opengl_circle(int xc, int yc, int d, int resize_mode)
void(* gf_lighting)(bool, bool)
Definition: 2d.h:603
void gr_opengl_free_screen(int bmp_id)
Definition: gropengl.cpp:1132
int(* gf_make_light)(light *, int, int)
Definition: 2d.h:580
void(* gf_bm_init)(int n)
Definition: 2d.h:539
int clip_bottom
Definition: 2d.h:388
void opengl_minimize()
Definition: gropengl.cpp:236
int gr_opengl_set_color_buffer(int mode)
Definition: gropengl.cpp:709
void gr_opengl_set_projection_matrix(float fov, float aspect, float z_near, float z_far)
int(* gf_preload)(int bitmap_num, int is_aabitmap)
Definition: 2d.h:531
int Cmdline_window
Definition: cmdline.cpp:502
void(* gf_post_process_begin)()
Definition: 2d.h:591
void(* gf_post_process_save_zbuffer)()
Definition: 2d.h:593
void mouse_eval_deltas()
Definition: mouse.cpp:383
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: Glext.h:5180
#define MB_ICONERROR
Definition: config.h:190
int mouse_is_visible()
Definition: mouse.cpp:83
int scale
Definition: grinternal.h:30
#define Is_Extension_Enabled(x)
void SetTarget(GLenum tex_target)
WINGDIAPI void APIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
int clip_top
Definition: 2d.h:388
void(* gf_flash_alpha)(int r, int g, int b, int a)
Definition: 2d.h:416
void(* gf_scaler)(vertex *va, vertex *vb, bool bw_bitmap)
Definition: 2d.h:456
#define GL_FRONT_AND_BACK
Definition: Gl.h:223
void(* gf_string)(int x, int y, const char *text, int resize_mode)
Definition: 2d.h:433
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
for(int idx=0;idx< i;idx++)
Definition: multi_pxo.cpp:472
#define GL_MAX_ELEMENTS_INDICES
Definition: Glext.h:80
ubyte alpha
Definition: 2d.h:103
unsigned char ubyte
Definition: pstypes.h:62
void gr_opengl_pop_scale_matrix()
#define GL_VERSION
Definition: Gl.h:891
void Enable(GLuint tex_id=0)
int GLSL_version
Definition: gropengl.cpp:58
int bm_create(int bpp, int w, int h, void *data, int flags)
Definition: bmpman.cpp:469
#define GL_MAX_ELEMENTS_VERTICES
Definition: Glext.h:79
#define GL_MODELVIEW
Definition: Gl.h:751
void gr_opengl_aabitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode, bool mirror)
void(* gf_set_line_width)(float width)
Definition: 2d.h:618
int Cmdline_fullscreen_window
Definition: cmdline.cpp:503
color_gun Gr_t_blue
Definition: 2d.cpp:49
#define vglMapBufferARB
void(* gf_reset_clip)()
Definition: 2d.h:422
WINGDIAPI void APIENTRY glGetIntegerv(GLenum pname, GLint *params)
WINGDIAPI void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
typedef HDC(WINAPI *PFNWGLGETCURRENTREADDCARBPROC)(void)
int max_w
Definition: 2d.h:360
bool gr_opengl_bm_data(int n, bitmap *bm)
void opengl_save_mouse_area(int x, int y, int w, int h)
Definition: gropengl.cpp:925
#define NOX(s)
Definition: pstypes.h:473
WINGDIAPI void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
void gr_opengl_flash(int r, int g, int b)
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
GLint GL_max_texture_width
void gr_opengl_post_process_save_zbuffer()
void opengl_tcache_init()
#define GL_UNSIGNED_INT_8_8_8_8_REV
Definition: Glext.h:75
GLbitfield flags
Definition: Glext.h:6722
#define vglActiveTextureARB
unsigned char GLboolean
Definition: Gl.h:44
void gr_opengl_render_effect(int nverts, vertex *verts, float *radius_list, uint flags)
#define INTEL_INT(x)
Definition: pstypes.h:388
void init(GLuint n_units)
int Cmdline_no_vsync
Definition: cmdline.cpp:354
void gr_opengl_post_process_begin()
void gr_opengl_set_team_color(const team_color *colors)
color current_fog_color
Definition: 2d.h:397
int offset_y
Definition: 2d.h:376
GLfloat GL_anisotropy
color_gun Gr_t_alpha
Definition: 2d.cpp:49
GLuint GLfloat * val
Definition: Glext.h:6741
float Gr_gamma
Definition: 2d.cpp:67
void(* gf_set_clear_color)(int r, int g, int b)
Definition: 2d.h:534
#define MAX_PATH_LEN
Definition: pstypes.h:325
void gr_opengl_tmapper(int nverts, vertex **verts, uint flags)
DCF(ogl_minimize,"Minimizes opengl")
Definition: gropengl.cpp:1995
void(* gf_line_htl)(const vec3d *start, const vec3d *end)
Definition: 2d.h:620
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
#define GL_TEXTURE_2D
Definition: Gl.h:570
GLboolean PolygonOffsetFill(GLint state=-1)
void dc_stuff_boolean(bool *b)
stuffs a boolean evaluated integer or string into the given variable.
void gr_opengl_print_screen(const char *filename)
Definition: gropengl.cpp:480
int gr_global_zbuffering
Definition: 2d.cpp:73
#define vglXSwapIntervalSGI
int gr_opengl_save_screen()
Definition: gropengl.cpp:983
bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
Definition: 2d.cpp:212
color_gun Gr_red
Definition: 2d.cpp:48
void opengl_setup_scene_textures()
int clip_right
Definition: 2d.h:388
int Cmdline_no_set_gamma
Definition: cmdline.cpp:440
void(* gf_set_texture_addressing)(int)
Definition: 2d.h:550
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void(* gf_copy_effect_texture)()
Definition: 2d.h:601
int(* PFNGLXSWAPINTERVALSGIPROC)(int interval)
Definition: gropengl.cpp:42
int gr_opengl_bm_make_render_target(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags)
void gr_opengl_deferred_lighting_begin()
void(* gf_scene_texture_end)()
Definition: 2d.h:600
void(* gf_pop_texture_matrix)(int unit)
Definition: 2d.h:548
int gr_opengl_maybe_create_shader(shader_type shader_t, unsigned int flags)
#define GL_FOG_COLOR
Definition: Gl.h:413
#define GL_FRAGMENT_DEPTH
Definition: Glext.h:311
void(* gf_set_fill_mode)(int)
Definition: 2d.h:613
opengl_state GL_state
#define GL_FOG_MODE
Definition: Gl.h:412
GLint GLsizei GLsizei height
Definition: Gl.h:1505
GLboolean Fog(GLint state=-1)
#define strcat_s(...)
Definition: safe_strings.h:68
bool(* gf_config_buffer)(const int buffer_id, vertex_buffer *vb, bool update_ibuffer_only)
Definition: 2d.h:554
void(* gf_post_process_end)()
Definition: 2d.h:592
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
WINGDIAPI void APIENTRY glPushMatrix(void)
int clip_bottom_unscaled
Definition: 2d.h:390
bool gr_opengl_pack_buffer(const int buffer_id, vertex_buffer *vb)
int gr_opengl_preload(int bitmap_num, int is_aabitmap)
int gr_opengl_alpha_mask_set(int mode, float alpha)
Definition: gropengl.cpp:799
int OGL_fogmode
Definition: gropengl.cpp:66
int gr_zbuffering
Definition: 2d.cpp:71
void(* gf_zbuffer_clear)(int use_zbuffer)
Definition: 2d.h:485
void gr_opengl_get_bitmap_from_texture(void *data_out, int bitmap_num)
void(* gf_set_ambient_light)(int, int, int)
Definition: 2d.h:585
#define GL_GREATER
Definition: Gl.h:76
void gr_opengl_flip()
Definition: gropengl.cpp:321
void(* gf_start_instance_matrix)(const vec3d *, const matrix *)
Definition: 2d.h:576
void gr_opengl_set_gamma(float gamma)
Definition: gropengl.cpp:872
WINGDIAPI void APIENTRY glHint(GLenum target, GLenum mode)
int clip_width
Definition: 2d.h:378
WINGDIAPI void APIENTRY glPixelStorei(GLenum pname, GLint param)
int Gr_gamma_int
Definition: 2d.cpp:68
screen gr_screen
Definition: 2d.cpp:46
void opengl_set_texture_target(GLenum target)
void gr_opengl_line_htl(const vec3d *start, const vec3d *end)
int Use_VBOs
Definition: gropengl.cpp:76
void(* gf_pop_scale_matrix)()
Definition: 2d.h:574
unsigned short ushort
Definition: pstypes.h:63
bool custom_size
Definition: 2d.h:402
color_gun Gr_alpha
Definition: 2d.cpp:48
void(* gf_deferred_lighting_finish)()
Definition: 2d.h:597
void gr_opengl_set_texture_addressing(int mode)
void gr_opengl_scaler(vertex *va, vertex *vb, bool bw_bitmap=false)
color_gun * Gr_current_alpha
Definition: 2d.cpp:51
void gr_opengl_pop_texture_matrix(int unit)
Definition: gropengl.cpp:1197
#define GL_CCW
Definition: Gl.h:339
#define GL_ALWAYS
Definition: Gl.h:79
void gr_opengl_set_ambient_light(int red, int green, int blue)
color_gun Gr_t_green
Definition: 2d.cpp:49
int clip_height_unscaled
Definition: 2d.h:379
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
#define LOCATION
Definition: pstypes.h:245
int gr_opengl_zbuffer_get()
Definition: gropengl.cpp:724
int max_h
Definition: 2d.h:360
#define OGL_EXT_TEXTURE_FILTER_ANISOTROPIC
WINGDIAPI void APIENTRY glFogf(GLenum pname, GLfloat param)
void gr_opengl_shadow_map_start(const matrix4 *shadow_view_matrix, const matrix *light_orient)
int MessageBox(HWND h, const char *s1, const char *s2, int i)
GLenum GLsizei GLenum GLenum const GLvoid * data
Definition: Gl.h:1509
WINGDIAPI void APIENTRY glFogfv(GLenum pname, const GLfloat *params)
color_gun Gr_green
Definition: 2d.cpp:48
GLint GL_max_renderbuffer_size
void(* gf_set_light)(light *)
Definition: 2d.h:583
#define GL_SHADING_LANGUAGE_VERSION
Definition: Glext.h:458
void gr_opengl_start_instance_matrix(const vec3d *offset, const matrix *rotation)
uint os_get_dc()
Definition: osapi.cpp:213
void opengl_scene_texture_shutdown()
bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
Definition: 2d.cpp:320
#define GL_TEXTURE
Definition: Gl.h:753
void opengl_light_init()
int gr_opengl_create_stream_buffer_object()
#define vglBufferDataARB
void(* gf_push_scale_matrix)(const vec3d *)
Definition: 2d.h:573
WINGDIAPI const GLubyte *APIENTRY glGetString(GLenum name)
void opengl_go_windowed()
Definition: gropengl.cpp:184
#define GL_MATRIX_MODE
Definition: Gl.h:429
#define i2fl(i)
Definition: floating.h:32
void gr_opengl_zbuffer_clear(int mode)
Definition: gropengl.cpp:753
void(* gf_cross_fade)(int bmap1, int bmap2, int x1, int y1, int x2, int y2, float pct, int resize_mode)
Definition: 2d.h:525
#define GR_STENCIL_READ
Definition: 2d.h:678
void(* gf_zbias)(int zbias)
Definition: 2d.h:611
unsigned int GLenum
Definition: Gl.h:43
void gr_bitmap(int _x, int _y, int resize_mode)
Definition: 2d.cpp:1303
void AlphaFunc(GLenum f_val, GLclampf r_val)
int(* gf_zbuffer_get)()
Definition: 2d.h:479
void gr_opengl_set_clip(int x, int y, int w, int h, int resize_mode)
Definition: gropengl.cpp:365
int(* gf_save_screen)()
Definition: 2d.h:496
int gr_opengl_tcache_set(int bitmap_handle, int bitmap_type, float *u_scale, float *v_scale, int stage)
void opengl_shader_init()
void(* gf_get_region)(int front, int w, int h, ubyte *data)
Definition: 2d.h:513
void(* gf_set_thrust_scale)(float)
Definition: 2d.h:606
void gr_opengl_translate_texture_matrix(int unit, const vec3d *shift)
Definition: gropengl.cpp:1213
#define GL_PROJECTION
Definition: Gl.h:752
void opengl_tcache_frame()
void(* gf_clear)()
Definition: 2d.h:425
int gr_zbuffering_mode
Definition: 2d.cpp:72
void gr_opengl_post_process_set_effect(const char *name, int value)
void dc_printf(const char *format,...)
Prints the given char string to the debug console.
Definition: console.cpp:358
WINGDIAPI void APIENTRY glShadeModel(GLenum mode)
void(* gf_aabitmap)(int x, int y, int resize_mode, bool mirror)
Definition: 2d.h:430
void(* gf_set_team_color)(const team_color *colors)
Definition: 2d.h:629
bool is_minimum_GLSL_version()
Definition: gropengl.cpp:2064
void(* gf_end_instance_matrix)()
Definition: 2d.h:578
#define vglGenBuffersARB
#define GL_READ_ONLY
Definition: Glext.h:341
int Cmdline_postprocess
Definition: cmdline.cpp:335
void gr_opengl_start_clip_plane()
void opengl_post_process_init()
void gr_opengl_set_view_matrix(const vec3d *pos, const matrix *orient)
int clip_left
Definition: 2d.h:388
void(* gf_render_stream_buffer)(int buffer_handle, int offset, int n_verts, int flags)
Definition: 2d.h:564
#define GL_FILL
Definition: Gl.h:844
void gr_opengl_bm_create(int n)
void gr_opengl_update_transform_buffer(void *data, uint size)
void(* gf_deferred_lighting_begin)()
Definition: 2d.h:595
#define GL_FOG_COORDINATE_SOURCE
Definition: Glext.h:309
void gr_opengl_set_palette(const ubyte *new_palette, int is_alphacolor)
Definition: gropengl.cpp:476
void gr_opengl_fog_set(int fog_mode, int r, int g, int b, float fog_near, float fog_far)
Definition: gropengl.cpp:633
#define vwglSwapIntervalEXT
#define GL_PIXEL_PACK_BUFFER_ARB
Definition: Glext.h:1539
#define GL_TEXTURE0_ARB
Definition: Glext.h:1051
void(* gf_end_proj_matrix)()
Definition: 2d.h:568
#define GL_STATIC_READ
Definition: Glext.h:351
void gr_opengl_set_light(light *fs_light)
void gr_opengl_arc(int xc, int yc, float r, float angle_start, float angle_end, bool fill, int resize_mode)
GLclampf GLclampf GLclampf alpha
Definition: Glext.h:5177
int rendering_to_texture
Definition: 2d.h:403
void opengl_tnl_shutdown()
void gr_opengl_get_region(int front, int w, int h, ubyte *data)
Definition: gropengl.cpp:903
void(* gf_curve)(int x, int y, int r, int direction, int resize_mode)
Definition: 2d.h:441
void(* gf_set_buffer)(int)
Definition: 2d.h:556
#define FALSE
Definition: pstypes.h:400
#define GL_COLOR_BUFFER_BIT
Definition: Gl.h:96
void(* gf_print_screen)(const char *filename)
Definition: 2d.h:470
GLenum FrontFaceValue(GLenum new_val=GL_INVALID_ENUM)
void gr_opengl_gradient(int x1, int y1, int x2, int y2, int resize_mode)
void(* gf_render)(int nv, vertex *verts, uint flags)
Definition: 2d.h:465
WINGDIAPI GLenum APIENTRY glGetError(void)
#define GL_NO_ERROR
Definition: Gl.h:298
#define GL_MAX_TEXTURE_IMAGE_UNITS
Definition: Glext.h:418
void(* gf_bitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode)
Definition: 2d.h:428
void gr_init_color(color *c, int r, int g, int b)
Definition: 2d.cpp:1155
void opengl_tnl_init()
#define GL_MAX_TEXTURE_COORDS
Definition: Glext.h:472
void os_suspend()
Definition: osapi.cpp:238
void gr_opengl_start_instance_angles(const vec3d *pos, const angles *rotation)
void gr_opengl_scene_texture_end()
void gr_opengl_shader_set_animated_effect(int effect, float timer)
#define GL_STENCIL_BUFFER_BIT
Definition: Gl.h:92
void SetActiveUnit(GLuint id=0)
void(* gf_render_buffer)(int, const vertex_buffer *, int, int)
Definition: 2d.h:557
int opengl_check_for_errors(char *err_at)
Definition: gropengl.cpp:1252
int(* gf_create_stream_buffer)()
Definition: 2d.h:563
#define GR_FILL_MODE_WIRE
Definition: 2d.h:669
void gr_opengl_draw_line_list(const colored_vector *lines, int num)
int Gr_cursor
Definition: 2d.cpp:59
GLint y
Definition: Gl.h:1505
void gr_opengl_curve(int xc, int yc, int r, int direction, int resize_mode)
int(* gf_tcache_set)(int bitmap_id, int bitmap_type, float *u_scale, float *v_scale, int stage)
Definition: 2d.h:528
void gr_opengl_bm_init(int n)
#define GL_DEPTH_BUFFER_BIT
Definition: Gl.h:90
void(* gf_update_buffer_object)(int handle, uint size, void *data)
Definition: 2d.h:559
int GLint
Definition: Gl.h:48
void(* gf_modify_light)(light *, int, int)
Definition: 2d.h:581
#define GR_FOGMODE_NONE
Definition: 2d.h:355
WINGDIAPI void APIENTRY glReadBuffer(GLenum mode)
int current_bitmap
Definition: 2d.h:395
#define GL_RGBA
Definition: Gl.h:785
float GLfloat
Definition: Gl.h:53
color_gun Gr_blue
Definition: 2d.cpp:48
#define GL_SMOOTH
Definition: Gl.h:867
void gr_opengl_bitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode)
void(* gf_gradient)(int x1, int y1, int x2, int y2, int resize_mode)
Definition: 2d.h:436
int gr_opengl_set_cull(int cull)
Definition: gropengl.cpp:689
#define GL_FOG_HINT
Definition: Gl.h:468
void gr_opengl_render(int nverts, vertex *verts, uint flags)
#define GL_RENDERER
Definition: Gl.h:890
void gr_opengl_post_process_set_defaults()