Quake II RTX doxygen  1.0 dev
main.c File Reference
#include "gl.h"

Go to the source code of this file.

Macros

#define E(x)   case GL_##x: str = "GL_"#x; break;
 

Functions

static void GL_SetupFrustum (void)
 
glCullResult_t GL_CullBox (vec3_t bounds[2])
 
glCullResult_t GL_CullSphere (const vec3_t origin, float radius)
 
static void make_box_points (const vec3_t origin, vec3_t bounds[2], vec3_t points[8])
 
glCullResult_t GL_CullLocalBox (const vec3_t origin, vec3_t bounds[2])
 
qboolean GL_AllocBlock (int width, int height, int *inuse, int w, int h, int *s, int *t)
 
void GL_MultMatrix (GLfloat *p, const GLfloat *a, const GLfloat *b)
 
void GL_RotateForEntity (vec3_t origin, float scale)
 
static void GL_DrawSpriteModel (model_t *model)
 
static void GL_DrawNullModel (void)
 
static void GL_DrawEntities (int mask)
 
static void GL_DrawTearing (void)
 
static const char * GL_ErrorString (GLenum err)
 
void QGL_ClearErrors (void)
 
qboolean GL_ShowErrors (const char *func)
 
void R_RenderFrame_GL (refdef_t *fd)
 
void R_BeginFrame_GL (void)
 
void R_EndFrame_GL (void)
 
static void GL_Strings_f (void)
 
static size_t GL_ViewCluster_m (char *buffer, size_t size)
 
static void gl_lightmap_changed (cvar_t *self)
 
static void gl_modulate_entities_changed (cvar_t *self)
 
static void gl_modulate_changed (cvar_t *self)
 
static void gl_drawsky_changed (cvar_t *self)
 
static void gl_novis_changed (cvar_t *self)
 
static void GL_Register (void)
 
static void GL_Unregister (void)
 
static qboolean GL_SetupConfig (void)
 
static void GL_InitTables (void)
 
static void GL_PostInit (void)
 
qboolean R_Init_GL (qboolean total)
 
void R_Shutdown_GL (qboolean total)
 
void R_BeginRegistration_GL (const char *name)
 
void R_EndRegistration_GL (void)
 
void R_ModeChanged_GL (int width, int height, int flags, int rowbytes, void *pixels)
 
void R_AddDecal_GL (decal_t *d)
 
qboolean R_InterceptKey_GL (unsigned key, qboolean down)
 
void R_RegisterFunctionsGL ()
 

Variables

glRefdef_t glr
 
glStatic_t gl_static
 
glConfig_t gl_config
 
statCounters_t c
 
entity_t gl_world
 
int registration_sequence
 
cvar_t * gl_partscale
 
cvar_t * gl_partstyle
 
cvar_t * gl_celshading
 
cvar_t * gl_dotshading
 
cvar_t * gl_shadows
 
cvar_t * gl_modulate
 
cvar_t * gl_modulate_world
 
cvar_t * gl_coloredlightmaps
 
cvar_t * gl_brightness
 
cvar_t * gl_dynamic
 
cvar_t * gl_modulate_entities
 
cvar_t * gl_doublelight_entities
 
cvar_t * gl_fragment_program
 
cvar_t * gl_vertex_buffer_object
 
cvar_t * gl_fontshadow
 
cvar_t * gl_znear
 
cvar_t * gl_drawworld
 
cvar_t * gl_drawentities
 
cvar_t * gl_drawsky
 
cvar_t * gl_showtris
 
cvar_t * gl_showorigins
 
cvar_t * gl_showtearing
 
cvar_t * gl_cull_nodes
 
cvar_t * gl_cull_models
 
cvar_t * gl_clear
 
cvar_t * gl_finish
 
cvar_t * gl_hash_faces
 
cvar_t * gl_novis
 
cvar_t * gl_lockpvs
 
cvar_t * gl_lightmap
 
cvar_t * gl_fullbright
 
cvar_t * gl_vertexlight
 
cvar_t * gl_polyblend
 
cvar_t * gl_showerrors
 

Macro Definition Documentation

◆ E

#define E (   x)    case GL_##x: str = "GL_"#x; break;

Function Documentation

◆ GL_AllocBlock()

qboolean GL_AllocBlock ( int  width,
int  height,
int inuse,
int  w,
int  h,
int s,
int t 
)

Definition at line 252 of file main.c.

254 {
255  int i, j, k, x, y, max_inuse, min_inuse;
256 
257  x = 0; y = height;
258  min_inuse = height;
259  for (i = 0; i < width - w; i++) {
260  max_inuse = 0;
261  for (j = 0; j < w; j++) {
262  k = inuse[i + j];
263  if (k >= min_inuse) {
264  break;
265  }
266  if (max_inuse < k) {
267  max_inuse = k;
268  }
269  }
270  if (j == w) {
271  x = i;
272  y = min_inuse = max_inuse;
273  }
274  }
275 
276  if (y + h > height) {
277  return qfalse;
278  }
279 
280  for (i = 0; i < w; i++) {
281  inuse[x + i] = y + h;
282  }
283 
284  *s = x;
285  *t = y;
286  return qtrue;
287 }

◆ GL_CullBox()

glCullResult_t GL_CullBox ( vec3_t  bounds[2])

Definition at line 122 of file main.c.

123 {
124  int i, bits;
125  glCullResult_t cull;
126 
127  if (!gl_cull_models->integer) {
128  return CULL_IN;
129  }
130 
131  cull = CULL_IN;
132  for (i = 0; i < 4; i++) {
133  bits = BoxOnPlaneSide(bounds[0], bounds[1], &glr.frustumPlanes[i]);
134  if (bits == BOX_BEHIND) {
135  return CULL_OUT;
136  }
137  if (bits != BOX_INFRONT) {
138  cull = CULL_CLIP;
139  }
140  }
141 
142  return cull;
143 }

Referenced by cull_lerped_model(), cull_static_model(), and GL_DrawBspModel().

◆ GL_CullLocalBox()

glCullResult_t GL_CullLocalBox ( const vec3_t  origin,
vec3_t  bounds[2] 
)

Definition at line 185 of file main.c.

186 {
187  vec3_t points[8];
188  cplane_t *p;
189  int i, j;
190  vec_t dot;
191  qboolean infront;
192  glCullResult_t cull;
193 
194  if (!gl_cull_models->integer) {
195  return CULL_IN;
196  }
197 
198  make_box_points(origin, bounds, points);
199 
200  cull = CULL_IN;
201  for (i = 0, p = glr.frustumPlanes; i < 4; i++, p++) {
202  infront = qfalse;
203  for (j = 0; j < 8; j++) {
204  dot = DotProduct(points[j], p->normal);
205  if (dot >= p->dist) {
206  infront = qtrue;
207  if (cull == CULL_CLIP) {
208  break;
209  }
210  } else {
211  cull = CULL_CLIP;
212  if (infront) {
213  break;
214  }
215  }
216  }
217  if (!infront) {
218  return CULL_OUT;
219  }
220  }
221 
222  return cull;
223 }

Referenced by cull_lerped_model(), cull_static_model(), and GL_DrawBspModel().

◆ GL_CullSphere()

glCullResult_t GL_CullSphere ( const vec3_t  origin,
float  radius 
)

Definition at line 145 of file main.c.

146 {
147  float dist;
148  cplane_t *p;
149  int i;
150  glCullResult_t cull;
151 
152  if (!gl_cull_models->integer) {
153  return CULL_IN;
154  }
155 
156  cull = CULL_IN;
157  for (i = 0, p = glr.frustumPlanes; i < 4; i++, p++) {
158  dist = PlaneDiff(origin, p);
159  if (dist < -radius) {
160  return CULL_OUT;
161  }
162  if (dist <= radius) {
163  cull = CULL_CLIP;
164  }
165  }
166 
167  return cull;
168 }

Referenced by cull_lerped_model(), cull_static_model(), and GL_DrawBspModel().

◆ GL_DrawEntities()

static void GL_DrawEntities ( int  mask)
static

Definition at line 418 of file main.c.

419 {
420  entity_t *ent, *last;
421  model_t *model;
422 
423  if (!gl_drawentities->integer) {
424  return;
425  }
426 
427  last = glr.fd.entities + glr.fd.num_entities;
428  for (ent = glr.fd.entities; ent != last; ent++) {
429  if (ent->flags & RF_BEAM) {
430  // beams are drawn elsewhere in single batch
431  glr.num_beams++;
432  continue;
433  }
434  if ((ent->flags & RF_TRANSLUCENT) != mask) {
435  continue;
436  }
437 
438  glr.ent = ent;
439 
440  // convert angles to axis
441  if (VectorEmpty(ent->angles)) {
442  glr.entrotated = qfalse;
443  VectorSet(glr.entaxis[0], 1, 0, 0);
444  VectorSet(glr.entaxis[1], 0, 1, 0);
445  VectorSet(glr.entaxis[2], 0, 0, 1);
446  } else {
447  glr.entrotated = qtrue;
448  AnglesToAxis(ent->angles, glr.entaxis);
449  }
450 
451  // inline BSP model
452  if (ent->model & 0x80000000) {
453  bsp_t *bsp = gl_static.world.cache;
454  int index = ~ent->model;
455 
456  if (glr.fd.rdflags & RDF_NOWORLDMODEL) {
457  Com_Error(ERR_DROP, "%s: inline model without world",
458  __func__);
459  }
460 
461  if (index < 1 || index >= bsp->nummodels) {
462  Com_Error(ERR_DROP, "%s: inline model %d out of range",
463  __func__, index);
464  }
465 
466  GL_DrawBspModel(&bsp->models[index]);
467  continue;
468  }
469 
470  model = MOD_ForHandle(ent->model);
471  if (!model) {
473  continue;
474  }
475 
476  switch (model->type) {
477  case MOD_ALIAS:
478  GL_DrawAliasModel(model);
479  break;
480  case MOD_SPRITE:
481  GL_DrawSpriteModel(model);
482  break;
483  case MOD_EMPTY:
484  break;
485  default:
486  Com_Error(ERR_FATAL, "%s: bad model type", __func__);
487  }
488 
489  if (gl_showorigins->integer) {
491  }
492  }
493 }

