FS2_Open
Open source remastering of the Freespace 2 engine
2d.h
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 
12 #ifndef _GRAPHICS_H
13 #define _GRAPHICS_H
14 
15 #include "bmpman/bmpman.h"
16 #include "cfile/cfile.h"
17 #include "globalincs/pstypes.h"
18 #include "graphics/tmapper.h"
19 
20 extern const float Default_min_draw_distance;
21 extern const float Default_max_draw_distance;
22 extern float Min_draw_distance;
23 extern float Max_draw_distance;
24 extern int Gr_inited;
25 
26 // z-buffering stuff
28 extern int gr_global_zbuffering;
29 
43 
45 };
46 
47 // Shader flags
48 #define SDR_FLAG_MODEL_LIGHT (1<<0)
49 #define SDR_FLAG_MODEL_FOG (1<<1)
50 #define SDR_FLAG_MODEL_DIFFUSE_MAP (1<<2)
51 #define SDR_FLAG_MODEL_GLOW_MAP (1<<3)
52 #define SDR_FLAG_MODEL_SPEC_MAP (1<<4)
53 #define SDR_FLAG_MODEL_NORMAL_MAP (1<<5)
54 #define SDR_FLAG_MODEL_HEIGHT_MAP (1<<6)
55 #define SDR_FLAG_MODEL_ENV_MAP (1<<7)
56 #define SDR_FLAG_MODEL_ANIMATED (1<<8)
57 #define SDR_FLAG_MODEL_MISC_MAP (1<<9)
58 #define SDR_FLAG_MODEL_TEAMCOLOR (1<<10)
59 #define SDR_FLAG_MODEL_TRANSFORM (1<<11)
60 #define SDR_FLAG_MODEL_DEFERRED (1<<12)
61 #define SDR_FLAG_MODEL_SHADOW_MAP (1<<13)
62 #define SDR_FLAG_MODEL_GEOMETRY (1<<14)
63 #define SDR_FLAG_MODEL_SHADOWS (1<<15)
64 #define SDR_FLAG_MODEL_THRUSTER (1<<16)
65 #define SDR_FLAG_MODEL_CLIP (1<<17)
66 
67 #define SDR_FLAG_PARTICLE_POINT_GEN (1<<0)
68 
69 #define SDR_FLAG_BLUR_HORIZONTAL (1<<0)
70 #define SDR_FLAG_BLUR_VERTICAL (1<<1)
71 
72 // stencil buffering stuff
73 extern int gr_stencil_mode;
74 
75 // alpha test
76 extern int gr_alpha_test;
77 
82 typedef struct shader {
83  uint screen_sig; // current mode this is in
84  ubyte r,g,b,c; // factors and constant
85  ubyte lookup[256];
86 } shader;
87 
88 #define AC_TYPE_NONE 0 // Not an alphacolor
89 #define AC_TYPE_HUD 1 // Doesn't change hue depending on background. Used for HUD stuff.
90 #define AC_TYPE_BLEND 2 // Changes hue depending on background. Used for stars, etc.
91 
92 // NEVER REFERENCE THESE VALUES OUTSIDE OF THE GRAPHICS LIBRARY!!!
93 // If you need to get the rgb values of a "color" struct call
94 // gr_get_colors after calling gr_set_colors_fast.
95 typedef struct color {
99  int magic;
104  ubyte ac_type; // The type of alphacolor. See AC_TYPE_??? defines
106 } color;
107 
108 // Used by the team coloring code
109 typedef struct team_color {
110  struct {
111  float r, g, b;
112  } base;
113  struct {
114  float r, g, b;
115  } stripe;
116 } team_color;
117 
118 
119 
120 typedef struct tsb_t {
122  float scaler;
123 } tsb_t;
124 
129 class poly_list {
130  // helper function struct that let's us sort the indices.
131  // an instance is fed into std::sort and std::lower_bound.
132  // overloaded operator() is used for the comparison function.
133  struct finder {
134  poly_list* search_list;
135  bool compare_indices;
136  vertex* vert_to_find;
137  vec3d* norm_to_find;
138 
139  finder(poly_list* _search_list): search_list(_search_list), compare_indices(true), vert_to_find(NULL), norm_to_find(NULL) {}
140  finder(poly_list* _search_list, vertex* _vert, vec3d* _norm): search_list(_search_list), compare_indices(false), vert_to_find(_vert), norm_to_find(_norm) {}
141 
142  bool operator()(const uint a, const uint b);
143  };
144 public:
145  poly_list(): n_verts(0), vert(NULL), norm(NULL), tsb(NULL), submodels(NULL), sorted_indices(NULL), currently_allocated(0) {}
146  ~poly_list();
148 
149  void allocate(int size);
150  void make_index_buffer(SCP_vector<int> &vertex_list);
151  void calculate_tangent();
152  int n_verts;
156  int *submodels;
157 
159 
160  int find_index(poly_list *plist, int idx);
161  int find_index_fast(poly_list *plist, int idx);
162 private:
163  int currently_allocated;
164  int find_first_vertex(int idx);
165  int find_first_vertex_fast(int idx);
166  void generate_sorted_index_list();
167 };
168 
170 {
171 public:
173  : pad(1.0f)
174  {}
175 
177  float pad; //needed so I can just memcpy it in d3d
179 };
180 
181 
182 struct line_list {
183  int n_line;
185 };
186 
188 {
189 public:
190  int flags;
191 
192  int texture; // this is the texture the vertex buffer will use
193  int n_verts;
194 
195  size_t index_offset;
196 
197  const uint *get_index() const
198  {
199  return index;
200  }
201 
203 
204  void release()
205  {
206  if (index) {
207  delete [] index;
208  index = NULL;
209  }
210  }
211 
212  void assign(int i, uint j)
213  {
214  const_cast<uint *>(index)[i] = j;
215  if (i_first > i_last)
216  i_first = i_last = j;
217  else if (i_first > j)
218  i_first = j;
219  else if (i_last < j)
220  i_last = j;
221  }
222 
223  // Constructor
224 
226  flags(0), texture(-1), n_verts(0), index_offset(0),
227  i_first(1), i_last(0), index(NULL)
228  {
229  }
230 
231  buffer_data(int n_vrts) :
232  flags(0), texture(-1), n_verts(n_vrts), index_offset(0),
233  i_first(1), i_last(0), index(NULL)
234  {
235  if ( n_verts > 0 ) {
236  index = new(std::nothrow) uint[n_verts];
237  } else {
238  index = NULL;
239  }
240  }
241 
242  // Copy-constructor
243  buffer_data(const buffer_data& other)
244  {
245  if ( other.index ) {
246  index = new(std::nothrow) uint[other.n_verts];
247  for (size_t i=0; i < (size_t) other.n_verts; i++)
248  {
249  index[i] = other.index[i];
250  }
251  } else {
252  index = NULL;
253  }
254 
255  flags = other.flags;
256  texture = other.texture;
257  n_verts = other.n_verts;
258 
259  i_first = other.i_first;
260  i_last = other.i_last;
261 
262  index_offset = other.index_offset;
263  }
264 
265  // Copy-assignment operator
267  {
268  if (this != &rhs)
269  {
270  if ( index ) {
271  delete [] index;
272  }
273 
274  if ( rhs.index && rhs.n_verts > 0 ) {
275  index = new(std::nothrow) uint[rhs.n_verts];
276  for (size_t i=0; i < (size_t) rhs.n_verts; i++)
277  {
278  index[i] = rhs.index[i];
279  }
280  }
281 
282  flags = rhs.flags;
283  texture = rhs.texture;
284  n_verts = rhs.n_verts;
285 
286  i_first = rhs.i_first;
287  i_last = rhs.i_last;
288 
289  index_offset = rhs.index_offset;
290  }
291  return *this;
292  }
293 
294  // Destructor
296  {
297  release();
298  }
299 
300 private:
301  uint *index;
302 };
303 
305 {
306 public:
307  int flags;
308 
311 
313 
315 
317  flags(0), stride(0), vertex_offset(0), model_list(NULL)
318  {
319  }
320 
322  {
323  clear();
324  }
325 
326  void release()
327  {
328  if (model_list) {
329  delete model_list;
330  model_list = NULL;
331  }
332 
333  for (SCP_vector<buffer_data>::iterator tbi = tex_buf.begin(); tbi != tex_buf.end(); ++tbi) {
334  tbi->release();
335  }
336  }
337 
338  void clear()
339  {
340  release();
341  tex_buf.clear();
342  }
343 };
344 
345 struct light;
346 
347 
348 #define GR_ALPHABLEND_NONE 0 // no blending
349 #define GR_ALPHABLEND_FILTER 1 // 50/50 mix of foreground, background, using intensity as alpha
350 
351 #define GR_BITBLT_MODE_NORMAL 0 // Normal bitblting
352 #define GR_BITBLT_MODE_RLE 1 // RLE would be faster
353 
354 // fog modes
355 #define GR_FOGMODE_NONE 0 // set this to turn off fog
356 #define GR_FOGMODE_FOG 1 // linear fog
357 
358 typedef struct screen {
359  uint signature; // changes when mode or palette or width or height changes
360  int max_w, max_h; // Width and height
363  int center_w, center_h; // Width and height of center monitor
365  int save_max_w, save_max_h; // Width and height
368  int save_center_w, save_center_h; // Width and height of center monitor
370  int res; // GR_640 or GR_1024
371  int mode; // What mode gr_init was called with.
372  float aspect, clip_aspect; // Aspect ratio, aspect of clip_width/clip_height
373  int rowsize; // What you need to add to go to next row (includes bytes_per_pixel)
374  int bits_per_pixel; // How many bits per pixel it is. (7,8,15,16,24,32)
375  int bytes_per_pixel; // How many bytes per pixel (1,2,3,4)
376  int offset_x, offset_y; // The offsets into the screen
377  int offset_x_unscaled, offset_y_unscaled; // Offsets into the screen, in unscaled dimensions
379  int clip_width_unscaled, clip_height_unscaled; // Height and width of clip aread, in unscaled dimensions
380  // center of clip area
382 
384 
385  // the clip_l,r,t,b are used internally. left and top are
386  // actually always 0, but it's nice to have the code work with
387  // arbitrary clipping regions.
389  // same as above except in unscaled dimensions
391 
392  int current_alphablend_mode; // See GR_ALPHABLEND defines above
393  int current_bitblt_mode; // See GR_BITBLT_MODE defines above
394  int current_fog_mode; // See GR_FOGMODE_* defines above
397  color current_fog_color; // current fog color
398  color current_clear_color; // current clear color
401 
403  int rendering_to_texture; //wich texture we are rendering to, -1 if the back buffer
404  int rendering_to_face; //wich face of the texture we are rendering to, -1 if the back buffer
405 
407 
408  //switch onscreen, offscreen
409  void (*gf_flip)();
410 
411  // Sets the current palette
412  void (*gf_set_palette)(const ubyte *new_pal, int restrict_alphacolor);
413 
414  // Flash the screen
415  void (*gf_flash)( int r, int g, int b );
416  void (*gf_flash_alpha)(int r, int g, int b, int a);
417 
418  // sets the clipping region
419  void (*gf_set_clip)(int x, int y, int w, int h, int resize_mode);
420 
421  // resets the clipping region to entire screen
423 
424  // clears entire clipping region to current color
426 
427  // void (*gf_bitmap)(int x, int y, int resize_mode);
428  void (*gf_bitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode);
429 
430  void (*gf_aabitmap)(int x, int y, int resize_mode, bool mirror);
431  void (*gf_aabitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode, bool mirror);
432 
433  void (*gf_string)(int x, int y, const char * text,int resize_mode);
434 
435  // Draw a gradient line... x1,y1 is bright, x2,y2 is transparent.
436  void (*gf_gradient)(int x1, int y1, int x2, int y2, int resize_mode);
437 
438  void (*gf_circle)(int x, int y, int r, int resize_mode);
439  void (*gf_unfilled_circle)(int x, int y, int r, int resize_mode);
440  void (*gf_arc)(int x, int y, float r, float angle_start, float angle_end, bool fill, int resize_mode);
441  void (*gf_curve)(int x, int y, int r, int direction, int resize_mode);
442 
443  // Integer line. Used to draw a fast but pixely line.
444  void (*gf_line)(int x1, int y1, int x2, int y2, int resize_mode);
445 
446  // Draws an antialiased line is the current color is an
447  // alphacolor, otherwise just draws a fast line. This
448  // gets called internally by g3_draw_line. This assumes
449  // the vertex's are already clipped, so call g3_draw_line
450  // not this if you have two 3d points.
452 
453  void (*gf_pixel)( int x, int y, int resize_mode );
454 
455  // Scales current bitmap between va and vb with clipping
456  void (*gf_scaler)(vertex *va, vertex *vb, bool bw_bitmap );
457 
458  // Scales current bitmap between va and vb with clipping, draws an aabitmap
459  void (*gf_aascaler)(vertex *va, vertex *vb );
460 
461  // Texture maps the current bitmap. See TMAP_FLAG_?? defines for flag values
462  void (*gf_tmapper)(int nv, vertex *verts[], uint flags );
463 
464  // Texture maps the current bitmap. See TMAP_FLAG_?? defines for flag values
465  void (*gf_render)(int nv, vertex *verts, uint flags);
466 
467  void (*gf_render_effect)(int nv, vertex *verts, float *radius_list, uint flags);
468 
469  // dumps the current screen to a file
470  void (*gf_print_screen)(const char * filename);
471 
472  // Call once before rendering anything.
474 
475  // Call after rendering is over.
477 
478  // Retrieves the zbuffer mode.
480 
481  // Sets mode. Returns previous mode.
483 
484  // Clears the zbuffer. If use_zbuffer is FALSE, then zbuffering mode is ignored and zbuffer is always off.
485  void (*gf_zbuffer_clear)(int use_zbuffer);
486 
487  // Set the stencil buffer mode. Returns previous mode
489 
490  // Clears the stencil buffer.
492 
493  int (*gf_alpha_mask_set)(int mode, float alpha);
494 
495  // Saves screen. Returns an id you pass to restore and free.
497 
498  // Resets clip region and copies entire saved screen to the screen.
500 
501  // Frees up a saved screen.
503 
504  // Sets the gamma
505  void (*gf_set_gamma)(float gamma);
506 
507  // Lock/unlock the screen
508  // Returns non-zero if sucessful (memory pointer)
509  uint (*gf_lock)();
511 
512  // grab a region of the screen. assumes data is large enough
513  void (*gf_get_region)(int front, int w, int h, ubyte *data);
514 
515  // set fog attributes
516  void (*gf_fog_set)(int fog_mode, int r, int g, int b, float fog_near, float fog_far);
517 
518  // poly culling
519  int (*gf_set_cull)(int cull);
520 
521  // color buffer writes
523 
524  // cross fade
525  void (*gf_cross_fade)(int bmap1, int bmap2, int x1, int y1, int x2, int y2, float pct, int resize_mode);
526 
527  // set a texture into cache. for sectioned bitmaps, pass in sx and sy to set that particular section of the bitmap
528  int (*gf_tcache_set)(int bitmap_id, int bitmap_type, float *u_scale, float *v_scale, int stage);
529 
530  // preload a bitmap into texture memory
531  int (*gf_preload)(int bitmap_num, int is_aabitmap);
532 
533  // set the color to be used when clearing the background
534  void (*gf_set_clear_color)(int r, int g, int b);
535 
536  // Here be the bitmap functions
537  void (*gf_bm_free_data)(int n, bool release);
538  void (*gf_bm_create)(int n);
539  void (*gf_bm_init)(int n);
541  bool (*gf_bm_data)(int n, bitmap* bm);
542 
543  int (*gf_bm_make_render_target)(int n, int *width, int *height, ubyte *bpp, int *mm_lvl, int flags );
545 
546  void (*gf_translate_texture_matrix)(int unit, const vec3d *shift);
549 
551 
553  bool (*gf_pack_buffer)(const int buffer_id, vertex_buffer *vb);
554  bool (*gf_config_buffer)(const int buffer_id, vertex_buffer *vb, bool update_ibuffer_only);
558 
559  void (*gf_update_buffer_object)(int handle, uint size, void* data);
562 
564  void (*gf_render_stream_buffer)(int buffer_handle, int offset, int n_verts, int flags);
565 
566  //the projection matrix; fov, aspect ratio, near, far
569  //the view matrix
570  void (*gf_set_view_matrix)(const vec3d*, const matrix*);
572  //object scaleing
575  //object position and orientation
579 
586 
587  // postprocessing effects
590 
594 
598 
602 
603  void (*gf_lighting)(bool,bool);
607 
610 
611  void (*gf_zbias)(int zbias);
612 
614  void (*gf_set_texture_panning)(float u, float v, bool enable);
615 
616  void (*gf_draw_line_list)(const colored_vector *lines, int num);
617 
619 
620  void (*gf_line_htl)(const vec3d *start, const vec3d *end);
621  void (*gf_sphere_htl)(float rad);
622 
624 
625  void (*gf_set_animated_effect)(int effect, float timer);
626 
628 
629  void (*gf_set_team_color)(const team_color *colors);
630 
631  void (*gf_update_texture)(int bitmap_handle, int bpp, const ubyte* data, int width, int height);
632  void (*gf_get_bitmap_from_texture)(void* data_out, int bitmap_num);
633 
634  void (*gf_shadow_map_start)(const matrix4 *shadow_view_matrix, const matrix *light_matrix);
636 } screen;
637 
638 // handy macro
639 #define GR_MAYBE_CLEAR_RES(bmap) do { int bmw = -1; int bmh = -1; if(bmap != -1){ bm_get_info( bmap, &bmw, &bmh, NULL, NULL, NULL); if((bmw != gr_screen.max_w) || (bmh != gr_screen.max_h)){gr_clear();} } else {gr_clear();} } while(0);
640 
641 //Window's interface to set up graphics:
642 //--------------------------------------
643 // Call this at application startup
644 
645 // # Software Re-added by Kazan --- THIS HAS TO STAY -- It is used by standalone!
646 #define GR_DEFAULT (-1) // set to use default settings
647 #define GR_STUB (100)
648 #define GR_OPENGL (104) // Use OpenGl hardware renderer
649 
650 // resolution constants - always keep resolutions in ascending order and starting from 0
651 #define GR_NUM_RESOLUTIONS 2
652 #define GR_640 0 // 640 x 480
653 #define GR_1024 1 // 1024 x 768
654 
655 #define GR_1024_THRESHOLD_WIDTH 1024
656 #define GR_1024_THRESHOLD_HEIGHT 600
657 
658 extern const char *Resolution_prefixes[GR_NUM_RESOLUTIONS];
659 
660 extern bool gr_init(int d_mode = GR_DEFAULT, int d_width = GR_DEFAULT, int d_height = GR_DEFAULT, int d_depth = GR_DEFAULT);
661 extern void gr_screen_resize(int width, int height);
662 extern int gr_get_resolution_class(int width, int height);
663 
664 // Call this when your app ends.
665 extern void gr_close();
666 
667 extern screen gr_screen;
668 
669 #define GR_FILL_MODE_WIRE 1
670 #define GR_FILL_MODE_SOLID 2
671 
672 #define GR_ZBUFF_NONE 0
673 #define GR_ZBUFF_WRITE (1<<0)
674 #define GR_ZBUFF_READ (1<<1)
675 #define GR_ZBUFF_FULL (GR_ZBUFF_WRITE|GR_ZBUFF_READ)
676 
677 #define GR_STENCIL_NONE 0
678 #define GR_STENCIL_READ 1
679 #define GR_STENCIL_WRITE 2
680 
681 #define GR_RESIZE_NONE 0
682 #define GR_RESIZE_FULL 1
683 #define GR_RESIZE_FULL_CENTER 2
684 #define GR_RESIZE_MENU 3
685 #define GR_RESIZE_MENU_ZOOMED 4
686 #define GR_RESIZE_MENU_NO_OFFSET 5
687 
688 void gr_set_screen_scale(int x, int y, int zoom_x = -1, int zoom_y = -1, int max_x = gr_screen.max_w, int max_y = gr_screen.max_h, int center_x = gr_screen.center_w, int center_y = gr_screen.center_h, bool force_stretch = false);
689 void gr_reset_screen_scale();
690 bool gr_unsize_screen_pos(int *x, int *y, int *w = NULL, int *h = NULL, int resize_mode = GR_RESIZE_FULL);
691 bool gr_resize_screen_pos(int *x, int *y, int *w = NULL, int *h = NULL, int resize_mode = GR_RESIZE_FULL);
692 bool gr_unsize_screen_posf(float *x, float *y, float *w = NULL, float *h = NULL, int resize_mode = GR_RESIZE_FULL);
693 bool gr_resize_screen_posf(float *x, float *y, float *w = NULL, float *h = NULL, int resize_mode = GR_RESIZE_FULL);
694 
695 // Does formatted printing. This calls gr_string after formatting,
696 // so if you don't need to format the string, then call gr_string
697 // directly.
698 extern void _cdecl gr_printf( int x, int y, const char * format, ... );
699 // same as gr_printf but positions text correctly in menus
700 extern void _cdecl gr_printf_menu( int x, int y, const char * format, ... );
701 // same as gr_printf_menu but accounts for menu zooming
702 extern void _cdecl gr_printf_menu_zoomed( int x, int y, const char * format, ... );
703 // same as gr_printf but doesn't resize for non-standard resolutions
704 extern void _cdecl gr_printf_no_resize( int x, int y, const char * format, ... );
705 
706 // Returns the size of the string in pixels in w and h
707 extern void gr_get_string_size( int *w, int *h, const char * text, int len = 9999 );
708 
709 // Returns the height of the current font
710 extern int gr_get_font_height();
711 
712 extern void gr_set_palette(const char *name, ubyte *palette, int restrict_to_128 = 0);
713 
714 // These two functions use a Windows mono font. Only for use
715 // in the editor, please.
716 void gr_get_string_size_win(int *w, int *h, const char *text);
717 void gr_string_win(int x, int y, const char *s );
718 
719 // set the mouse pointer to a specific bitmap, used for animating cursors
720 #define GR_CURSOR_LOCK 1
721 #define GR_CURSOR_UNLOCK 2
722 void gr_set_cursor_bitmap(int n, int lock = 0);
723 void gr_unset_cursor_bitmap(int n);
725 extern int Web_cursor_bitmap;
726 
727 // Called by OS when application gets/looses focus
728 extern void gr_activate(int active);
729 
730 #define GR_CALL(x) (*x)
731 
732 // These macros make the function indirection look like the
733 // old Descent-style gr_xxx calls.
734 
735 #define gr_print_screen GR_CALL(gr_screen.gf_print_screen)
736 
737 //#define gr_flip GR_CALL(gr_screen.gf_flip)
738 void gr_flip();
739 
740 //#define gr_set_clip GR_CALL(gr_screen.gf_set_clip)
741 __inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
742 {
743  (*gr_screen.gf_set_clip)(x,y,w,h,resize_mode);
744 }
745 #define gr_reset_clip GR_CALL(gr_screen.gf_reset_clip)
746 
747 void gr_set_bitmap(int bitmap_num, int alphablend = GR_ALPHABLEND_NONE, int bitbltmode = GR_BITBLT_MODE_NORMAL, float alpha = 1.0f);
748 
749 #define gr_clear GR_CALL(gr_screen.gf_clear)
750 __inline void gr_aabitmap(int x, int y, int resize_mode = GR_RESIZE_FULL, bool mirror = false)
751 {
752  (*gr_screen.gf_aabitmap)(x,y,resize_mode,mirror);
753 }
754 
755 __inline void gr_aabitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode = GR_RESIZE_FULL, bool mirror = false)
756 {
757  (*gr_screen.gf_aabitmap_ex)(x,y,w,h,sx,sy,resize_mode,mirror);
758 }
759 
760 __inline void gr_bitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode = GR_RESIZE_FULL)
761 {
762  (*gr_screen.gf_bitmap_ex)(x, y, w, h, sx, sy, resize_mode);
763 }
764 
765 void gr_shield_icon(coord2d coords[6], const int resize_mode = GR_RESIZE_FULL);
766 void gr_rect(int x, int y, int w, int h, int resize_mode = GR_RESIZE_FULL);
767 void gr_shade(int x, int y, int w, int h, int resize_mode = GR_RESIZE_FULL);
768 
769 __inline void gr_string(int x, int y, const char* string, int resize_mode = GR_RESIZE_FULL)
770 {
771  (*gr_screen.gf_string)(x,y,string,resize_mode);
772 }
773 
774 __inline void gr_circle(int xc, int yc, int d, int resize_mode = GR_RESIZE_FULL)
775 {
776  (*gr_screen.gf_circle)(xc,yc,d,resize_mode);
777 }
778 
779 __inline void gr_unfilled_circle(int xc, int yc, int d, int resize_mode = GR_RESIZE_FULL)
780 {
781  (*gr_screen.gf_unfilled_circle)(xc,yc,d,resize_mode);
782 }
783 
784 __inline void gr_arc(int xc, int yc, float r, float angle_start, float angle_end, bool fill, int resize_mode = GR_RESIZE_FULL)
785 {
786  (*gr_screen.gf_arc)(xc,yc,r,angle_start,angle_end,fill,resize_mode);
787 }
788 
789 #define gr_curve GR_CALL(gr_screen.gf_curve)
790 
791 __inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode = GR_RESIZE_FULL)
792 {
793  (*gr_screen.gf_line)(x1, y1, x2, y2, resize_mode);
794 }
795 
796 #define gr_aaline GR_CALL(gr_screen.gf_aaline)
797 
798 __inline void gr_pixel(int x, int y, int resize_mode = GR_RESIZE_FULL)
799 {
800  (*gr_screen.gf_pixel)(x, y, resize_mode);
801 }
802 #define gr_scaler GR_CALL(gr_screen.gf_scaler)
803 #define gr_aascaler GR_CALL(gr_screen.gf_aascaler)
804 #define gr_tmapper GR_CALL(gr_screen.gf_tmapper)
805 #define gr_render GR_CALL(gr_screen.gf_render)
806 #define gr_render_effect GR_CALL(gr_screen.gf_render_effect)
807 
808 __inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode = GR_RESIZE_FULL)
809 {
810  (*gr_screen.gf_gradient)(x1, y1, x2, y2, resize_mode);
811 }
812 
813 #define gr_flash GR_CALL(gr_screen.gf_flash)
814 #define gr_flash_alpha GR_CALL(gr_screen.gf_flash_alpha)
815 
816 #define gr_zbuffer_get GR_CALL(gr_screen.gf_zbuffer_get)
817 #define gr_zbuffer_set GR_CALL(gr_screen.gf_zbuffer_set)
818 #define gr_zbuffer_clear GR_CALL(gr_screen.gf_zbuffer_clear)
819 
820 #define gr_stencil_set GR_CALL(gr_screen.gf_stencil_set)
821 #define gr_stencil_clear GR_CALL(gr_screen.gf_stencil_clear)
822 
823 #define gr_alpha_mask_set GR_CALL(gr_screen.gf_alpha_mask_set)
824 
825 #define gr_save_screen GR_CALL(gr_screen.gf_save_screen)
826 #define gr_restore_screen GR_CALL(gr_screen.gf_restore_screen)
827 #define gr_free_screen GR_CALL(gr_screen.gf_free_screen)
828 
829 #define gr_set_gamma GR_CALL(gr_screen.gf_set_gamma)
830 
831 #define gr_get_region GR_CALL(gr_screen.gf_get_region)
832 
833 __inline void gr_fog_set(int fog_mode, int r, int g, int b, float fog_near = -1.0f, float fog_far = -1.0f)
834 {
835  (*gr_screen.gf_fog_set)(fog_mode, r, g, b, fog_near, fog_far);
836 }
837 
838 #define gr_set_cull GR_CALL(gr_screen.gf_set_cull)
839 #define gr_set_color_buffer GR_CALL(gr_screen.gf_set_color_buffer)
840 
841 #define gr_cross_fade GR_CALL(gr_screen.gf_cross_fade)
842 
843 __inline int gr_tcache_set(int bitmap_id, int bitmap_type, float *u_scale, float *v_scale, int stage = 0)
844 {
845  return (*gr_screen.gf_tcache_set)(bitmap_id, bitmap_type, u_scale, v_scale, stage);
846 }
847 
848 #define gr_preload GR_CALL(gr_screen.gf_preload)
849 
850 #define gr_set_clear_color GR_CALL(gr_screen.gf_set_clear_color)
851 
852 #define gr_translate_texture_matrix GR_CALL(gr_screen.gf_translate_texture_matrix)
853 #define gr_push_texture_matrix GR_CALL(gr_screen.gf_push_texture_matrix)
854 #define gr_pop_texture_matrix GR_CALL(gr_screen.gf_pop_texture_matrix)
855 
856 
857 // Here be the bitmap functions
858 #define gr_bm_free_data GR_CALL(*gr_screen.gf_bm_free_data)
859 #define gr_bm_create GR_CALL(*gr_screen.gf_bm_create)
860 #define gr_bm_init GR_CALL(*gr_screen.gf_bm_init)
861 #define gr_bm_page_in_start GR_CALL(*gr_screen.gf_bm_page_in_start)
862 #define gr_bm_data GR_CALL(*gr_screen.gf_bm_data)
863 
864 #define gr_bm_make_render_target GR_CALL(*gr_screen.gf_bm_make_render_target)
865 
866 __inline int gr_bm_set_render_target(int n, int face = -1)
867 {
868  return (*gr_screen.gf_bm_set_render_target)(n, face);
869 }
870 
871 #define gr_set_texture_addressing GR_CALL(*gr_screen.gf_set_texture_addressing)
872 
873 #define gr_create_buffer GR_CALL(*gr_screen.gf_create_buffer)
874 #define gr_pack_buffer GR_CALL(*gr_screen.gf_pack_buffer)
875 #define gr_config_buffer GR_CALL(*gr_screen.gf_config_buffer)
876 #define gr_destroy_buffer GR_CALL(*gr_screen.gf_destroy_buffer)
877 __inline void gr_render_buffer(int start, const vertex_buffer *bufferp, int texi, int flags = TMAP_FLAG_TEXTURED)
878 {
879  (*gr_screen.gf_render_buffer)(start, bufferp, texi, flags);
880 }
881 
882 #define gr_update_buffer_object GR_CALL(*gr_screen.gf_update_buffer_object)
883 #define gr_update_transform_buffer GR_CALL(*gr_screen.gf_update_transform_buffer)
884 #define gr_set_transform_buffer_offset GR_CALL(*gr_screen.gf_set_transform_buffer_offset)
885 
886 #define gr_create_stream_buffer GR_CALL(*gr_screen.gf_create_stream_buffer)
887 #define gr_render_stream_buffer GR_CALL(*gr_screen.gf_render_stream_buffer)
888 #define gr_render_stream_buffer_start GR_CALL(*gr_screen.gf_render_stream_buffer_start)
889 #define gr_render_stream_buffer_end GR_CALL(*gr_screen.gf_render_stream_buffer_end)
890 
891 #define gr_set_buffer GR_CALL(*gr_screen.gf_set_buffer)
892 
893 #define gr_set_proj_matrix GR_CALL(*gr_screen.gf_set_proj_matrix)
894 #define gr_end_proj_matrix GR_CALL(*gr_screen.gf_end_proj_matrix)
895 #define gr_set_view_matrix GR_CALL(*gr_screen.gf_set_view_matrix)
896 #define gr_end_view_matrix GR_CALL(*gr_screen.gf_end_view_matrix)
897 #define gr_push_scale_matrix GR_CALL(*gr_screen.gf_push_scale_matrix)
898 #define gr_pop_scale_matrix GR_CALL(*gr_screen.gf_pop_scale_matrix)
899 #define gr_start_instance_matrix GR_CALL(*gr_screen.gf_start_instance_matrix)
900 #define gr_start_angles_instance_matrix GR_CALL(*gr_screen.gf_start_angles_instance_matrix)
901 #define gr_end_instance_matrix GR_CALL(*gr_screen.gf_end_instance_matrix)
902 
903 #define gr_make_light GR_CALL(*gr_screen.gf_make_light)
904 #define gr_modify_light GR_CALL(*gr_screen.gf_modify_light)
905 #define gr_destroy_light GR_CALL(*gr_screen.gf_destroy_light)
906 #define gr_set_light GR_CALL(*gr_screen.gf_set_light)
907 #define gr_reset_lighting GR_CALL(*gr_screen.gf_reset_lighting)
908 #define gr_set_ambient_light GR_CALL(*gr_screen.gf_set_ambient_light)
909 
910 #define gr_scene_texture_begin GR_CALL(*gr_screen.gf_scene_texture_begin)
911 #define gr_scene_texture_end GR_CALL(*gr_screen.gf_scene_texture_end)
912 #define gr_copy_effect_texture GR_CALL(*gr_screen.gf_copy_effect_texture)
913 
914 #define gr_post_process_set_effect GR_CALL(*gr_screen.gf_post_process_set_effect)
915 #define gr_post_process_set_defaults GR_CALL(*gr_screen.gf_post_process_set_defaults)
916 #define gr_post_process_begin GR_CALL(*gr_screen.gf_post_process_begin)
917 #define gr_post_process_end GR_CALL(*gr_screen.gf_post_process_end)
918 #define gr_post_process_save_zbuffer GR_CALL(*gr_screen.gf_post_process_save_zbuffer)
919 
920 #define gr_deferred_lighting_begin GR_CALL(*gr_screen.gf_deferred_lighting_begin)
921 #define gr_deferred_lighting_end GR_CALL(*gr_screen.gf_deferred_lighting_end)
922 #define gr_deferred_lighting_finish GR_CALL(*gr_screen.gf_deferred_lighting_finish)
923 
924 #define gr_set_lighting GR_CALL(*gr_screen.gf_lighting)
925 #define gr_set_light_factor GR_CALL(*gr_screen.gf_set_light_factor)
926 #define gr_center_alpha GR_CALL(*gr_screen.gf_center_alpha)
927 #define gr_set_thrust_scale GR_CALL(*gr_screen.gf_set_thrust_scale)
928 
929 #define gr_start_clip GR_CALL(*gr_screen.gf_start_clip_plane)
930 #define gr_end_clip GR_CALL(*gr_screen.gf_end_clip_plane)
931 
932 #define gr_zbias GR_CALL(*gr_screen.gf_zbias)
933 #define gr_set_fill_mode GR_CALL(*gr_screen.gf_set_fill_mode)
934 #define gr_set_texture_panning GR_CALL(*gr_screen.gf_set_texture_panning)
935 
936 #define gr_draw_line_list GR_CALL(*gr_screen.gf_draw_line_list)
937 
938 #define gr_set_line_width GR_CALL(*gr_screen.gf_set_line_width)
939 
940 #define gr_line_htl GR_CALL(*gr_screen.gf_line_htl)
941 #define gr_sphere_htl GR_CALL(*gr_screen.gf_sphere_htl)
942 
943 #define gr_maybe_create_shader GR_CALL(*gr_screen.gf_maybe_create_shader)
944 #define gr_set_animated_effect GR_CALL(*gr_screen.gf_set_animated_effect)
945 
946 #define gr_clear_states GR_CALL(*gr_screen.gf_clear_states)
947 
948 #define gr_set_team_color GR_CALL(*gr_screen.gf_set_team_color)
949 
950 #define gr_update_texture GR_CALL(*gr_screen.gf_update_texture)
951 #define gr_get_bitmap_from_texture GR_CALL(*gr_screen.gf_get_bitmap_from_texture)
952 
953 #define gr_shadow_map_start GR_CALL(*gr_screen.gf_shadow_map_start)
954 #define gr_shadow_map_end GR_CALL(*gr_screen.gf_shadow_map_end)
955 
956 // color functions
957 void gr_get_color( int *r, int *g, int b );
958 void gr_init_color(color *c, int r, int g, int b);
959 void gr_init_alphacolor( color *clr, int r, int g, int b, int alpha, int type = AC_TYPE_HUD );
960 void gr_set_color( int r, int g, int b );
962 
963 // shader functions
964 void gr_create_shader(shader *shade, ubyte r, ubyte g, ubyte b, ubyte c);
965 void gr_set_shader(shader *shade);
966 
968  bool lighting,
969  bool fog,
970  bool textured,
971  bool in_shadow_map,
972  bool thruster_scale,
973  bool transform,
974  bool team_color_set,
975  int tmap_flags,
976  int spec_map,
977  int glow_map,
978  int normal_map,
979  int height_map,
980  int env_map,
981  int misc_map
982 );
983 
984 // new bitmap functions
985 void gr_bitmap(int x, int y, int resize_mode = GR_RESIZE_FULL);
986 void gr_bitmap_uv(int _x, int _y, int _w, int _h, float _u0, float _v0, float _u1, float _v1, int resize_mode = GR_RESIZE_FULL);
987 void gr_bitmap_list(bitmap_2d_list* list, int n_bm, int resize_mode);
988 void gr_bitmap_list(bitmap_rect_list* list, int n_bm, int resize_mode);
989 
990 // texture update functions
991 ubyte* gr_opengl_get_texture_update_pointer(int bitmap_handle);
992 void gr_opengl_update_texture(int bitmap_handle, int bpp, const ubyte* data, int width, int height);
993 
994 // special function for drawing polylines. this function is specifically intended for
995 // polylines where each section is no more than 90 degrees away from a previous section.
996 // Moreover, it is _really_ intended for use with 45 degree angles.
997 void gr_pline_special(SCP_vector<vec3d> *pts, int thickness,int resize_mode=GR_RESIZE_FULL);
998 
999 #define VB_FLAG_POSITION (1<<0)
1000 #define VB_FLAG_RHW (1<<1) //incompatable with the next normal
1001 #define VB_FLAG_NORMAL (1<<2)
1002 #define VB_FLAG_DIFUSE (1<<3)
1003 #define VB_FLAG_SPECULAR (1<<4)
1004 #define VB_FLAG_UV1 (1<<5) //how many UV coords, only use one of these
1005 #define VB_FLAG_UV2 (1<<6)
1006 #define VB_FLAG_UV3 (1<<7)
1007 #define VB_FLAG_UV4 (1<<8)
1008 #define VB_FLAG_TANGENT (1<<9)
1009 #define VB_FLAG_LARGE_INDEX (1<<10)
1010 #define VB_FLAG_MODEL_ID (1<<11)
1011 #define VB_FLAG_TRANS (1<<12)
1012 
1014 {
1030  };
1031 
1034  void *data_src;
1035 
1036  vertex_format_data(vertex_format i_format_type, uint i_stride, void *i_data_src) :
1037  format_type(i_format_type), stride(i_stride), data_src(i_data_src) {}
1038 };
1039 
1041 {
1042  SCP_vector<vertex_format_data> Vertex_components;
1043 
1044  uint Vertex_mask;
1045 public:
1046  vertex_layout(): Vertex_mask(0) {}
1047 
1048  uint get_num_vertex_components() { return Vertex_components.size(); }
1049 
1050  vertex_format_data* get_vertex_component(uint index) { return &Vertex_components[index]; }
1051 
1052  bool resident_vertex_format(vertex_format_data::vertex_format format_type) { return Vertex_mask & (1 << format_type) ? true : false; }
1053 
1055  {
1056  if ( resident_vertex_format(format_type) ) {
1057  // we already have a vertex component of this format type
1058  return;
1059  }
1060 
1061  Vertex_mask |= (1 << format_type);
1062  Vertex_components.push_back(vertex_format_data(format_type, stride, src));
1063  }
1064 };
1065 
1066 
1067 
1068 #endif
GLenum GLsizei GLenum format
Definition: Gl.h:1509
#define AC_TYPE_HUD
Definition: 2d.h:89
struct team_color::@238 stripe
int * submodels
Definition: 2d.h:156
int save_center_offset_x
Definition: 2d.h:369
void(* gf_aaline)(vertex *v1, vertex *v2)
Definition: 2d.h:451
Definition: 2d.h:182
int n_line
Definition: 2d.h:183
int i
Definition: multi_pxo.cpp:466
float current_alpha
Definition: 2d.h:400
void(* gf_set_proj_matrix)(float, float, float, float)
Definition: 2d.h:567
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
shader current_shader
Definition: 2d.h:399
bool resident_vertex_format(vertex_format_data::vertex_format format_type)
Definition: 2d.h:1052
void(* gf_destroy_light)(int)
Definition: 2d.h:582
int gr_stencil_mode
Definition: 2d.cpp:76
void(* gf_unlock)()
Definition: 2d.h:510
float pad
Definition: 2d.h:177
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
__inline int gr_tcache_set(int bitmap_id, int bitmap_type, float *u_scale, float *v_scale, int stage=0)
Definition: 2d.h:843
float Max_draw_distance
Definition: 2d.cpp:85
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
void(* gf_set_palette)(const ubyte *new_pal, int restrict_alphacolor)
Definition: 2d.h:412
int offset_y_unscaled
Definition: 2d.h:377
void(* gf_stop_frame)()
Definition: 2d.h:476
int current_fog_mode
Definition: 2d.h:394
vertex_buffer()
Definition: 2d.h:316
void(* gf_bm_free_data)(int n, bool release)
Definition: 2d.h:537
void(* gf_push_texture_matrix)(int unit)
Definition: 2d.h:547
void gr_string_win(int x, int y, const char *s)
int gr_get_resolution_class(int width, int height)
Definition: 2d.cpp:773
vec3d tangent
Definition: 2d.h:121
void(* gf_free_screen)(int id)
Definition: 2d.h:502
void gr_set_bitmap(int bitmap_num, int alphablend=GR_ALPHABLEND_NONE, int bitbltmode=GR_BITBLT_MODE_NORMAL, float alpha=1.0f)
Definition: 2d.cpp:2105
void(* gf_shadow_map_start)(const matrix4 *shadow_view_matrix, const matrix *light_matrix)
Definition: 2d.h:634
void gr_create_shader(shader *shade, ubyte r, ubyte g, ubyte b, ubyte c)
Definition: 2d.cpp:1211
vec3d * norm
Definition: 2d.h:154
int mode
Definition: 2d.h:371
GLuint index
Definition: Glext.h:5608
screen gr_screen
Definition: 2d.cpp:46
bool gr_resize_screen_posf(float *x, float *y, float *w=NULL, float *h=NULL, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:430
void gr_set_shader(shader *shade)
Definition: 2d.cpp:1220
int save_max_h_unscaled
Definition: 2d.h:366
void(* gf_sphere_htl)(float rad)
Definition: 2d.h:621
__inline void gr_circle(int xc, int yc, int d, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:774
buffer_data(const buffer_data &other)
Definition: 2d.h:243
uint gr_determine_model_shader_flags(bool lighting, bool fog, bool textured, bool in_shadow_map, bool thruster_scale, bool transform, bool team_color_set, int tmap_flags, int spec_map, int glow_map, int normal_map, int height_map, int env_map, int misc_map)
Definition: 2d.cpp:2131
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
void gr_bitmap_list(bitmap_2d_list *list, int n_bm, int resize_mode)
Definition: 2d.cpp:1407
void gr_get_color(int *r, int *g, int b)
void(* gf_stencil_clear)()
Definition: 2d.h:491
void(* gf_reset_lighting)()
Definition: 2d.h:584
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(* gf_line)(int x1, int y1, int x2, int y2, int resize_mode)
Definition: 2d.h:444
int clip_width_unscaled
Definition: 2d.h:379
int(* gf_bm_set_render_target)(int n, int face)
Definition: 2d.h:544
Definition: pstypes.h:88
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
vertex_format format_type
Definition: 2d.h:1032
__inline int gr_bm_set_render_target(int n, int face=-1)
Definition: 2d.h:866
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
void(* gf_set_animated_effect)(int effect, float timer)
Definition: 2d.h:625
~buffer_data()
Definition: 2d.h:295
Definition: 2d.h:95
int texture
Definition: 2d.h:192
int res
Definition: 2d.h:370
void assign(int i, uint j)
Definition: 2d.h:212
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
__inline void gr_gradient(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:808
ubyte r
Definition: 2d.h:84
void(* gf_deferred_lighting_end)()
Definition: 2d.h:596
void(* gf_post_process_set_effect)(const char *, int)
Definition: 2d.h:588
int center_h
Definition: 2d.h:363
GLclampf f
Definition: Glext.h:7097
void(* gf_scene_texture_begin)()
Definition: 2d.h:599
vertex_format_data(vertex_format i_format_type, uint i_stride, void *i_data_src)
Definition: 2d.h:1036
void gr_activate(int active)
Definition: 2d.cpp:1122
#define GR_DEFAULT
Definition: 2d.h:646
int bits_per_pixel
Definition: 2d.h:374
int(* gf_set_cull)(int cull)
Definition: 2d.h:519
float clip_center_y
Definition: 2d.h:381
__inline void gr_render_buffer(int start, const vertex_buffer *bufferp, int texi, int flags=TMAP_FLAG_TEXTURED)
Definition: 2d.h:877
buffer_data & operator=(const buffer_data &rhs)
Definition: 2d.h:266
int center_offset_y
Definition: 2d.h:364
Definition: 2d.h:82
enum_h * u
Definition: lua.cpp:12649
void gr_bitmap_uv(int _x, int _y, int _w, int _h, float _u0, float _v0, float _u1, float _v1, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:1356
bool(* gf_pack_buffer)(const int buffer_id, vertex_buffer *vb)
Definition: 2d.h:553
void gr_reset_screen_scale()
Definition: 2d.cpp:176
int flags
Definition: 2d.h:307
int save_max_w
Definition: 2d.h:365
int center_w
Definition: 2d.h:363
int(* gf_maybe_create_shader)(shader_type type, unsigned int flags)
Definition: 2d.h:623
ubyte b
Definition: 2d.h:84
int n_verts
Definition: 2d.h:152
int(* gf_set_color_buffer)(int mode)
Definition: 2d.h:522
void gr_opengl_update_texture(int bitmap_handle, int bpp, const ubyte *data, int width, int height)
ubyte blue
Definition: 2d.h:102
void release()
Definition: 2d.h:204
GLfloat GLfloat GLfloat v2
Definition: Glext.h:5640
GLsizeiptr size
Definition: Glext.h:5496
int max_w_unscaled
Definition: 2d.h:361
bool(* gf_bm_data)(int n, bitmap *bm)
Definition: 2d.h:541
void(* gf_draw_line_list)(const colored_vector *lines, int num)
Definition: 2d.h:616
poly_list & operator=(poly_list &)
Definition: 2d.cpp:1943
int is_alphacolor
Definition: 2d.h:97
float clip_center_x
Definition: 2d.h:381
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
void(* gf_flip)()
Definition: 2d.h:409
void(* gf_pixel)(int x, int y, int resize_mode)
Definition: 2d.h:453
void(* gf_set_gamma)(float gamma)
Definition: 2d.h:505
uint get_num_vertex_components()
Definition: 2d.h:1048
bool gr_unsize_screen_posf(float *x, float *y, float *w=NULL, float *h=NULL, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:538
int n_verts
Definition: 2d.h:193
int(* gf_create_buffer)()
Definition: 2d.h:552
void(* gf_translate_texture_matrix)(int unit, const vec3d *shift)
Definition: 2d.h:546
ubyte g
Definition: 2d.h:84
int clip_height
Definition: 2d.h:378
GLenum type
Definition: Gl.h:1492
colored_vector()
Definition: 2d.h:172
void gr_get_string_size_win(int *w, int *h, const char *text)
GLint GLsizei width
Definition: Gl.h:1505
void(* gf_circle)(int x, int y, int r, int resize_mode)
Definition: 2d.h:438
ubyte green
Definition: 2d.h:101
void gr_rect(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:2068
uint signature
Definition: 2d.h:359
void(* gf_arc)(int x, int y, float r, float angle_start, float angle_end, bool fill, int resize_mode)
Definition: 2d.h:440
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:741
SCP_vector< buffer_data > tex_buf
Definition: 2d.h:314
void(* gf_set_clip)(int x, int y, int w, int h, int resize_mode)
Definition: 2d.h:419
GLenum GLuint GLint GLenum face
Definition: Glext.h:6586
void(* gf_post_process_set_defaults)()
Definition: 2d.h:589
void release()
Definition: 2d.h:326
uint(* gf_lock)()
Definition: 2d.h:509
int bytes_per_pixel
Definition: 2d.h:375
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void(* gf_unfilled_circle)(int x, int y, int r, int resize_mode)
Definition: 2d.h:439
GLintptr offset
Definition: Glext.h:5497
void(* gf_destroy_buffer)(int)
Definition: 2d.h:555
int clip_left_unscaled
Definition: 2d.h:390
const float Default_max_draw_distance
Definition: 2d.cpp:83
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
int(* gf_alpha_mask_set)(int mode, float alpha)
Definition: 2d.h:493
uint * sorted_indices
Definition: 2d.h:158
void(* gf_start_clip_plane)()
Definition: 2d.h:608
unsigned int uint
Definition: pstypes.h:64
void gr_init_alphacolor(color *clr, int r, int g, int b, int alpha, int type=AC_TYPE_HUD)
Definition: 2d.cpp:1173
int offset_x
Definition: 2d.h:376
GLboolean GLboolean g
Definition: Glext.h:5781
void add_vertex_component(vertex_format_data::vertex_format format_type, uint stride, void *src)
Definition: 2d.h:1054
void gr_close()
Definition: 2d.cpp:637
GLuint coords
Definition: Glext.h:6925
__inline void gr_arc(int xc, int yc, float r, float angle_start, float angle_end, bool fill, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:784
GLenum GLenum dst
Definition: Glext.h:5917
void(* gf_aascaler)(vertex *va, vertex *vb)
Definition: 2d.h:459
void(* gf_set_light_factor)(float)
Definition: 2d.h:604
int clip_top_unscaled
Definition: 2d.h:390
int clip_right_unscaled
Definition: 2d.h:390
float clip_aspect
Definition: 2d.h:372
GLboolean GLboolean GLboolean GLboolean a
Definition: Glext.h:5781
int alphacolor
Definition: 2d.h:98
int offset_x_unscaled
Definition: 2d.h:377
__inline void gr_unfilled_circle(int xc, int yc, int d, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:779
void _cdecl gr_printf_menu_zoomed(int x, int y, const char *format,...)
Definition: font.cpp:328
char * filename
int magic
Definition: 2d.h:99
vec3d vec
Definition: 2d.h:176
void(* gf_set_transform_buffer_offset)(int offset)
Definition: 2d.h:561
uint screen_sig
Definition: 2d.h:96
void(* gf_set_texture_panning)(float u, float v, bool enable)
Definition: 2d.h:614
struct color color
Definition: Glext.h:6943
void(* gf_tmapper)(int nv, vertex *verts[], uint flags)
Definition: 2d.h:462
void _cdecl gr_printf(int x, int y, const char *format,...)
Definition: font.cpp:300
#define w(p)
Definition: modelsinc.h:68
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
tsb_t * tsb
Definition: 2d.h:155
ubyte red
Definition: 2d.h:100
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
float b
Definition: 2d.h:111
vertex_format_data * get_vertex_component(uint index)
Definition: 2d.h:1050
int(* gf_zbuffer_set)(int mode)
Definition: 2d.h:482
void(* gf_update_transform_buffer)(void *data, uint size)
Definition: 2d.h:560
void(* gf_end_clip_plane)()
Definition: 2d.h:609
Definition: bmpman.h:101
void(* gf_clear_states)()
Definition: 2d.h:627
void gr_pline_special(SCP_vector< vec3d > *pts, int thickness, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:1471
GLdouble s
Definition: Glext.h:5321
ubyte ac_type
Definition: 2d.h:104
int gr_global_zbuffering
Definition: 2d.cpp:73
int find_index(poly_list *plist, int idx)
Definition: 2d.cpp:1670
void(* gf_start_angles_instance_matrix)(const vec3d *, const angles *)
Definition: 2d.h:577
poly_list * model_list
Definition: 2d.h:312
void make_index_buffer(SCP_vector< int > &vertex_list)
Definition: 2d.cpp:1870
GLenum GLuint id
Definition: Glext.h:5156
void gr_set_screen_scale(int x, int y, int zoom_x=-1, int zoom_y=-1, int max_x=gr_screen.max_w, int max_y=gr_screen.max_h, int center_x=gr_screen.center_w, int center_y=gr_screen.center_h, bool force_stretch=false)
Definition: 2d.cpp:104
__inline void gr_bitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:760
int find_index_fast(poly_list *plist, int idx)
Definition: 2d.cpp:1692
void(* gf_lighting)(bool, bool)
Definition: 2d.h:603
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
int idx
Definition: multiui.cpp:761
int rendering_to_face
Definition: 2d.h:404
int(* gf_preload)(int bitmap_num, int is_aabitmap)
Definition: 2d.h:531
void(* gf_post_process_begin)()
Definition: 2d.h:591
void(* gf_post_process_save_zbuffer)()
Definition: 2d.h:593
ubyte c
Definition: 2d.h:84
void gr_shade(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:2085
void(* gf_start_frame)()
Definition: 2d.h:473
int clip_top
Definition: 2d.h:388
void(* gf_flash_alpha)(int r, int g, int b, int a)
Definition: 2d.h:416
buffer_data()
Definition: 2d.h:225
void(* gf_scaler)(vertex *va, vertex *vb, bool bw_bitmap)
Definition: 2d.h:456
int save_max_w_unscaled_zoomed
Definition: 2d.h:367
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
size_t index_offset
Definition: 2d.h:195
ubyte alpha
Definition: 2d.h:103
GLclampd n
Definition: Glext.h:7286
unsigned char ubyte
Definition: pstypes.h:62
float r
Definition: 2d.h:111
void(* gf_set_line_width)(float width)
Definition: 2d.h:618
void gr_shield_icon(coord2d coords[6], const int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:2046
int save_center_h
Definition: 2d.h:368
ubyte lookup[256]
Definition: 2d.h:85
void(* gf_reset_clip)()
Definition: 2d.h:422
int max_w
Definition: 2d.h:360
void gr_screen_resize(int width, int height)
Definition: 2d.cpp:733
GLuint start
Definition: Gl.h:1502
vertex_layout()
Definition: 2d.h:1046
#define GR_RESIZE_FULL
Definition: 2d.h:682
GLfloat GLfloat v1
Definition: Glext.h:5639
GLbitfield flags
Definition: Glext.h:6722
vertex * vert
Definition: 2d.h:153
vertex * vert
Definition: 2d.h:184
Definition: 2d.h:109
typedef void(APIENTRY *PFNGLARRAYELEMENTEXTPROC)(GLint i)
shader_type
Definition: 2d.h:30
uint i_last
Definition: 2d.h:202
Definition: lighting.h:32
int envmap_render_target
Definition: 2d.h:406
GLuint const GLchar * name
Definition: Glext.h:5608
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:791
color current_fog_color
Definition: 2d.h:397
int offset_y
Definition: 2d.h:376
int max_w_unscaled_zoomed
Definition: 2d.h:362
void(* gf_set_clear_color)(int r, int g, int b)
Definition: 2d.h:534
GLboolean enable
Definition: Glext.h:10591
const char * Resolution_prefixes[GR_NUM_RESOLUTIONS]
Definition: 2d.cpp:44
void(* gf_line_htl)(const vec3d *start, const vec3d *end)
Definition: 2d.h:620
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
__inline void gr_fog_set(int fog_mode, int r, int g, int b, float fog_near=-1.0f, float fog_far=-1.0f)
Definition: 2d.h:833
int clip_right
Definition: 2d.h:388
void(* gf_set_texture_addressing)(int)
Definition: 2d.h:550
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
int save_center_offset_y
Definition: 2d.h:369
GLuint GLuint num
Definition: Glext.h:9089
void(* gf_copy_effect_texture)()
Definition: 2d.h:601
Definition: 2d.h:120
bool gr_unsize_screen_pos(int *x, int *y, int *w=NULL, int *h=NULL, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:320
void(* gf_scene_texture_end)()
Definition: 2d.h:600
void(* gf_pop_texture_matrix)(int unit)
Definition: 2d.h:548
struct team_color::@237 base
~vertex_buffer()
Definition: 2d.h:321
size_t vertex_offset
Definition: 2d.h:310
void(* gf_set_fill_mode)(int)
Definition: 2d.h:613
uint screen_sig
Definition: 2d.h:83
struct shader shader
Definition: Glext.h:5614
GLint GLsizei GLsizei height
Definition: Gl.h:1505
int flags
Definition: 2d.h:190
float fog_far
Definition: 2d.h:383
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
float Min_draw_distance
Definition: 2d.cpp:84
struct screen screen
const uint * get_index() const
Definition: 2d.h:197
struct tsb_t tsb_t
buffer_data(int n_vrts)
Definition: 2d.h:231
int clip_bottom_unscaled
Definition: 2d.h:390
void gr_set_cursor_bitmap(int n, int lock=0)
Definition: 2d.cpp:1242
void gr_unset_cursor_bitmap(int n)
Definition: 2d.cpp:1281
void(* gf_zbuffer_clear)(int use_zbuffer)
Definition: 2d.h:485
void gr_set_palette(const char *name, ubyte *palette, int restrict_to_128=0)
Definition: 2d.cpp:722
int Web_cursor_bitmap
Definition: 2d.cpp:60
void(* gf_set_ambient_light)(int, int, int)
Definition: 2d.h:585
void(* gf_start_instance_matrix)(const vec3d *, const matrix *)
Definition: 2d.h:576
int clip_width
Definition: 2d.h:378
struct team_color team_color
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
void(* gf_pop_scale_matrix)()
Definition: 2d.h:574
bool custom_size
Definition: 2d.h:402
float g
Definition: 2d.h:111
void(* gf_deferred_lighting_finish)()
Definition: 2d.h:597
int gr_get_cursor_bitmap()
Definition: 2d.cpp:1297
bool gr_init(int d_mode=GR_DEFAULT, int d_width=GR_DEFAULT, int d_height=GR_DEFAULT, int d_depth=GR_DEFAULT)
Definition: 2d.cpp:909
int gr_get_font_height()
Definition: font.cpp:187
float fog_near
Definition: 2d.h:383
int center_offset_x
Definition: 2d.h:364
ubyte raw8
Definition: 2d.h:105
int clip_height_unscaled
Definition: 2d.h:379
GLenum src
Definition: Glext.h:5917
int max_h
Definition: 2d.h:360
__inline void gr_aabitmap(int x, int y, int resize_mode=GR_RESIZE_FULL, bool mirror=false)
Definition: 2d.h:750
GLenum GLsizei GLenum GLenum const GLvoid * data
Definition: Gl.h:1509
#define TMAP_FLAG_TEXTURED
Definition: tmapper.h:36
int current_bitblt_mode
Definition: 2d.h:393
__inline void gr_aabitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_mode=GR_RESIZE_FULL, bool mirror=false)
Definition: 2d.h:755
int save_max_w_unscaled
Definition: 2d.h:366
void(* gf_set_light)(light *)
Definition: 2d.h:583
color current_color
Definition: 2d.h:396
Definition: 2d.h:129
void(* gf_push_scale_matrix)(const vec3d *)
Definition: 2d.h:573
int current_alphablend_mode
Definition: 2d.h:392
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
const float Default_min_draw_distance
Definition: 2d.cpp:82
void(* gf_zbias)(int zbias)
Definition: 2d.h:611
int(* gf_zbuffer_get)()
Definition: 2d.h:479
#define GR_BITBLT_MODE_NORMAL
Definition: 2d.h:351
int(* gf_save_screen)()
Definition: 2d.h:496
uint stride
Definition: 2d.h:309
GLenum GLsizei len
Definition: Glext.h:6283
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(* gf_clear)()
Definition: 2d.h:425
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
uint i_first
Definition: 2d.h:202
void(* gf_end_instance_matrix)()
Definition: 2d.h:578
bool gr_resize_screen_pos(int *x, int *y, int *w=NULL, int *h=NULL, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:212
void clear()
Definition: 2d.h:338
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
void gr_flip()
Definition: 2d.cpp:2113
ubyte * gr_opengl_get_texture_update_pointer(int bitmap_handle)
void(* gf_deferred_lighting_begin)()
Definition: 2d.h:595
int Gr_inited
Definition: 2d.cpp:63
#define GR_ALPHABLEND_NONE
Definition: 2d.h:348
void _cdecl gr_printf_no_resize(int x, int y, const char *format,...)
Definition: font.cpp:342
void(* gf_end_proj_matrix)()
Definition: 2d.h:568
int save_max_h_unscaled_zoomed
Definition: 2d.h:367
__inline void gr_pixel(int x, int y, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:798
float scaler
Definition: 2d.h:122
GLclampf GLclampf GLclampf alpha
Definition: Glext.h:5177
int rendering_to_texture
Definition: 2d.h:403
poly_list()
Definition: 2d.h:145
int save_center_w
Definition: 2d.h:368
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
int gr_zbuffering_mode
Definition: 2d.cpp:72
int gr_zbuffering
Definition: 2d.cpp:71
void(* gf_print_screen)(const char *filename)
Definition: 2d.h:470
void(* gf_render)(int nv, vertex *verts, uint flags)
Definition: 2d.h:465
int save_max_h
Definition: 2d.h:365
int gr_alpha_test
Definition: 2d.cpp:79
void _cdecl gr_printf_menu(int x, int y, const char *format,...)
Definition: font.cpp:314
void gr_init_color(color *c, int r, int g, int b)
Definition: 2d.cpp:1155
#define _cdecl
Definition: config.h:71
void * data_src
Definition: 2d.h:1034
void allocate(int size)
Definition: 2d.cpp:1704
void(* gf_bitmap_ex)(int x, int y, int w, int h, int sx, int sy, int resize_mode)
Definition: 2d.h:428
const GLdouble * v
Definition: Glext.h:5322
int rowsize
Definition: 2d.h:373
void gr_bitmap(int x, int y, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.cpp:1303
int max_h_unscaled_zoomed
Definition: 2d.h:362
void gr_set_color(int r, int g, int b)
Definition: 2d.cpp:1188
float aspect
Definition: 2d.h:372
const GLubyte * c
Definition: Glext.h:8376
void(* gf_render_buffer)(int, const vertex_buffer *, int, int)
Definition: 2d.h:557
int(* gf_create_stream_buffer)()
Definition: 2d.h:563
GLuint GLuint end
Definition: Gl.h:1502
GLint y
Definition: Gl.h:1505
void calculate_tangent()
Definition: 2d.cpp:1781
int(* gf_tcache_set)(int bitmap_id, int bitmap_type, float *u_scale, float *v_scale, int stage)
Definition: 2d.h:528
Definition: 2d.h:358
void(* gf_update_buffer_object)(int handle, uint size, void *data)
Definition: 2d.h:559
void(* gf_modify_light)(light *, int, int)
Definition: 2d.h:581
int current_bitmap
Definition: 2d.h:395
GLenum GLsizei stride
Definition: Gl.h:1492
~poly_list()
Definition: 2d.cpp:1753
void(* gf_gradient)(int x1, int y1, int x2, int y2, int resize_mode)
Definition: 2d.h:436