Referenced by R_RenderFrame_GL().

◆ GL_DrawNullModel()

static void GL_DrawNullModel ( void  )
static

Definition at line 391 of file main.c.

392 {
393  static const uint32_t colors[6] = {
394  U32_RED, U32_RED,
395  U32_GREEN, U32_GREEN,
396  U32_BLUE, U32_BLUE
397  };
398  entity_t *e = glr.ent;
399  vec3_t points[6];
400 
401  VectorCopy(e->origin, points[0]);
402  VectorCopy(e->origin, points[2]);
403  VectorCopy(e->origin, points[4]);
404 
405  VectorMA(e->origin, 16, glr.entaxis[0], points[1]);
406  VectorMA(e->origin, 16, glr.entaxis[1], points[3]);
407  VectorMA(e->origin, 16, glr.entaxis[2], points[5]);
408 
413  GL_ColorBytePointer(4, 0, (GLubyte *)colors);
414  GL_VertexPointer(3, 0, &points[0][0]);
415  qglDrawArrays(GL_LINES, 0, 6);
416 }

Referenced by GL_DrawEntities().

◆ gl_drawsky_changed()

static void gl_drawsky_changed ( cvar_t *  self)
static

Definition at line 724 of file main.c.

725 {
726  if (gl_static.world.cache)
727  CL_SetSky();
728 }

Referenced by GL_Register().

◆ GL_DrawSpriteModel()

static void GL_DrawSpriteModel ( model_t *  model)
static

Definition at line 336 of file main.c.

337 {
338  static const vec_t tcoords[8] = { 0, 1, 0, 0, 1, 1, 1, 0 };
339  entity_t *e = glr.ent;
340  mspriteframe_t *frame = &model->spriteframes[e->frame % model->numframes];
341  image_t *image = frame->image;
342  float alpha = (e->flags & RF_TRANSLUCENT) ? e->alpha : 1;
343  int bits = GLS_DEPTHMASK_FALSE;
344  vec3_t up, down, left, right;
345  vec3_t points[4];
346 
347  const vec3_t world_y = { 0.f, 0.f, 1.f };
348 
349  if (alpha == 1) {
350  if (image->flags & IF_TRANSPARENT) {
351  if (image->flags & IF_PALETTED) {
352  bits |= GLS_ALPHATEST_ENABLE;
353  } else {
354  bits |= GLS_BLEND_BLEND;
355  }
356  }
357  } else {
358  bits |= GLS_BLEND_BLEND;
359  }
360 
362  GL_BindTexture(0, image->texnum);
363  GL_StateBits(bits);
365  qglColor4f(1, 1, 1, alpha);
366 
367  VectorScale(glr.viewaxis[1], frame->origin_x, left);
368  VectorScale(glr.viewaxis[1], frame->origin_x - frame->width, right);
369 
370  if (model->sprite_vertical)
371  {
372  VectorScale(world_y, -frame->origin_y, down);
373  VectorScale(world_y, frame->height - frame->origin_y, up);
374  }
375  else
376  {
377  VectorScale(glr.viewaxis[2], -frame->origin_y, down);
378  VectorScale(glr.viewaxis[2], frame->height - frame->origin_y, up);
379  }
380 
381  VectorAdd3(e->origin, down, left, points[0]);
382  VectorAdd3(e->origin, up, left, points[1]);
383  VectorAdd3(e->origin, down, right, points[2]);
384  VectorAdd3(e->origin, up, right, points[3]);
385 
386  GL_TexCoordPointer(2, 0, tcoords);
387  GL_VertexPointer(3, 0, &points[0][0]);
388  qglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
389 }

Referenced by GL_DrawEntities().

◆ GL_DrawTearing()

static void GL_DrawTearing ( void  )
static

Definition at line 495 of file main.c.

496 {
497  static int i;
498 
499  // alternate colors to make tearing obvious
500  i++;
501  if (i & 1) {
502  qglClearColor(1, 1, 1, 1);
503  } else {
504  qglClearColor(1, 0, 0, 0);
505  }
506 
507  qglClear(GL_COLOR_BUFFER_BIT);
508  qglClearColor(0, 0, 0, 1);
509 }

Referenced by R_EndFrame_GL().

◆ GL_ErrorString()

static const char* GL_ErrorString ( GLenum  err)
static

Definition at line 511 of file main.c.

512 {
513  const char *str;
514 
515  switch (err) {
516 #define E(x) case GL_##x: str = "GL_"#x; break;
517  E(NO_ERROR)
518  E(INVALID_ENUM)
519  E(INVALID_VALUE)
520  E(INVALID_OPERATION)
521  E(STACK_OVERFLOW)
522  E(STACK_UNDERFLOW)
523  E(OUT_OF_MEMORY)
524  default: str = "UNKNOWN ERROR";
525 #undef E
526  }
527 
528  return str;
529 }

Referenced by GL_ShowErrors().

◆ GL_InitTables()

static void GL_InitTables ( void  )
static

Definition at line 953 of file main.c.

954 {
955  vec_t lat, lng;
956  const vec_t *v;
957  int i;
958 
959  for (i = 0; i < NUMVERTEXNORMALS; i++) {
960  v = bytedirs[i];
961  lat = acos(v[2]);
962  lng = atan2(v[1], v[0]);
963  gl_static.latlngtab[i][0] = lat * (255.0f / (2 * M_PI));
964  gl_static.latlngtab[i][1] = lng * (255.0f / (2 * M_PI));
965  }
966 
967  for (i = 0; i < 256; i++) {
968  gl_static.sintab[i] = sin(i * (2 * M_PI / 255.0f));
969  }
970 }

Referenced by R_Init_GL().

◆ gl_lightmap_changed()

static void gl_lightmap_changed ( cvar_t *  self)
static

Definition at line 700 of file main.c.

701 {
703  if (AT_LEAST_OPENGL_ES(1, 0))
704  lm.comp = GL_RGBA; // ES doesn't support internal format != external
705  else
706  lm.comp = lm.scale ? GL_RGB : GL_LUMINANCE;
707  lm.add = 255 * Cvar_ClampValue(gl_brightness, -1, 1);
708  lm.modulate = gl_modulate->value * gl_modulate_world->value;
709  lm.dirty = qtrue; // rebuild all lightmaps next frame
710 }

Referenced by gl_modulate_changed(), and GL_Register().

◆ gl_modulate_changed()

static void gl_modulate_changed ( cvar_t *  self)
static

Definition at line 717 of file main.c.

718 {
719  gl_lightmap_changed(self);
721 }

Referenced by GL_Register().

◆ gl_modulate_entities_changed()

static void gl_modulate_entities_changed ( cvar_t *  self)
static

Definition at line 712 of file main.c.

713 {
715 }

Referenced by gl_modulate_changed(), and GL_Register().

◆ GL_MultMatrix()

void GL_MultMatrix ( GLfloat *  p,
const GLfloat *  a,
const GLfloat *  b 
)

Definition at line 290 of file main.c.

291 {
292  int i, j;
293 
294  for (i = 0; i < 4; i++) {
295  for (j = 0; j < 4; j++) {
296  p[i * 4 + j] =
297  a[0 * 4 + j] * b[i * 4 + 0] +
298  a[1 * 4 + j] * b[i * 4 + 1] +
299  a[2 * 4 + j] * b[i * 4 + 2] +
300  a[3 * 4 + j] * b[i * 4 + 3];
301  }
302  }
303 }

Referenced by GL_RotateForEntity(), and setup_shadow().

◆ gl_novis_changed()

static void gl_novis_changed ( cvar_t *  self)
static

Definition at line 730 of file main.c.

731 {
733 }

Referenced by GL_Register().

◆ GL_PostInit()

static void GL_PostInit ( void  )
static

Definition at line 972 of file main.c.

973 {
975 
976  if (gl_vertex_buffer_object->modified) {
977  // enable buffer objects before map is loaded
979  if (gl_vertex_buffer_object->integer) {
980  Com_Printf("...enabling GL_ARB_vertex_buffer_object\n");
983  } else {
984  Com_Printf("...ignoring GL_ARB_vertex_buffer_object\n");
985  }
986  } else if (gl_vertex_buffer_object->integer) {
987  Com_Printf("GL_ARB_vertex_buffer_object not found\n");
988  Cvar_Set("gl_vertex_buffer_object", "0");
989  }
990 
991  // reset the modified flag
992  gl_vertex_buffer_object->modified = qfalse;
993  }
994 
996  GL_InitImages();
997  MOD_Init();
998 }

Referenced by R_Init_GL().

◆ GL_Register()

static void GL_Register ( void  )
static

Definition at line 735 of file main.c.

736 {
737  // regular variables
738  gl_partscale = Cvar_Get("gl_partscale", "2", 0);
739  gl_partstyle = Cvar_Get("gl_partstyle", "0", 0);
740  gl_celshading = Cvar_Get("gl_celshading", "0", 0);
741  gl_dotshading = Cvar_Get("gl_dotshading", "1", 0);
742  gl_shadows = Cvar_Get("gl_shadows", "1", CVAR_ARCHIVE);
743  gl_modulate = Cvar_Get("gl_modulate", "1", CVAR_ARCHIVE);
744  gl_modulate->changed = gl_modulate_changed;
745  gl_modulate_world = Cvar_Get("gl_modulate_world", "1", 0);
747  gl_coloredlightmaps = Cvar_Get("gl_coloredlightmaps", "1", 0);
749  gl_brightness = Cvar_Get("gl_brightness", "0", 0);
751  gl_dynamic = Cvar_Get("gl_dynamic", "1", 0);
752  gl_dynamic->changed = gl_lightmap_changed;
753 #if USE_DLIGHTS
754  gl_dlight_falloff = Cvar_Get("gl_dlight_falloff", "1", 0);
755 #endif
756  gl_modulate_entities = Cvar_Get("gl_modulate_entities", "1", 0);
758  gl_doublelight_entities = Cvar_Get("gl_doublelight_entities", "1", 0);
759  gl_fragment_program = Cvar_Get("gl_fragment_program", "1", 0);
760  gl_vertex_buffer_object = Cvar_Get("gl_vertex_buffer_object", "1", CVAR_FILES);
761  gl_vertex_buffer_object->modified = qtrue;
762  gl_fontshadow = Cvar_Get("gl_fontshadow", "0", 0);
763 
764  // development variables
765  gl_znear = Cvar_Get("gl_znear", "2", CVAR_CHEAT);
766  gl_drawworld = Cvar_Get("gl_drawworld", "1", CVAR_CHEAT);
767  gl_drawentities = Cvar_Get("gl_drawentities", "1", CVAR_CHEAT);
768  gl_drawsky = Cvar_Get("gl_drawsky", "1", 0);
769  gl_drawsky->changed = gl_drawsky_changed;
770  gl_showtris = Cvar_Get("gl_showtris", "0", CVAR_CHEAT);
771  gl_showorigins = Cvar_Get("gl_showorigins", "0", CVAR_CHEAT);
772  gl_showtearing = Cvar_Get("gl_showtearing", "0", 0);
773 #ifdef _DEBUG
774  gl_log = Cvar_Get("gl_log", "0", CVAR_CHEAT);
775  gl_showstats = Cvar_Get("gl_showstats", "0", 0);
776  gl_showscrap = Cvar_Get("gl_showscrap", "0", 0);
777  gl_nobind = Cvar_Get("gl_nobind", "0", CVAR_CHEAT);
778  gl_test = Cvar_Get("gl_test", "0", 0);
779 #endif
780  gl_cull_nodes = Cvar_Get("gl_cull_nodes", "1", 0);
781  gl_cull_models = Cvar_Get("gl_cull_models", "1", 0);
782  gl_hash_faces = Cvar_Get("gl_hash_faces", "1", 0);
783  gl_clear = Cvar_Get("gl_clear", "0", 0);
784  gl_finish = Cvar_Get("gl_finish", "0", 0);
785  gl_novis = Cvar_Get("gl_novis", "0", 0);
786  gl_novis->changed = gl_novis_changed;
787  gl_lockpvs = Cvar_Get("gl_lockpvs", "0", CVAR_CHEAT);
788  gl_lightmap = Cvar_Get("gl_lightmap", "0", CVAR_CHEAT);
789  gl_fullbright = Cvar_Get("r_fullbright", "0", CVAR_CHEAT);
791  gl_vertexlight = Cvar_Get("gl_vertexlight", "0", 0);
793  gl_polyblend = Cvar_Get("gl_polyblend", "1", 0);
794  gl_showerrors = Cvar_Get("gl_showerrors", "1", 0);
795 
796  gl_lightmap_changed(NULL);
798 
799  Cmd_AddCommand("strings", GL_Strings_f);
800  Cmd_AddMacro("gl_viewcluster", GL_ViewCluster_m);
801 }

Referenced by R_Init_GL().

◆ GL_RotateForEntity()

void GL_RotateForEntity ( vec3_t  origin,
float  scale 
)

Definition at line 305 of file main.c.

306 {
307  GLfloat matrix[16];
308 
309  matrix[0] = glr.entaxis[0][0] * scale;
310  matrix[4] = glr.entaxis[1][0] * scale;
311  matrix[8] = glr.entaxis[2][0] * scale;
312  matrix[12] = origin[0];
313 
314  matrix[1] = glr.entaxis[0][1] * scale;
315  matrix[5] = glr.entaxis[1][1] * scale;
316  matrix[9] = glr.entaxis[2][1] * scale;
317  matrix[13] = origin[1];
318 
319  matrix[2] = glr.entaxis[0][2] * scale;
320  matrix[6] = glr.entaxis[1][2] * scale;
321  matrix[10] = glr.entaxis[2][2] * scale;
322  matrix[14] = origin[2];
323 
324  matrix[3] = 0;
325  matrix[7] = 0;
326  matrix[11] = 0;
327  matrix[15] = 1;
328 
331 
332  // forced matrix upload
334 }

Referenced by GL_DrawAliasModel(), and GL_DrawBspModel().

◆ GL_SetupConfig()

static qboolean GL_SetupConfig ( void  )
static

Definition at line 808 of file main.c.

809 {
810  const char *version, *extensions;
811  GLint integer;
812  GLfloat value;
813  char *p;
814 
815  // get version string
816  version = (const char *)qglGetString(GL_VERSION);
817  if (!version || !*version) {
818  Com_EPrintf("OpenGL returned NULL version string\n");
819  return qfalse;
820  }
821 
822  // parse ES profile prefix
823  if (!strncmp(version, "OpenGL ES", 9)) {
824  version += 9;
825  if (version[0] == '-' && version[1] && version[2] && version[3] == ' ') {
826  version += 4;
827  } else if (version[0] == ' ') {
828  version += 1;
829  } else {
830  Com_EPrintf("OpenGL returned invalid version string\n");
831  return qfalse;
832  }
833  gl_config.es_profile = qtrue;
834  } else {
835  gl_config.es_profile = qfalse;
836  }
837 
838  // parse version
839  gl_config.version_major = strtoul(version, &p, 10);
840  if (*p == '.') {
841  gl_config.version_minor = strtoul(p + 1, NULL, 10);
842  } else {
844  }
845 
846  if (gl_config.version_major < 1) {
847  Com_EPrintf("OpenGL returned invalid version string\n");
848  return qfalse;
849  }
850 
851  // OpenGL 1.0 doesn't have vertex arrays
852  if (!AT_LEAST_OPENGL(1, 1) && !AT_LEAST_OPENGL_ES(1, 0)) {
853  Com_EPrintf("OpenGL version 1.1 or higher required\n");
854  return qfalse;
855  }
856 
857  // allow version override for debugging purposes
858  p = Cvar_Get("gl_versionoverride", "", CVAR_REFRESH)->string;
859  if (*p) {
860  gl_config.version_major = strtoul(p, &p, 10);
861  if (*p == '.')
862  gl_config.version_minor = strtoul(p + 1, NULL, 10);
863  else
865  }
866 
867  // get and parse extension string
868  extensions = (const char *)qglGetString(GL_EXTENSIONS);
871 
872  // initialize our 'always on' extensions
874  Com_Printf("...enabling GL_EXT_compiled_vertex_array\n");
876  } else {
877  Com_Printf("GL_EXT_compiled_vertex_array not found\n");
878  }
879 
882  qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &integer);
883  if (integer >= 2) {
884  Com_Printf("...enabling GL_ARB_multitexture (%d TMUs)\n", integer);
886  if (integer > MAX_TMUS) {
887  integer = MAX_TMUS;
888  }
889  gl_config.numTextureUnits = integer;
890  } else {
891  Com_Printf("...ignoring GL_ARB_multitexture,\n"
892  "%d TMU is not enough\n", integer);
893  }
894  } else {
895  Com_Printf("GL_ARB_multitexture not found\n");
896  }
897 
900  qglGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &value);
901  if (value >= 2) {
902  Com_Printf("...enabling GL_EXT_texture_filter_anisotropic (%.f max)\n", value);
904  gl_config.maxAnisotropy = value;
905  } else {
906  Com_Printf("...ignoring GL_EXT_texture_filter_anisotropic,\n"
907  "%.f anisotropy is not enough\n", value);
908  }
909  } else {
910  Com_Printf("GL_EXT_texture_filter_anisotropic not found\n");
911  }
912 
913  if (AT_LEAST_OPENGL(3, 0)) {
915  }
916 
918 
919  qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &integer);
920  if (integer < 256) {
921  Com_EPrintf("OpenGL reports invalid maximum texture size\n");
922  return qfalse;
923  }
924 
925  if (integer & (integer - 1)) {
926  integer = npot32(integer) >> 1;
927  }
928 
929  if (integer > MAX_TEXTURE_SIZE) {
930  integer = MAX_TEXTURE_SIZE;
931  }
932 
933  gl_config.maxTextureSize = integer;
934 
935  gl_config.colorbits = 0;
936  qglGetIntegerv(GL_RED_BITS, &integer);
937  gl_config.colorbits += integer;
938  qglGetIntegerv(GL_GREEN_BITS, &integer);
939  gl_config.colorbits += integer;
940  qglGetIntegerv(GL_BLUE_BITS, &integer);
941  gl_config.colorbits += integer;
942 
943  qglGetIntegerv(GL_DEPTH_BITS, &integer);
944  gl_config.depthbits = integer;
945 
946  qglGetIntegerv(GL_STENCIL_BITS, &integer);
947  gl_config.stencilbits = integer;
948 
949  GL_ShowErrors(__func__);
950  return qtrue;
951 }

Referenced by R_Init_GL().

◆ GL_SetupFrustum()

static void GL_SetupFrustum ( void  )
static

Definition at line 86 of file main.c.

87 {
88  vec_t angle, sf, cf;
89  vec3_t forward, left, up;
90  cplane_t *p;
91  int i;
92 
93  // right/left
94  angle = DEG2RAD(glr.fd.fov_x / 2);
95  sf = sin(angle);
96  cf = cos(angle);
97 
98  VectorScale(glr.viewaxis[0], sf, forward);
99  VectorScale(glr.viewaxis[1], cf, left);
100 
101  VectorAdd(forward, left, glr.frustumPlanes[0].normal);
102  VectorSubtract(forward, left, glr.frustumPlanes[1].normal);
103 
104  // top/bottom
105  angle = DEG2RAD(glr.fd.fov_y / 2);
106  sf = sin(angle);
107  cf = cos(angle);
108 
109  VectorScale(glr.viewaxis[0], sf, forward);
110  VectorScale(glr.viewaxis[2], cf, up);
111 
112  VectorAdd(forward, up, glr.frustumPlanes[2].normal);
113  VectorSubtract(forward, up, glr.frustumPlanes[3].normal);
114 
115  for (i = 0, p = glr.frustumPlanes; i < 4; i++, p++) {
116  p->dist = DotProduct(glr.fd.vieworg, p->normal);
117  p->type = PLANE_NON_AXIAL;
118  SetPlaneSignbits(p);
119  }
120 }

Referenced by R_RenderFrame_GL().

◆ GL_ShowErrors()

qboolean GL_ShowErrors ( const char *  func)

Definition at line 539 of file main.c.

540 {
541  GLenum err = qglGetError();
542 
543  if (err == GL_NO_ERROR) {
544  return qfalse;
545  }
546 
547  do {
548  if (gl_showerrors->integer) {
549  Com_EPrintf("%s: %s\n", func, GL_ErrorString(err));
550  }
551  } while ((err = qglGetError()) != GL_NO_ERROR);
552 
553  return qtrue;
554 }

Referenced by create_surface_vbo(), GL_InitImages(), GL_InitPrograms(), GL_LoadWorld(), GL_SetupConfig(), R_BeginFrame_GL(), R_EndFrame_GL(), and R_RenderFrame_GL().

◆ GL_Strings_f()

static void GL_Strings_f ( void  )
static

Definition at line 682 of file main.c.

683 {
684  Com_Printf("GL_VENDOR: %s\n", qglGetString(GL_VENDOR));
685  Com_Printf("GL_RENDERER: %s\n", qglGetString(GL_RENDERER));
686  Com_Printf("GL_VERSION: %s\n", qglGetString(GL_VERSION));
687  Com_Printf("GL_EXTENSIONS: %s\n", qglGetString(GL_EXTENSIONS));
688  Com_Printf("GL_MAX_TEXTURE_SIZE: %d\n", gl_config.maxTextureSize);
689  Com_Printf("GL_MAX_TEXTURE_UNITS: %d\n", gl_config.numTextureUnits);
690  Com_Printf("GL_MAX_TEXTURE_MAX_ANISOTROPY: %.f\n", gl_config.maxAnisotropy);
691  Com_Printf("GL_PFD: color(%d-bit) Z(%d-bit) stencil(%d-bit)\n",
693 }

Referenced by GL_Register().

◆ GL_Unregister()

static void GL_Unregister ( void  )
static

Definition at line 803 of file main.c.

804 {
805  Cmd_RemoveCommand("strings");
806 }

Referenced by R_Shutdown_GL().

◆ GL_ViewCluster_m()

static size_t GL_ViewCluster_m ( char *  buffer,
size_t  size 
)
static

Definition at line 695 of file main.c.

696 {
697  return Q_scnprintf(buffer, size, "%d", glr.viewcluster1);
698 }

Referenced by GL_Register().

◆ make_box_points()

static void make_box_points ( const vec3_t  origin,
vec3_t  bounds[2],
vec3_t  points[8] 
)
inlinestatic

Definition at line 170 of file main.c.

173 {
174  int i;
175 
176  for (i = 0; i < 8; i++) {
177  VectorCopy(origin, points[i]);
178  VectorMA(points[i], bounds[(i >> 0) & 1][0], glr.entaxis[0], points[i]);
179  VectorMA(points[i], bounds[(i >> 1) & 1][1], glr.entaxis[1], points[i]);
180  VectorMA(points[i], bounds[(i >> 2) & 1][2], glr.entaxis[2], points[i]);
181  }
182 
183 }

Referenced by GL_CullLocalBox().

◆ QGL_ClearErrors()

void QGL_ClearErrors ( void  )

Definition at line 531 of file main.c.

532 {
533  GLenum err;
534 
535  while ((err = qglGetError()) != GL_NO_ERROR)
536  ;
537 }

Referenced by create_surface_vbo(), and GL_InitPrograms().

◆ R_AddDecal_GL()

void R_AddDecal_GL ( decal_t *  d)

Definition at line 1144 of file main.c.

1144 {}

Referenced by R_RegisterFunctionsGL().

◆ R_BeginFrame_GL()

void R_BeginFrame_GL ( void  )

Definition at line 618 of file main.c.

619 {
620 #ifdef _DEBUG
621  if (gl_log->integer) {
622  QGL_LogComment("\n*** R_BeginFrame ***\n");
623  }
624 #endif
625 
626  memset(&c, 0, sizeof(c));
627 
628  if (gl_finish->integer) {
629  qglFinish();
630  }
631 
632  GL_Setup2D();
633 
634  if (gl_clear->integer) {
635  qglClear(GL_COLOR_BUFFER_BIT);
636  }
637 
638  GL_ShowErrors(__func__);
639 }

Referenced by R_RegisterFunctionsGL().

◆ R_BeginRegistration_GL()

void R_BeginRegistration_GL ( const char *  name)

Definition at line 1105 of file main.c.

1106 {
1107  char fullname[MAX_QPATH];
1108 
1109  gl_static.registering = qtrue;
1111 
1112  memset(&glr, 0, sizeof(glr));
1114 
1115  Q_concat(fullname, sizeof(fullname), "maps/", name, ".bsp", NULL);
1116  GL_LoadWorld(fullname);
1117 }

Referenced by R_RegisterFunctionsGL().

◆ R_EndFrame_GL()

void R_EndFrame_GL ( void  )

Definition at line 641 of file main.c.

642 {
643 #ifdef _DEBUG
644  if (gl_showstats->integer) {
645  GL_Flush2D();
646  Draw_Stats();
647  }
648  if (gl_showscrap->integer) {
649  Draw_Scrap();
650  }
651 #endif
652  GL_Flush2D();
653 
654  if (gl_showtearing->integer) {
655  GL_DrawTearing();
656  }
657 
658  // enable/disable fragment programs on the fly
659  if (gl_fragment_program->modified) {
661  GL_InitPrograms();
662  gl_fragment_program->modified = qfalse;
663  }
664 
665  GL_ShowErrors(__func__);
666 
667 #ifdef _DEBUG
668  if (gl_log->modified) {
669  if (gl_log->integer)
670  QGL_EnableLogging(gl_config.ext_enabled);
671  else
672  QGL_DisableLogging(gl_config.ext_enabled);
673  gl_log->modified = qfalse;
674  }
675 #endif
676 
677  VID_EndFrame();
678 }

Referenced by R_RegisterFunctionsGL().

◆ R_EndRegistration_GL()

void R_EndRegistration_GL ( void  )

Definition at line 1124 of file main.c.

1125 {
1126  IMG_FreeUnused();
1127  MOD_FreeUnused();
1128  Scrap_Upload();
1129  gl_static.registering = qfalse;
1130 }

Referenced by R_RegisterFunctionsGL().

◆ R_Init_GL()

qboolean R_Init_GL ( qboolean  total)

Definition at line 1007 of file main.c.

1008 {
1009  Com_DPrintf("GL_Init( %i )\n", total);
1010 
1011  if (!total) {
1012  GL_PostInit();
1013  return qtrue;
1014  }
1015 
1016  Com_Printf("------- R_Init -------\n");
1017  Com_DPrintf("ref_gl " VERSION_STRING ", " __DATE__ "\n");
1018 
1019  // initialize OS-specific parts of OpenGL
1020  // create the window and set up the context
1021  if (!VID_Init(GAPI_OPENGL)) {
1022  return qfalse;
1023  }
1024 
1025  // initialize our QGL dynamic bindings
1026  if (!QGL_Init()) {
1027  goto fail;
1028  }
1029 
1030  // initialize extensions and get various limits from OpenGL
1031  if (!GL_SetupConfig()) {
1032  goto fail;
1033  }
1034 
1035  // register our variables
1036  GL_Register();
1037 
1038 #ifdef _DEBUG
1039  if (gl_log->integer) {
1040  QGL_EnableLogging(gl_config.ext_enabled);
1041  }
1042  gl_log->modified = qfalse;
1043 #endif
1044 
1045  GL_PostInit();
1046 
1047  GL_InitPrograms();
1048  gl_fragment_program->modified = qfalse;
1049 
1050  GL_InitTables();
1051 
1052  Com_Printf("----------------------\n");
1053 
1054  return qtrue;
1055 
1056 fail:
1057  memset(&gl_config, 0, sizeof(gl_config));
1058  QGL_Shutdown();
1059  VID_Shutdown();
1060  return qfalse;
1061 }

Referenced by R_RegisterFunctionsGL().

◆ R_InterceptKey_GL()

qboolean R_InterceptKey_GL ( unsigned  key,
qboolean  down 
)

Definition at line 1145 of file main.c.

1145 { return qfalse; }

Referenced by R_RegisterFunctionsGL().

◆ R_ModeChanged_GL()

void R_ModeChanged_GL ( int  width,
int  height,
int  flags,
int  rowbytes,
void pixels 
)

Definition at line 1137 of file main.c.

1138 {
1139  r_config.width = width;
1140  r_config.height = height;
1141  r_config.flags = flags;
1142 }

Referenced by R_RegisterFunctionsGL().

◆ R_RegisterFunctionsGL()

◆ R_RenderFrame_GL()

void R_RenderFrame_GL ( refdef_t *  fd)

Definition at line 556 of file main.c.

557 {
558  GL_Flush2D();
559 
560  if (!gl_static.world.cache && !(fd->rdflags & RDF_NOWORLDMODEL)) {
561  Com_Error(ERR_FATAL, "%s: NULL worldmodel", __func__);
562  }
563 
564  glr.drawframe++;
565 
566  glr.fd = *fd;
567  glr.num_beams = 0;
568 
569 #if USE_DLIGHTS
570  if (gl_dynamic->integer != 1 || gl_vertexlight->integer) {
571  glr.fd.num_dlights = 0;
572  }
573 #endif
574 
575  if (lm.dirty) {
577  lm.dirty = qfalse;
578  }
579 
580  GL_Setup3D();
581 
582  if (gl_cull_nodes->integer) {
583  GL_SetupFrustum();
584  }
585 
586  if (!(glr.fd.rdflags & RDF_NOWORLDMODEL) && gl_drawworld->integer) {
587  GL_DrawWorld();
588  }
589 
590  GL_DrawEntities(0);
591 
592  GL_DrawBeams();
593 
595 
596  GL_DrawEntities(RF_TRANSLUCENT);
597 
598  if (!(glr.fd.rdflags & RDF_NOWORLDMODEL)) {
600  }
601 
602  // go back into 2D mode
603  GL_Setup2D();
604 
605  if (gl_polyblend->integer && glr.fd.blend[3] != 0) {
606  GL_Blend();
607  }
608 
609 #ifdef _DEBUG
610  if (gl_lightmap->integer > 1) {
611  Draw_Lightmaps();
612  }
613 #endif
614 
615  GL_ShowErrors(__func__);
616 }

Referenced by R_RegisterFunctionsGL().

◆ R_Shutdown_GL()

void R_Shutdown_GL ( qboolean  total)

Definition at line 1068 of file main.c.

1069 {
1070  Com_DPrintf("GL_Shutdown( %i )\n", total);
1071 
1072  GL_FreeWorld();
1074  MOD_Shutdown();
1075 
1076  if (gl_vertex_buffer_object->modified) {
1077  // disable buffer objects after map is freed
1080  }
1081 
1082  if (!total) {
1083  return;
1084  }
1085 
1087 
1088  // shut down OS specific OpenGL stuff like contexts, etc.
1089  VID_Shutdown();
1090 
1091  // shutdown our QGL subsystem
1092  QGL_Shutdown();
1093 
1094  GL_Unregister();
1095 
1096  memset(&gl_static, 0, sizeof(gl_static));
1097  memset(&gl_config, 0, sizeof(gl_config));
1098 }

Referenced by R_RegisterFunctionsGL().

Variable Documentation

◆ c

Definition at line 30 of file main.c.

Referenced by AC_FreeChecks(), AC_SendChecks(), BSP_ClusterVis(), CheckBlock(), CL_ConnectionlessPacket(), CL_GetDemoInfo(), CL_Heatbeam(), CL_OldRailTrail(), CL_RailSpiral(), CL_Record_f(), CL_WriteConfig_f(), clamp_output(), CM_InitBoxHull(), Cmd_EchoEx_f(), Cmd_UnAlias_f(), COM_Compress(), Com_Generic_c(), Com_HashString(), Com_HashStringLen(), COM_IsFloat(), COM_IsPath(), COM_IsUint(), COM_IsWhite(), COM_Parse(), COM_strclr(), compute_cluster_aabbs(), Con_DrawLine(), Con_Paste(), cull_lerped_model(), cull_static_model(), Cvar_BitInfo(), Cvar_Default_g(), Cvar_Get(), Cvar_List_f(), Cvar_Set_f(), Cvar_Variable_g(), D_FlushCaches(), draw_alias_mesh(), draw_char(), dummy_find_slot(), escape_path(), format_mask(), FS_NormalizePath(), FS_UnLink_f(), G_FindTeams(), get_emissive_shell(), GL_BindTexture(), GL_ColorInvertTexture(), GL_DrawBspModel(), GL_DrawFace(), GL_DrawLeaf(), GL_DrawNode(), GL_Flush2D(), GL_Flush3D(), GL_ForceTexture(), GL_GrayScaleTexture(), GL_LightScaleTexture(), GL_MarkLeaves(), GL_TextureAnimation(), GL_TextureHasAlpha(), GL_Upload32(), GL_WorldNode_r(), IMG_Load(), Info_SetValueForKey(), Info_SubValidate(), Info_Validate(), inject_model_lights(), Key_Bind_f(), KeyDown(), KeyUp(), left_of(), LM_RebuildSurfaces(), logfile_write(), MSG_ReadByte(), MSG_ReadChar(), MSG_ReadLong(), MSG_ReadShort(), MSG_ReadString(), MSG_ReadStringLine(), MSG_ReadWord(), MSG_WriteByte(), MSG_WriteChar(), MSG_WriteLong(), MSG_WriteShort(), MVD_Connect_f(), MVD_Control_f(), MVD_CountClients(), MVD_Play_f(), MVD_StreamedRecord_f(), needs_quotes(), Parse_Action(), Parse_Bind(), Parse_Bitmap(), Parse_Color(), parse_CSV_line(), Parse_Field(), parse_ignore_nick(), Parse_Pairs(), Parse_Range(), Parse_Savegame(), Parse_Spin(), Parse_Style(), Parse_Toggle(), Q_memccpy(), Q_strchrnul(), R_BeginFrame_GL(), R_DrawChar_GL(), R_DrawChar_RTX(), R_DrawFill32(), R_DrawFill8(), R_DrawFill8_GL(), R_DrawFill8_RTX(), R_DrawString(), R_DrawString_GL(), R_DrawString_RTX(), R_IMFlatShadedQuad(), R_LightScaleTexture(), R_RecursiveWorldNode(), R_TextureAnimation(), sample_spherical_lights(), SCR_Draw_f(), SCR_LagDraw(), SCR_ParseColor(), SetupRotationMatrix(), SV_ConnectionlessPacket(), SV_CvarResult_f(), SV_DumpEnts_f(), SV_ExecuteClientMessage(), SV_ExecuteUserCommand(), SV_MvdRecord_f(), SV_NewClientExecuteMove(), SV_StuffCvar_f(), SZ_WriteByte(), SZ_WriteLong(), SZ_WriteShort(), target_string_use(), TH_DrawString(), UI_DrawRect8(), UnionBounds(), update_dynamic_lightmap(), and validate_char().

◆ gl_brightness

cvar_t* gl_brightness

Definition at line 45 of file main.c.

Referenced by CL_Begin(), CL_ClearState(), gl_lightmap_changed(), and GL_Register().

◆ gl_celshading

cvar_t* gl_celshading

Definition at line 39 of file main.c.

Referenced by draw_celshading(), GL_Register(), and setup_celshading().

◆ gl_clear

cvar_t* gl_clear

Definition at line 73 of file main.c.

Referenced by GL_Register(), and R_BeginFrame_GL().

◆ gl_coloredlightmaps

cvar_t* gl_coloredlightmaps

Definition at line 44 of file main.c.

Referenced by gl_lightmap_changed(), and GL_Register().

◆ gl_config

◆ gl_cull_models

cvar_t* gl_cull_models

Definition at line 72 of file main.c.

Referenced by GL_CullBox(), GL_CullLocalBox(), GL_CullSphere(), and GL_Register().

◆ gl_cull_nodes

cvar_t* gl_cull_nodes

Definition at line 71 of file main.c.

Referenced by GL_DrawWorld(), GL_Register(), and R_RenderFrame_GL().

◆ gl_dotshading

cvar_t* gl_dotshading

Definition at line 40 of file main.c.

Referenced by GL_Register(), and setup_dotshading().

◆ gl_doublelight_entities

cvar_t* gl_doublelight_entities

Definition at line 51 of file main.c.

Referenced by GL_LightPoint(), and GL_Register().

◆ gl_drawentities

cvar_t* gl_drawentities

Definition at line 59 of file main.c.

Referenced by GL_DrawEntities(), and GL_Register().

◆ gl_drawsky

cvar_t* gl_drawsky

Definition at line 60 of file main.c.

Referenced by GL_Register(), and R_SetSky_GL().

◆ gl_drawworld

cvar_t* gl_drawworld

Definition at line 58 of file main.c.

Referenced by GL_Register(), and R_RenderFrame_GL().

◆ gl_dynamic

cvar_t* gl_dynamic

◆ gl_finish

cvar_t* gl_finish

Definition at line 74 of file main.c.

Referenced by GL_Register(), and R_BeginFrame_GL().

◆ gl_fontshadow

cvar_t* gl_fontshadow

Definition at line 54 of file main.c.

Referenced by draw_char(), and GL_Register().

◆ gl_fragment_program

cvar_t* gl_fragment_program

Definition at line 52 of file main.c.

Referenced by GL_InitPrograms(), GL_Register(), R_EndFrame_GL(), and R_Init_GL().

◆ gl_fullbright

cvar_t* gl_fullbright

◆ gl_hash_faces

cvar_t* gl_hash_faces

Definition at line 75 of file main.c.

Referenced by GL_DrawNode(), and GL_Register().

◆ gl_lightmap

cvar_t* gl_lightmap

Definition at line 78 of file main.c.

Referenced by GL_BindArrays(), GL_DrawFace(), GL_Register(), and R_RenderFrame_GL().

◆ gl_lockpvs

cvar_t* gl_lockpvs

Definition at line 77 of file main.c.

Referenced by GL_MarkLeaves(), and GL_Register().

◆ gl_modulate

cvar_t* gl_modulate

Definition at line 42 of file main.c.

Referenced by gl_lightmap_changed(), gl_modulate_entities_changed(), and GL_Register().

◆ gl_modulate_entities

cvar_t* gl_modulate_entities

Definition at line 50 of file main.c.

Referenced by CL_Begin(), CL_ClearState(), gl_modulate_entities_changed(), and GL_Register().

◆ gl_modulate_world

cvar_t* gl_modulate_world

Definition at line 43 of file main.c.

Referenced by CL_Begin(), CL_ClearState(), gl_lightmap_changed(), and GL_Register().

◆ gl_novis

cvar_t* gl_novis

Definition at line 76 of file main.c.

Referenced by GL_MarkLeaves(), and GL_Register().

◆ gl_partscale

cvar_t* gl_partscale

Definition at line 37 of file main.c.

Referenced by GL_DrawParticles(), and GL_Register().

◆ gl_partstyle

cvar_t* gl_partstyle

Definition at line 38 of file main.c.

Referenced by GL_DrawParticles(), and GL_Register().

◆ gl_polyblend

cvar_t* gl_polyblend

Definition at line 81 of file main.c.

Referenced by GL_Register(), and R_RenderFrame_GL().

◆ gl_shadows

cvar_t* gl_shadows

Definition at line 41 of file main.c.

Referenced by GL_Register(), and setup_shadow().

◆ gl_showerrors

cvar_t* gl_showerrors

Definition at line 82 of file main.c.

Referenced by GL_Register(), and GL_ShowErrors().

◆ gl_showorigins

cvar_t* gl_showorigins

Definition at line 62 of file main.c.

Referenced by GL_DrawEntities(), and GL_Register().

◆ gl_showtearing

cvar_t* gl_showtearing

Definition at line 63 of file main.c.

Referenced by GL_Register(), and R_EndFrame_GL().

◆ gl_showtris

cvar_t* gl_showtris

Definition at line 61 of file main.c.

Referenced by draw_alias_mesh(), GL_DrawParticles(), GL_Flush2D(), GL_Flush3D(), and GL_Register().

◆ gl_static

◆ gl_vertex_buffer_object

cvar_t* gl_vertex_buffer_object

Definition at line 53 of file main.c.

Referenced by GL_PostInit(), GL_Register(), and R_Shutdown_GL().

◆ gl_vertexlight

cvar_t* gl_vertexlight

◆ gl_world

entity_t gl_world

Definition at line 32 of file main.c.

Referenced by GL_DrawAlphaFaces(), and GL_DrawWorld().

◆ gl_znear

cvar_t* gl_znear

Definition at line 57 of file main.c.

Referenced by GL_Frustum(), and GL_Register().

◆ glr

◆ registration_sequence

IMG_ReadPixels
byte * IMG_ReadPixels(int *width, int *height, int *rowbytes)
Definition: main.c:768
gl_lockpvs
cvar_t * gl_lockpvs
Definition: main.c:77
R_TileClear
void(* R_TileClear)(int x, int y, int w, int h, qhandle_t pic)
Definition: refresh.c:421
MOD_Reference
void(* MOD_Reference)(model_t *model)
Definition: refresh.c:438
QGL_3_0_core_functions
#define QGL_3_0_core_functions
Definition: dynamic.h:161
R_EndRegistration
void(* R_EndRegistration)(void)
Definition: refresh.c:407
Cvar_Set
cvar_t * Cvar_Set(const char *var_name, const char *value)
Definition: cvar.c:466
CL_SetSky
void CL_SetSky(void)
Definition: precache.c:306
R_SetAlphaScale_GL
void R_SetAlphaScale_GL(float alpha)
Definition: draw.c:104
r_config
refcfg_t r_config
Definition: main.c:24
glStatic_t::entity_modulate
float entity_modulate
Definition: gl.h:71
R_SetColor
void(* R_SetColor)(uint32_t color)
Definition: refresh.c:413
gl_dynamic
cvar_t * gl_dynamic
Definition: main.c:46
R_InterceptKey
qboolean(* R_InterceptKey)(unsigned key, qboolean down)
Definition: refresh.c:428
glConfig_t::version_major
int version_major
Definition: gl.h:103
gl_fragment_program
cvar_t * gl_fragment_program
Definition: main.c:52
R_SetClipRect_GL
void R_SetClipRect_GL(const clipRect_t *clip)
Definition: draw.c:115
GL_InitPrograms
void GL_InitPrograms(void)
Definition: state.c:477
GL_InitImages
void GL_InitImages(void)
Definition: images.c:855
gl_partscale
cvar_t * gl_partscale
Definition: main.c:37
lm
lightmap_builder_t lm
Definition: surf.c:25
gl_modulate_world
cvar_t * gl_modulate_world
Definition: main.c:43
R_SetSky
void(* R_SetSky)(const char *name, float rotate, vec3_t axis)
Definition: refresh.c:406
R_SetAlpha
void(* R_SetAlpha)(float clpha)
Definition: refresh.c:411
height
static int height
Definition: physical_sky.c:39
R_RenderFrame_GL
void R_RenderFrame_GL(refdef_t *fd)
Definition: main.c:556
GL_DrawTearing
static void GL_DrawTearing(void)
Definition: main.c:495
gl_dotshading
cvar_t * gl_dotshading
Definition: main.c:40
image_t
struct image_s image_t
Definition: material.h:27
gl_config
glConfig_t gl_config
Definition: main.c:29
lightmap_builder_t::comp
int comp
Definition: gl.h:262
MOD_ForHandle
model_t * MOD_ForHandle(qhandle_t h)
Definition: models.c:430
Cmd_AddCommand
void Cmd_AddCommand(const char *name, xcommand_t function)
Definition: cmd.c:1562
MOD_LoadMD3_GL
qerror_t MOD_LoadMD3_GL(model_t *model, const void *rawdata, size_t length)
gl_cull_models
cvar_t * gl_cull_models
Definition: main.c:72
IMG_Load
void(* IMG_Load)(image_t *image, byte *pic)
Definition: refresh.c:431
GL_ErrorString
static const char * GL_ErrorString(GLenum err)
Definition: main.c:511
glConfig_t::maxTextureSize
int maxTextureSize
Definition: gl.h:109
qglGetError
#define qglGetError
Definition: fixed.h:67
R_ModeChanged_GL
void R_ModeChanged_GL(int width, int height, int flags, int rowbytes, void *pixels)
Definition: main.c:1137
glStatic_t::cache
bsp_t * cache
Definition: gl.h:62
Cvar_Get
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
Definition: cvar.c:257
R_BeginRegistration_GL
void R_BeginRegistration_GL(const char *name)
Definition: main.c:1105
c
statCounters_t c
Definition: main.c:30
glr
glRefdef_t glr
Definition: main.c:27
MOD_Init
void MOD_Init(void)
Definition: models.c:450
gl_polyblend
cvar_t * gl_polyblend
Definition: main.c:81
IMG_Load_GL
void IMG_Load_GL(image_t *image, byte *pic)
Definition: images.c:618
glRefdef_t::entrotated
qboolean entrotated
Definition: gl.h:93
R_ClearColor
void(* R_ClearColor)(void)
Definition: refresh.c:410
glConfig_t::depthbits
int depthbits
Definition: gl.h:114
glConfig_t::version_minor
int version_minor
Definition: gl.h:104
MOD_Reference_GL
void MOD_Reference_GL(model_t *model)
Definition: models.c:425
R_LightPoint
void(* R_LightPoint)(vec3_t origin, vec3_t light)
Definition: refresh.c:409
GL_DrawParticles
void GL_DrawParticles(void)
Definition: tess.c:79
R_ClearColor_GL
void R_ClearColor_GL(void)
Definition: draw.c:92
VID_EndFrame
void VID_EndFrame(void)
Definition: glimp.c:516
GL_SetupFrustum
static void GL_SetupFrustum(void)
Definition: main.c:86
R_SetScale_GL
void R_SetScale_GL(float scale)
Definition: draw.c:157
QGL_Shutdown
#define QGL_Shutdown()
Definition: fixed.h:152
qglClearColor
#define qglClearColor
Definition: fixed.h:40
qglColor4f
#define qglColor4f
Definition: fixed.h:43
lightmap_builder_t::scale
float scale
Definition: gl.h:263
GL_Register
static void GL_Register(void)
Definition: main.c:735
gl_fontshadow
cvar_t * gl_fontshadow
Definition: main.c:54
glStatic_t::sintab
float sintab[256]
Definition: gl.h:75
make_box_points
static void make_box_points(const vec3_t origin, vec3_t bounds[2], vec3_t points[8])
Definition: main.c:170
GL_BindTexture
void GL_BindTexture(GLuint tmu, GLuint texnum)
Definition: state.c:40
R_BeginFrame_GL
void R_BeginFrame_GL(void)
Definition: main.c:618
R_DrawString_GL
int R_DrawString_GL(int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font)
Definition: draw.c:247
gl_showtearing
cvar_t * gl_showtearing
Definition: main.c:63
R_DrawFill8
void(* R_DrawFill8)(int x, int y, int w, int h, int c)
Definition: refresh.c:422
GL_ShutdownPrograms
void GL_ShutdownPrograms(void)
Definition: state.c:518
R_Shutdown
void R_Shutdown(qboolean total)
Definition: main.c:280
glRefdef_t::num_beams
int num_beams
Definition: gl.h:97
GLS_BLEND_BLEND
@ GLS_BLEND_BLEND
Definition: gl.h:285
R_SetSky_GL
void R_SetSky_GL(const char *name, float rotate, vec3_t axis)
Definition: sky.c:382
R_EndFrame
void R_EndFrame(void)
Definition: main.c:863
glConfig_t::ext_supported
unsigned ext_supported
Definition: gl.h:106
R_DrawPic_GL
void R_DrawPic_GL(int x, int y, qhandle_t pic)
Definition: draw.c:179
infront
qboolean infront(edict_t *self, edict_t *other)
Definition: g_ai.c:293
glConfig_t::numTextureUnits
int numTextureUnits
Definition: gl.h:110
GL_ViewCluster_m
static size_t GL_ViewCluster_m(char *buffer, size_t size)
Definition: main.c:695
GLA_VERTEX
@ GLA_VERTEX
Definition: gl.h:301
gl_lightmap_changed
static void gl_lightmap_changed(cvar_t *self)
Definition: main.c:700
GL_DrawAlphaFaces
void GL_DrawAlphaFaces(void)
Definition: tess.c:445
GL_Strings_f
static void GL_Strings_f(void)
Definition: main.c:682
gl_coloredlightmaps
cvar_t * gl_coloredlightmaps
Definition: main.c:44
E
#define E(x)
GL_Flush2D
void GL_Flush2D(void)
Definition: tess.c:31
GL_DrawNullModel
static void GL_DrawNullModel(void)
Definition: main.c:391
gl_cull_nodes
cvar_t * gl_cull_nodes
Definition: main.c:71
R_Shutdown_GL
void R_Shutdown_GL(qboolean total)
Definition: main.c:1068
MOD_FreeUnused
void MOD_FreeUnused(void)
Definition: models.c:105
qglClear
#define qglClear
Definition: fixed.h:39
R_SetAlphaScale
void(* R_SetAlphaScale)(float alpha)
Definition: refresh.c:412
R_EndFrame_GL
void R_EndFrame_GL(void)
Definition: main.c:641
gls
glState_t gls
Definition: state.c:22
R_DrawFill32_GL
void R_DrawFill32_GL(int x, int y, int w, int h, uint32_t color)
Definition: draw.c:202
width
static int width
Definition: physical_sky.c:38
GL_Unregister
static void GL_Unregister(void)
Definition: main.c:803
gl_hash_faces
cvar_t * gl_hash_faces
Definition: main.c:75
gl_modulate_entities_changed
static void gl_modulate_entities_changed(cvar_t *self)
Definition: main.c:712
MOD_LoadMD2_GL
qerror_t MOD_LoadMD2_GL(model_t *model, const void *rawdata, size_t length)
Definition: models.c:32
R_Init
qboolean R_Init(qboolean total)
Definition: main.c:234
R_DrawChar_GL
void R_DrawChar_GL(int x, int y, int flags, int c, qhandle_t font)
Definition: draw.c:242
GL_SetupConfig
static qboolean GL_SetupConfig(void)
Definition: main.c:808
GL_ArrayBits
void GL_ArrayBits(glArrayBits_t bits)
Definition: state.c:185
GL_DrawWorld
void GL_DrawWorld(void)
Definition: world.c:552
Com_Error
void Com_Error(error_type_t type, const char *fmt,...)
Definition: g_main.c:258
Cmd_RemoveCommand
void Cmd_RemoveCommand(const char *name)
Definition: cmd.c:1593
gl_showerrors
cvar_t * gl_showerrors
Definition: main.c:82
Scrap_Upload
void Scrap_Upload(void)
Definition: images.c:220
AT_LEAST_OPENGL_ES
#define AT_LEAST_OPENGL_ES(major, minor)
Definition: gl.h:124
gl_modulate_entities
cvar_t * gl_modulate_entities
Definition: main.c:50
MOD_LoadMD2
qerror_t(* MOD_LoadMD2)(model_t *model, const void *rawdata, size_t length)
Definition: refresh.c:434
forward
static vec3_t forward
Definition: p_view.c:27
gl_drawworld
cvar_t * gl_drawworld
Definition: main.c:58
qglFinish
#define qglFinish
Definition: fixed.h:60
glRefdef_t::viewaxis
vec3_t viewaxis[3]
Definition: gl.h:82
gl_static
glStatic_t gl_static
Definition: main.c:28
AT_LEAST_OPENGL
#define AT_LEAST_OPENGL(major, minor)
Definition: gl.h:121
glStatic_t::world
struct glStatic_t::@11 world
Cvar_ClampValue
float Cvar_ClampValue(cvar_t *var, float min, float max)
Definition: cvar.c:571
glRefdef_t::frustumPlanes
cplane_t frustumPlanes[4]
Definition: gl.h:91
GL_MultMatrix
void GL_MultMatrix(GLfloat *p, const GLfloat *a, const GLfloat *b)
Definition: main.c:290
GL_RebuildLighting
void GL_RebuildLighting(void)
Definition: surf.c:836
glStatic_t::latlngtab
byte latlngtab[NUMVERTEXNORMALS][2]
Definition: gl.h:76
R_DrawPic
void(* R_DrawPic)(int x, int y, qhandle_t pic)
Definition: refresh.c:419
GL_ColorBytePointer
static void GL_ColorBytePointer(GLint size, GLsizei stride, const GLubyte *pointer)
Definition: gl.h:351
gl_vertex_buffer_object
cvar_t * gl_vertex_buffer_object
Definition: main.c:53
R_SetAlpha_GL
void R_SetAlpha_GL(float alpha)
Definition: draw.c:98
gl_clear
cvar_t * gl_clear
Definition: main.c:73
glRefdef_t::entmatrix
GLfloat entmatrix[16]
Definition: gl.h:95
GL_Setup3D
void GL_Setup3D(void)
Definition: state.c:362
gl_doublelight_entities
cvar_t * gl_doublelight_entities
Definition: main.c:51
R_RenderFrame
void R_RenderFrame(refdef_t *fd)
Definition: main.c:803
glConfig_t::colorbits
int colorbits
Definition: gl.h:113
VID_Shutdown
void VID_Shutdown(void)
Definition: glimp.c:54
gl_drawsky_changed
static void gl_drawsky_changed(cvar_t *self)
Definition: main.c:724
GL_TexCoordPointer
static void GL_TexCoordPointer(GLint size, GLsizei stride, const GLfloat *pointer)
Definition: gl.h:339
origin
static vec3_t origin
Definition: mesh.c:27
R_DrawString
int(* R_DrawString)(int x, int y, int flags, size_t maxChars, const char *string, qhandle_t font)
Definition: refresh.c:417
GL_DrawBspModel
void GL_DrawBspModel(mmodel_t *model)
Definition: world.c:358
GL_ShowErrors
qboolean GL_ShowErrors(const char *func)
Definition: main.c:539
R_EndRegistration_GL
void R_EndRegistration_GL(void)
Definition: main.c:1124
glRefdef_t::viewmatrix
GLfloat viewmatrix[16]
Definition: gl.h:83
QGL_ShutdownExtensions
void QGL_ShutdownExtensions(unsigned mask)
Definition: dynamic.c:643
gl_novis
cvar_t * gl_novis
Definition: main.c:76
lightmap_builder_t::dirty
qboolean dirty
Definition: gl.h:261
gl_znear
cvar_t * gl_znear
Definition: main.c:57
SetPlaneSignbits
void SetPlaneSignbits(cplane_t *plane)
Definition: math.c:298
qglGetIntegerv
#define qglGetIntegerv
Definition: fixed.h:69
CULL_IN
@ CULL_IN
Definition: gl.h:192
R_AddDecal
void R_AddDecal(decal_t *d)
Definition: main.c:923
R_DrawFill32
void(* R_DrawFill32)(int x, int y, int w, int h, uint32_t color)
Definition: refresh.c:423
gl_vertexlight
cvar_t * gl_vertexlight
Definition: main.c:80
IMG_Unload
void(* IMG_Unload)(image_t *image)
Definition: refresh.c:430
R_Init_GL
qboolean R_Init_GL(qboolean total)
Definition: main.c:1007
VID_Init
qboolean VID_Init(void)
Definition: glimp.c:430
GLS_DEFAULT
@ GLS_DEFAULT
Definition: gl.h:282
qglGetString
#define qglGetString
Definition: fixed.h:70
qglDrawArrays
#define qglDrawArrays
Definition: fixed.h:56
qglLoadMatrixf
#define qglLoadMatrixf
Definition: fixed.h:80
GL_Setup2D
void GL_Setup2D(void)
Definition: state.c:263
R_DrawStretchPic_GL
void R_DrawStretchPic_GL(int x, int y, int w, int h, qhandle_t pic)
Definition: draw.c:171
gl_finish
cvar_t * gl_finish
Definition: main.c:74
gl_drawsky
cvar_t * gl_drawsky
Definition: main.c:60
MOD_Shutdown
void MOD_Shutdown(void)
Definition: models.c:459
QGL_ARB_vertex_buffer_object
#define QGL_ARB_vertex_buffer_object
Definition: dynamic.h:157
MAX_TMUS
#define MAX_TMUS
Definition: gl.h:52
GL_DrawBeams
void GL_DrawBeams(void)
Definition: tess.c:164
R_InterceptKey_GL
qboolean R_InterceptKey_GL(unsigned key, qboolean down)
Definition: main.c:1145
gl_modulate
cvar_t * gl_modulate
Definition: main.c:42
GLA_TC
@ GLA_TC
Definition: gl.h:302
R_ModeChanged
void R_ModeChanged(int width, int height, int flags, int rowbytes, void *pixels)
Definition: main.c:191
gl_showorigins
cvar_t * gl_showorigins
Definition: main.c:62
lightmap_builder_t::modulate
float modulate
Definition: gl.h:263
TEXNUM_WHITE
#define TEXNUM_WHITE
Definition: gl.h:443
R_SetColor_GL
void R_SetColor_GL(uint32_t color)
Definition: draw.c:109
registration_sequence
int registration_sequence
Definition: main.c:34
GL_VertexPointer
static void GL_VertexPointer(GLint size, GLsizei stride, const GLfloat *pointer)
Definition: gl.h:334
up
static vec3_t up
Definition: p_view.c:27
glConfig_t::ext_enabled
unsigned ext_enabled
Definition: gl.h:107
GL_ShutdownImages
void GL_ShutdownImages(void)
Definition: images.c:940
right
static vec3_t right
Definition: p_view.c:27
GL_SetDefaultState
void GL_SetDefaultState(void)
Definition: state.c:377
QGL_InitExtensions
void QGL_InitExtensions(unsigned mask)
Definition: dynamic.c:683
R_BeginRegistration
void(* R_BeginRegistration)(const char *map)
Definition: refresh.c:405
GL_LoadMatrix
static void GL_LoadMatrix(const GLfloat *matrix)
Definition: gl.h:375
GLA_COLOR
@ GLA_COLOR
Definition: gl.h:304
R_SetClipRect
void(* R_SetClipRect)(const clipRect_t *clip)
Definition: refresh.c:414
gl_lightmap
cvar_t * gl_lightmap
Definition: main.c:78
R_DrawStretchPic
void(* R_DrawStretchPic)(int x, int y, int w, int h, qhandle_t pic)
Definition: refresh.c:420
glRefdef_t::viewcluster1
int viewcluster1
Definition: gl.h:89
glStatic_t::registering
qboolean registering
Definition: gl.h:60
QGL_ARB_multitexture
#define QGL_ARB_multitexture
Definition: dynamic.h:156
gl_partstyle
cvar_t * gl_partstyle
Definition: main.c:38
gl_celshading
cvar_t * gl_celshading
Definition: main.c:39
QGL_ParseExtensionString
unsigned QGL_ParseExtensionString(const char *s)
Definition: dynamic.c:712
err
int err
Definition: win.h:24
R_AddDecal_GL
void R_AddDecal_GL(decal_t *d)
Definition: main.c:1144
R_SetScale
void(* R_SetScale)(float scale)
Definition: refresh.c:415
R_DrawFill8_GL
void R_DrawFill8_GL(int x, int y, int w, int h, int c)
Definition: draw.c:195
lightmap_builder_t::add
float add
Definition: gl.h:263
gl_novis_changed
static void gl_novis_changed(cvar_t *self)
Definition: main.c:730
R_LightPoint_GL
void R_LightPoint_GL(vec3_t origin, vec3_t color)
Definition: world.c:254
QGL_EXT_texture_filter_anisotropic
#define QGL_EXT_texture_filter_anisotropic
Definition: dynamic.h:159
R_DrawChar
void(* R_DrawChar)(int x, int y, int flags, int ch, qhandle_t font)
Definition: refresh.c:416
Cmd_AddMacro
void Cmd_AddMacro(const char *name, xmacro_t function)
Definition: cmd.c:770
GL_Blend
void GL_Blend(void)
Definition: draw.c:79
GLS_ALPHATEST_ENABLE
@ GLS_ALPHATEST_ENABLE
Definition: gl.h:288
IMG_FreeUnused
void IMG_FreeUnused(void)
Definition: images.c:1310
Q_concat
size_t Q_concat(char *dest, size_t size,...)
Definition: shared.c:758
gl_shadows
cvar_t * gl_shadows
Definition: main.c:41
qglGetFloatv
#define qglGetFloatv
Definition: fixed.h:68
glRefdef_t::entaxis
vec3_t entaxis[3]
Definition: gl.h:94
glState_t::currentmatrix
const GLfloat * currentmatrix
Definition: gl.h:313
GL_LoadWorld
void GL_LoadWorld(const char *name)
Definition: surf.c:876
R_BeginFrame
void R_BeginFrame(void)
Definition: main.c:858
glCullResult_t
glCullResult_t
Definition: gl.h:190
GL_PostInit
static void GL_PostInit(void)
Definition: main.c:972
bytedirs
const vec3_t bytedirs[NUMVERTEXNORMALS]
Definition: math.c:80
gl_brightness
cvar_t * gl_brightness
Definition: main.c:45
GLS_DEPTHMASK_FALSE
@ GLS_DEPTHMASK_FALSE
Definition: gl.h:283
IMG_Unload_GL
void IMG_Unload_GL(image_t *image)
Definition: images.c:679
glRefdef_t::viewcluster2
int viewcluster2
Definition: gl.h:90
IMG_ReadPixels_GL
byte * IMG_ReadPixels_GL(int *width, int *height, int *rowbytes)
Definition: state.c:427
GL_StateBits
void GL_StateBits(glStateBits_t bits)
Definition: state.c:60
gl_drawentities
cvar_t * gl_drawentities
Definition: main.c:59
CULL_CLIP
@ CULL_CLIP
Definition: gl.h:193
GL_DrawSpriteModel
static void GL_DrawSpriteModel(model_t *model)
Definition: main.c:336
Q_scnprintf
size_t Q_scnprintf(char *dest, size_t size, const char *fmt,...)
Definition: shared.c:867
R_TileClear_GL
void R_TileClear_GL(int x, int y, int w, int h, qhandle_t pic)
Definition: draw.c:189
GL_DrawAliasModel
void GL_DrawAliasModel(model_t *model)
Definition: mesh.c:623
QGL_Init
#define QGL_Init()
Definition: fixed.h:151
glConfig_t::es_profile
qboolean es_profile
Definition: gl.h:101
glConfig_t::stencilbits
int stencilbits
Definition: gl.h:115
gl_modulate_changed
static void gl_modulate_changed(cvar_t *self)
Definition: main.c:717
gl_showtris
cvar_t * gl_showtris
Definition: main.c:61
GL_InitTables
static void GL_InitTables(void)
Definition: main.c:953
GL_FreeWorld
void GL_FreeWorld(void)
Definition: surf.c:859
glRefdef_t::drawframe
int drawframe
Definition: gl.h:85
glRefdef_t::ent
entity_t * ent
Definition: gl.h:92
gl_fullbright
cvar_t * gl_fullbright
Definition: main.c:79
BoxOnPlaneSide
int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, cplane_t *p)
Definition: math.c:322
CULL_OUT
@ CULL_OUT
Definition: gl.h:191
glConfig_t::maxAnisotropy
float maxAnisotropy
Definition: gl.h:111
QGL_EXT_compiled_vertex_array
#define QGL_EXT_compiled_vertex_array
Definition: dynamic.h:158
glRefdef_t::fd
refdef_t fd
Definition: gl.h:81
GL_DrawEntities
static void GL_DrawEntities(int mask)
Definition: main.c:418