This repository has been archived on 2022-06-27. You can view files and clone it, but cannot push or open issues or pull requests.
Xash3DArchive/engine/client/gl_local.h

689 lines
22 KiB
C
Raw Normal View History

2011-05-09 22:00:00 +02:00
/*
gl_local.h - renderer local declarations
Copyright (C) 2010 Uncle Mike
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
2010-11-22 22:00:00 +01:00
#ifndef GL_LOCAL_H
#define GL_LOCAL_H
2010-11-28 22:00:00 +01:00
#include "gl_export.h"
2010-11-29 22:00:00 +01:00
#include "cl_entity.h"
2011-12-04 21:00:00 +01:00
#include "render_api.h"
2010-12-14 22:00:00 +01:00
#include "protocol.h"
2010-12-03 22:00:00 +01:00
#include "dlight.h"
2017-03-13 22:00:00 +01:00
#include "gl_frustum.h"
2010-11-28 22:00:00 +01:00
extern byte *r_temppool;
2018-02-05 22:00:00 +01:00
#define BLOCK_SIZE tr.block_size // lightmap blocksize
2012-12-21 21:00:00 +01:00
#define BLOCK_SIZE_DEFAULT 128 // for keep backward compatibility
2014-01-01 21:00:00 +01:00
#define BLOCK_SIZE_MAX 1024
2010-12-23 22:00:00 +01:00
2011-03-18 22:00:00 +01:00
#define MAX_TEXTURES 4096
2011-07-07 22:00:00 +02:00
#define MAX_DETAIL_TEXTURES 256
2012-08-15 22:00:00 +02:00
#define MAX_LIGHTMAPS 256
2010-12-06 22:00:00 +01:00
#define SUBDIVIDE_SIZE 64
2017-08-20 23:00:00 +02:00
#define MAX_DECAL_SURFS 4096
2018-03-20 22:00:00 +01:00
#define MAX_DRAW_STACK 2 // normal view and menu view
2010-11-29 22:00:00 +01:00
2018-03-20 22:00:00 +01:00
#define SHADEDOT_QUANT 16 // precalculated dot products for quantized angles
2017-08-23 23:00:00 +02:00
#define SHADE_LAMBERT 1.495f
2018-05-08 23:00:00 +02:00
#define DEFAULT_ALPHATEST 0.0f
2011-08-14 22:00:00 +02:00
2010-12-06 22:00:00 +01:00
// refparams
2010-11-29 22:00:00 +01:00
#define RP_NONE 0
2018-02-06 22:00:00 +01:00
#define RP_ENVVIEW BIT( 0 ) // used for cubemapshot
#define RP_OLDVIEWLEAF BIT( 1 )
#define RP_CLIPPLANE BIT( 2 )
2011-04-08 22:00:00 +02:00
2018-02-06 22:00:00 +01:00
#define RP_NONVIEWERREF (RP_ENVVIEW)
2017-08-18 23:00:00 +02:00
#define R_ModelOpaque( rm ) ( rm == kRenderNormal )
2018-03-01 22:00:00 +01:00
#define R_StaticEntity( ent ) ( VectorIsNull( ent->origin ) && VectorIsNull( ent->angles ))
2017-03-11 22:00:00 +01:00
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
2018-03-01 22:00:00 +01:00
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
2010-11-29 22:00:00 +01:00
2017-08-18 23:00:00 +02:00
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP)
#define TF_IMAGE (TF_NOMIPMAP|TF_CLAMP)
#define TF_DECAL (TF_CLAMP)
2011-04-06 22:00:00 +02:00
2017-08-22 23:00:00 +02:00
#define CULL_VISIBLE 0 // not culled
#define CULL_BACKSIDE 1 // backside of transparent wall
#define CULL_FRUSTUM 2 // culled by frustum
#define CULL_VISFRAME 3 // culled by PVS
#define CULL_OTHER 4 // culled by other reason
2010-11-28 22:00:00 +01:00
typedef struct gltexture_s
{
2013-12-01 21:00:00 +01:00
char name[256]; // game path, including extension (can be store image programs)
2010-11-29 22:00:00 +01:00
word srcWidth; // keep unscaled sizes
word srcHeight;
word width; // upload width\height
word height;
2016-09-19 23:00:00 +02:00
word depth; // texture depth or count of layers for 2D_ARRAY
2016-09-06 23:00:00 +02:00
byte numMips; // mipmap count
2010-11-28 22:00:00 +01:00
GLuint target; // glTarget
GLuint texnum; // gl texture binding
2010-11-29 22:00:00 +01:00
GLint format; // uploaded format
2016-04-24 23:00:00 +02:00
GLint encode; // using GLSL decoder
2010-11-29 22:00:00 +01:00
texFlags_t flags;
2011-02-15 22:00:00 +01:00
rgba_t fogParams; // some water textures
// contain info about underwater fog
2011-10-06 22:00:00 +02:00
rgbdata_t *original; // keep original image
2010-11-29 22:00:00 +01:00
// debug info
size_t size; // upload size for debug targets
2010-11-28 22:00:00 +01:00
2011-07-07 22:00:00 +02:00
// detail textures stuff
float xscale;
float yscale;
2018-03-07 22:00:00 +01:00
int servercount;
uint hashValue;
2010-11-28 22:00:00 +01:00
struct gltexture_s *nextHash;
2018-08-23 23:00:00 +02:00
} gl_texture_t;
2010-11-28 22:00:00 +01:00
typedef struct
{
2010-11-29 22:00:00 +01:00
int params; // rendering parameters
2010-12-06 22:00:00 +01:00
2010-11-29 22:00:00 +01:00
qboolean drawWorld; // ignore world for drawing PlayerModel
2011-03-03 22:00:00 +01:00
qboolean isSkyVisible; // sky is visible
2017-02-15 22:00:00 +01:00
qboolean onlyClientDraw; // disabled by client request
2011-08-21 22:00:00 +02:00
qboolean drawOrtho; // draw world as orthogonal projection
2010-11-29 22:00:00 +01:00
2017-02-15 22:00:00 +01:00
float fov_x, fov_y; // current view fov
2010-12-02 22:00:00 +01:00
2010-11-29 22:00:00 +01:00
cl_entity_t *currententity;
model_t *currentmodel;
2011-10-28 22:00:00 +02:00
cl_entity_t *currentbeam; // same as above but for beams
2010-12-06 22:00:00 +01:00
int viewport[4];
2017-03-13 22:00:00 +01:00
gl_frustum_t frustum;
2010-12-06 22:00:00 +01:00
2016-11-21 22:00:00 +01:00
mleaf_t *viewleaf;
mleaf_t *oldviewleaf;
2010-12-06 22:00:00 +01:00
vec3_t pvsorigin;
vec3_t vieworg; // locked vieworigin
2017-02-15 22:00:00 +01:00
vec3_t viewangles;
2010-12-06 22:00:00 +01:00
vec3_t vforward;
vec3_t vright;
vec3_t vup;
2011-10-28 22:00:00 +02:00
vec3_t cullorigin;
vec3_t cull_vforward;
vec3_t cull_vright;
vec3_t cull_vup;
2010-12-06 22:00:00 +01:00
float farClip;
2011-03-20 22:00:00 +01:00
qboolean fogCustom;
qboolean fogEnabled;
2017-08-15 23:00:00 +02:00
qboolean fogSkybox;
vec4_t fogColor;
2011-03-20 22:00:00 +01:00
float fogDensity;
float fogStart;
float fogEnd;
2011-09-03 22:00:00 +02:00
int cached_contents; // in water
2017-09-02 23:00:00 +02:00
int cached_waterlevel; // was in water
2011-03-20 22:00:00 +01:00
2010-12-06 22:00:00 +01:00
float skyMins[2][6];
float skyMaxs[2][6];
2011-04-08 22:00:00 +02:00
matrix4x4 objectMatrix; // currententity matrix
matrix4x4 worldviewMatrix; // modelview for world
2010-12-06 22:00:00 +01:00
matrix4x4 modelviewMatrix; // worldviewMatrix * objectMatrix
matrix4x4 projectionMatrix;
matrix4x4 worldviewProjectionMatrix; // worldviewMatrix * projectionMatrix
2016-11-21 22:00:00 +01:00
byte visbytes[(MAX_MAP_LEAFS+7)/8];// actual PVS for current frame
2012-11-20 21:00:00 +01:00
float viewplanedist;
2010-12-06 22:00:00 +01:00
mplane_t clipPlane;
2010-11-29 22:00:00 +01:00
} ref_instance_t;
2018-03-20 22:00:00 +01:00
typedef struct
{
cl_entity_t *solid_entities[MAX_VISIBLE_PACKET]; // opaque moving or alpha brushes
cl_entity_t *trans_entities[MAX_VISIBLE_PACKET]; // translucent brushes
cl_entity_t *beam_entities[MAX_VISIBLE_PACKET];
uint num_solid_entities;
uint num_trans_entities;
uint num_beam_entities;
} draw_list_t;
2010-11-29 22:00:00 +01:00
typedef struct
{
2018-04-03 23:00:00 +02:00
int defaultTexture; // use for bad textures
int particleTexture;
2010-11-29 22:00:00 +01:00
int whiteTexture;
2012-01-27 21:00:00 +01:00
int grayTexture;
2010-11-29 22:00:00 +01:00
int blackTexture;
2010-12-06 22:00:00 +01:00
int solidskyTexture; // quake1 solid-sky layer
int alphaskyTexture; // quake1 alpha-sky layer
2010-11-29 22:00:00 +01:00
int lightmapTextures[MAX_LIGHTMAPS];
2011-03-31 22:00:00 +02:00
int dlightTexture; // custom dlight texture
2010-12-20 22:00:00 +01:00
int skyboxTextures[6]; // skybox sides
2018-04-03 23:00:00 +02:00
int cinTexture; // cinematic texture
2010-12-06 22:00:00 +01:00
int skytexturenum; // this not a gl_texturenum!
2011-04-13 22:00:00 +02:00
int skyboxbasenum; // start with 5800
2010-12-14 22:00:00 +01:00
// entity lists
2018-03-20 22:00:00 +01:00
draw_list_t draw_stack[MAX_DRAW_STACK];
int draw_stack_pos;
draw_list_t *draw_list;
2017-08-20 23:00:00 +02:00
msurface_t *draw_decals[MAX_DECAL_SURFS];
int num_draw_decals;
2011-04-08 22:00:00 +02:00
2010-12-11 22:00:00 +01:00
// OpenGL matrix states
qboolean modelviewIdentity;
2017-02-21 22:00:00 +01:00
2010-12-06 22:00:00 +01:00
int visframecount; // PVS frame
int dlightframecount; // dynamic light frame
2017-03-02 22:00:00 +01:00
int realframecount; // not including viewpasses
2010-12-03 22:00:00 +01:00
int framecount;
2011-10-06 22:00:00 +02:00
2017-04-01 23:00:00 +02:00
qboolean ignore_lightgamma;
2017-03-29 23:00:00 +02:00
qboolean fCustomRendering;
2017-03-26 23:00:00 +02:00
qboolean fResetVis;
2017-07-12 23:00:00 +02:00
qboolean fFlipViewModel;
2017-03-26 23:00:00 +02:00
2018-11-26 22:00:00 +01:00
// tree visualization stuff
int recursion_level;
int max_recursion;
2016-11-22 22:00:00 +01:00
int lightstylevalue[MAX_LIGHTSTYLES]; // value 0 - 65536
2018-02-05 22:00:00 +01:00
int block_size; // lightmap blocksize
2016-11-22 22:00:00 +01:00
2017-02-21 22:00:00 +01:00
double frametime; // special frametime for multipass rendering (will set to 0 on a nextview)
2017-03-06 22:00:00 +01:00
float blend; // global blend value
2017-02-21 22:00:00 +01:00
2011-10-06 22:00:00 +02:00
// cull info
vec3_t modelorg; // relative to viewpoint
2010-11-28 22:00:00 +01:00
} ref_globals_t;
2010-12-06 22:00:00 +01:00
typedef struct
{
uint c_world_polys;
uint c_studio_polys;
uint c_sprite_polys;
2017-06-23 23:00:00 +02:00
uint c_alias_polys;
2010-12-06 22:00:00 +01:00
uint c_world_leafs;
2010-12-16 22:00:00 +01:00
2011-01-03 22:00:00 +01:00
uint c_view_beams_count;
uint c_active_tents_count;
2017-08-12 23:00:00 +02:00
uint c_alias_models_drawn;
2010-12-17 22:00:00 +01:00
uint c_studio_models_drawn;
uint c_sprite_models_drawn;
2011-04-09 22:00:00 +02:00
uint c_particle_count;
2012-08-07 22:00:00 +02:00
2013-02-19 21:00:00 +01:00
uint c_client_ents; // entities that moved to client
2018-06-15 23:00:00 +02:00
double t_world_node;
double t_world_draw;
2010-12-06 22:00:00 +01:00
} ref_speeds_t;
extern ref_speeds_t r_stats;
2010-11-29 22:00:00 +01:00
extern ref_instance_t RI;
extern ref_globals_t tr;
2010-11-28 22:00:00 +01:00
2010-12-11 22:00:00 +01:00
extern float gldepthmin, gldepthmax;
2010-12-06 22:00:00 +01:00
extern mleaf_t *r_viewleaf, *r_oldviewleaf;
extern mleaf_t *r_viewleaf2, *r_oldviewleaf2;
2010-12-03 22:00:00 +01:00
extern dlight_t cl_dlights[MAX_DLIGHTS];
2010-12-19 22:00:00 +01:00
extern dlight_t cl_elights[MAX_ELIGHTS];
2018-03-20 22:00:00 +01:00
#define r_numEntities (tr.draw_list->num_solid_entities + tr.draw_list->num_trans_entities)
2013-02-19 21:00:00 +01:00
#define r_numStatics (r_stats.c_client_ents)
2010-11-22 22:00:00 +01:00
2011-12-04 21:00:00 +01:00
extern struct beam_s *cl_active_beams;
extern struct beam_s *cl_free_beams;
2017-02-21 22:00:00 +01:00
extern struct particle_s *cl_free_particles;
2011-12-04 21:00:00 +01:00
2010-11-28 22:00:00 +01:00
//
// gl_backend.c
//
2017-02-15 22:00:00 +01:00
void GL_BackendStartFrame( void );
void GL_BackendEndFrame( void );
2010-12-06 22:00:00 +01:00
void GL_CleanUpTextureUnits( int last );
2013-12-07 21:00:00 +01:00
void GL_Bind( GLint tmu, GLenum texnum );
2010-12-06 22:00:00 +01:00
void GL_MultiTexCoord2f( GLenum texture, GLfloat s, GLfloat t );
2013-12-07 21:00:00 +01:00
void GL_SetTexCoordArrayMode( GLenum mode );
2010-12-06 22:00:00 +01:00
void GL_LoadTexMatrix( const matrix4x4 m );
2012-01-27 21:00:00 +01:00
void GL_LoadTexMatrixExt( const float *glmatrix );
2010-12-06 22:00:00 +01:00
void GL_LoadMatrix( const matrix4x4 source );
2010-11-28 22:00:00 +01:00
void GL_TexGen( GLenum coord, GLenum mode );
2013-12-07 21:00:00 +01:00
void GL_SelectTexture( GLint texture );
2016-11-14 22:00:00 +01:00
void GL_CleanupAllTextureUnits( void );
2010-12-06 22:00:00 +01:00
void GL_LoadIdentityTexMatrix( void );
2011-10-06 22:00:00 +02:00
void GL_DisableAllTexGens( void );
2010-12-02 22:00:00 +01:00
void GL_SetRenderMode( int mode );
2013-09-03 22:00:00 +02:00
void GL_TextureTarget( uint target );
2010-11-28 22:00:00 +01:00
void GL_Cull( GLenum cull );
2010-12-06 22:00:00 +01:00
void R_ShowTextures( void );
2018-11-26 22:00:00 +01:00
void R_ShowTree( void );
2010-11-28 22:00:00 +01:00
2010-12-17 22:00:00 +01:00
//
// gl_cull.c
//
2017-03-06 22:00:00 +01:00
int R_CullModel( cl_entity_t *e, const vec3_t absmin, const vec3_t absmax );
2017-03-13 22:00:00 +01:00
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
qboolean R_CullSphere( const vec3_t centre, const float radius );
2017-08-22 23:00:00 +02:00
int R_CullSurface( msurface_t *surf, gl_frustum_t *frustum, uint clipflags );
2010-12-17 22:00:00 +01:00
2010-12-23 22:00:00 +01:00
//
// gl_decals.c
//
2017-08-22 23:00:00 +02:00
void DrawSurfaceDecals( msurface_t *fa, qboolean single, qboolean reverse );
2012-07-20 22:00:00 +02:00
float *R_DecalSetupVerts( decal_t *pDecal, msurface_t *surf, int texture, int *outCount );
2011-12-04 21:00:00 +01:00
void DrawSingleDecal( decal_t *pDecal, msurface_t *fa );
2012-04-25 22:00:00 +02:00
void R_EntityRemoveDecals( model_t *mod );
2017-08-21 23:00:00 +02:00
void DrawDecalsBatch( void );
2010-12-23 22:00:00 +01:00
void R_ClearDecals( void );
2010-11-29 22:00:00 +01:00
//
// gl_draw.c
//
void R_Set2DMode( qboolean enable );
2011-09-19 22:00:00 +02:00
void R_DrawTileClear( int x, int y, int w, int h );
2011-12-09 21:00:00 +01:00
void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data );
2010-11-29 22:00:00 +01:00
2018-05-26 23:00:00 +02:00
//
// gl_drawhulls.c
//
void R_DrawWorldHull( void );
void R_DrawModelHull( void );
2010-11-28 22:00:00 +01:00
//
// gl_image.c
//
void R_SetTextureParameters( void );
2018-08-23 23:00:00 +02:00
gl_texture_t *R_GetTexture( GLenum texnum );
#define GL_LoadTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, false )
#define GL_UpdateTextureInternal( name, pic, flags ) GL_LoadTextureFromBuffer( name, pic, flags, true )
2018-10-17 23:00:00 +02:00
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
int GL_LoadTextureArray( const char **names, int flags );
2018-08-23 23:00:00 +02:00
int GL_LoadTextureFromBuffer( const char *name, rgbdata_t *pic, texFlags_t flags, qboolean update );
2010-12-16 22:00:00 +01:00
byte *GL_ResampleTexture( const byte *source, int in_w, int in_h, int out_w, int out_h, qboolean isNormalMap );
2011-12-04 21:00:00 +01:00
int GL_CreateTexture( const char *name, int width, int height, const void *buffer, texFlags_t flags );
2016-09-26 23:00:00 +02:00
int GL_CreateTextureArray( const char *name, int width, int height, int depth, const void *buffer, texFlags_t flags );
2011-10-06 22:00:00 +02:00
void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor );
2018-08-23 23:00:00 +02:00
void GL_UpdateTexSize( int texnum, int width, int height, int depth );
void GL_ApplyTextureParams( gl_texture_t *tex );
2011-07-22 22:00:00 +02:00
int GL_FindTexture( const char *name );
2010-11-29 22:00:00 +01:00
void GL_FreeTexture( GLenum texnum );
void GL_FreeImage( const char *name );
2012-01-27 21:00:00 +01:00
const char *GL_Target( GLenum target );
2018-04-03 23:00:00 +02:00
void R_InitDlightTexture( void );
2010-12-02 22:00:00 +01:00
void R_TextureList_f( void );
2010-11-29 22:00:00 +01:00
void R_InitImages( void );
void R_ShutdownImages( void );
2019-05-11 23:00:00 +02:00
int GL_TexMemory( void );
2010-11-28 22:00:00 +01:00
2010-12-06 22:00:00 +01:00
//
// gl_refrag.c
//
2013-09-03 22:00:00 +02:00
void R_StoreEfrags( efrag_t **ppefrag, int framecount );
2010-12-06 22:00:00 +01:00
//
// gl_rlight.c
//
void R_PushDlights( void );
2010-12-11 22:00:00 +01:00
void R_AnimateLight( void );
2011-11-02 21:00:00 +01:00
void R_GetLightSpot( vec3_t lightspot );
2010-12-11 22:00:00 +01:00
void R_MarkLights( dlight_t *light, int bit, mnode_t *node );
2011-07-07 22:00:00 +02:00
void R_LightForPoint( const vec3_t point, color24 *ambientLight, qboolean invLight, qboolean useAmbient, float radius );
2018-05-20 23:00:00 +02:00
colorVec R_LightVec( const vec3_t start, const vec3_t end, vec3_t lightspot, vec3_t lightvec );
2011-11-02 21:00:00 +01:00
int R_CountSurfaceDlights( msurface_t *surf );
2017-03-07 22:00:00 +01:00
colorVec R_LightPoint( const vec3_t p0 );
2011-11-02 21:00:00 +01:00
int R_CountDlights( void );
2010-12-06 22:00:00 +01:00
2010-11-28 22:00:00 +01:00
//
// gl_rmain.c
//
void R_ClearScene( void );
2010-12-11 22:00:00 +01:00
void R_LoadIdentity( void );
2017-02-15 22:00:00 +01:00
void R_RenderScene( void );
2010-11-29 22:00:00 +01:00
void R_DrawCubemapView( const vec3_t origin, const vec3_t angles, int size );
2017-03-13 22:00:00 +01:00
void R_SetupRefParams( const struct ref_viewpass_s *rvp );
2010-12-11 22:00:00 +01:00
void R_TranslateForEntity( cl_entity_t *e );
void R_RotateForEntity( cl_entity_t *e );
2017-03-13 22:00:00 +01:00
void R_SetupGL( qboolean set_gl_state );
2011-12-04 21:00:00 +01:00
qboolean R_InitRenderAPI( void );
2017-08-15 23:00:00 +02:00
void R_AllowFog( int allowed );
2011-10-06 22:00:00 +02:00
void R_SetupFrustum( void );
void R_FindViewLeaf( void );
2019-06-13 23:00:00 +02:00
void R_CheckGamma( void );
2018-03-20 22:00:00 +01:00
void R_PushScene( void );
void R_PopScene( void );
2011-02-15 22:00:00 +01:00
void R_DrawFog( void );
2010-11-28 22:00:00 +01:00
2010-12-06 22:00:00 +01:00
//
// gl_rmath.c
//
float V_CalcFov( float *fov_x, float width, float height );
void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolean lock_x );
2010-12-22 22:00:00 +01:00
void Matrix4x4_ToArrayFloatGL( const matrix4x4 in, float out[16] );
void Matrix4x4_FromArrayFloatGL( matrix4x4 out, const float in[16] );
void Matrix4x4_Concat( matrix4x4 out, const matrix4x4 in1, const matrix4x4 in2 );
void Matrix4x4_ConcatTranslate( matrix4x4 out, float x, float y, float z );
void Matrix4x4_ConcatRotate( matrix4x4 out, float angle, float x, float y, float z );
2011-08-21 22:00:00 +02:00
void Matrix4x4_ConcatScale( matrix4x4 out, float x );
void Matrix4x4_ConcatScale3( matrix4x4 out, float x, float y, float z );
2010-12-22 22:00:00 +01:00
void Matrix4x4_CreateTranslate( matrix4x4 out, float x, float y, float z );
void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float z );
2011-08-21 22:00:00 +02:00
void Matrix4x4_CreateScale( matrix4x4 out, float x );
void Matrix4x4_CreateScale3( matrix4x4 out, float x, float y, float z );
2010-12-22 22:00:00 +01:00
void Matrix4x4_CreateProjection(matrix4x4 out, float xMax, float xMin, float yMax, float yMin, float zNear, float zFar);
2011-08-21 22:00:00 +02:00
void Matrix4x4_CreateOrtho(matrix4x4 m, float xLeft, float xRight, float yBottom, float yTop, float zNear, float zFar);
2010-12-22 22:00:00 +01:00
void Matrix4x4_CreateModelview( matrix4x4 out );
2010-12-16 22:00:00 +01:00
2012-11-20 21:00:00 +01:00
//
// gl_rmisc.
//
2018-10-17 23:00:00 +02:00
void R_ClearStaticEntities( void );
2010-12-06 22:00:00 +01:00
2010-12-03 22:00:00 +01:00
//
// gl_rsurf.c
//
2010-12-06 22:00:00 +01:00
void R_MarkLeaves( void );
void R_DrawWorld( void );
2010-12-11 22:00:00 +01:00
void R_DrawWaterSurfaces( void );
void R_DrawBrushModel( cl_entity_t *e );
2010-12-03 22:00:00 +01:00
void GL_SubdivideSurface( msurface_t *fa );
2011-12-04 21:00:00 +01:00
void GL_BuildPolygonFromSurface( model_t *mod, msurface_t *fa );
2017-08-20 23:00:00 +02:00
void DrawGLPoly( glpoly_t *p, float xScale, float yScale );
texture_t *R_TextureAnimation( msurface_t *s );
2012-06-25 22:00:00 +02:00
void GL_SetupFogColorForSurfaces( void );
2017-08-12 23:00:00 +02:00
void R_DrawAlphaTextureChains( void );
2011-10-06 22:00:00 +02:00
void GL_RebuildLightmaps( void );
2017-03-02 22:00:00 +01:00
void GL_InitRandomTable( void );
2010-12-03 22:00:00 +01:00
void GL_BuildLightmaps( void );
2012-06-25 22:00:00 +02:00
void GL_ResetFogColor( void );
2010-12-03 22:00:00 +01:00
2010-12-02 22:00:00 +01:00
//
// gl_sprite.c
//
2010-12-15 22:00:00 +01:00
void R_SpriteInit( void );
2012-01-27 21:00:00 +01:00
void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, uint texFlags );
2010-12-02 22:00:00 +01:00
mspriteframe_t *R_GetSpriteFrame( const model_t *pModel, int frame, float yaw );
2010-12-15 22:00:00 +01:00
void R_DrawSpriteModel( cl_entity_t *e );
2010-12-02 22:00:00 +01:00
2010-12-16 22:00:00 +01:00
//
// gl_studio.c
//
void R_StudioInit( void );
2011-07-22 22:00:00 +02:00
void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded );
2017-03-08 22:00:00 +01:00
void R_StudioLerpMovement( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
2017-03-11 22:00:00 +01:00
float CL_GetSequenceDuration( cl_entity_t *ent, int sequence );
2013-09-03 22:00:00 +02:00
struct mstudiotex_s *R_StudioGetTexture( cl_entity_t *e );
2017-02-21 22:00:00 +01:00
float CL_GetStudioEstimatedFrame( cl_entity_t *ent );
2018-02-20 22:00:00 +01:00
int R_GetEntityRenderMode( cl_entity_t *ent );
2010-12-16 22:00:00 +01:00
void R_DrawStudioModel( cl_entity_t *e );
2018-03-07 22:00:00 +01:00
player_info_t *pfnPlayerInfo( int index );
2018-05-08 23:00:00 +02:00
void R_GatherPlayerLight( void );
2010-12-16 22:00:00 +01:00
2017-06-23 23:00:00 +02:00
//
// gl_alias.c
//
void Mod_LoadAliasModel( model_t *mod, const void *buffer, qboolean *loaded );
void R_DrawAliasModel( cl_entity_t *e );
2017-07-12 23:00:00 +02:00
void R_AliasInit( void );
2017-06-23 23:00:00 +02:00
2010-12-06 22:00:00 +01:00
//
// gl_warp.c
//
2018-02-05 22:00:00 +01:00
void R_InitSkyClouds( struct mip_s *mt, struct texture_s *tx, qboolean custom_palette );
2010-12-20 22:00:00 +01:00
void R_AddSkyBoxSurface( msurface_t *fa );
2010-12-06 22:00:00 +01:00
void R_ClearSkyBox( void );
void R_DrawSkyBox( void );
2016-09-06 23:00:00 +02:00
void R_DrawClouds( void );
2018-03-03 22:00:00 +01:00
void EmitWaterPolys( msurface_t *warp, qboolean reverse );
2010-12-06 22:00:00 +01:00
2010-11-28 22:00:00 +01:00
//
// gl_vidnt.c
//
#define GL_CheckForErrors() GL_CheckForErrors_( __FILE__, __LINE__ )
void GL_CheckForErrors_( const char *filename, const int fileline );
2017-03-22 22:00:00 +01:00
const char *VID_GetModeString( int vid_mode );
2016-12-10 22:00:00 +01:00
void *GL_GetProcAddress( const char *name );
2018-09-28 23:00:00 +02:00
const char *GL_ErrorString( int err );
2010-11-29 22:00:00 +01:00
void GL_UpdateSwapInterval( void );
2010-12-21 22:00:00 +01:00
qboolean GL_DeleteContext( void );
2010-11-28 22:00:00 +01:00
qboolean GL_Support( int r_ext );
2010-12-21 22:00:00 +01:00
void VID_CheckChanges( void );
2013-12-01 21:00:00 +01:00
int GL_MaxTextureUnits( void );
2010-11-28 22:00:00 +01:00
qboolean R_Init( void );
void R_Shutdown( void );
2011-04-06 22:00:00 +02:00
//
// renderer exports
//
qboolean R_Init( void );
void R_Shutdown( void );
void VID_CheckChanges( void );
2018-10-17 23:00:00 +02:00
int GL_LoadTexture( const char *name, const byte *buf, size_t size, int flags );
2011-04-06 22:00:00 +02:00
void GL_FreeImage( const char *name );
qboolean VID_ScreenShot( const char *filename, int shot_type );
qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qboolean skyshot );
void R_BeginFrame( qboolean clearScene );
2017-02-21 22:00:00 +01:00
void R_RenderFrame( const struct ref_viewpass_s *vp );
2011-04-06 22:00:00 +02:00
void R_EndFrame( void );
void R_ClearScene( void );
void R_GetTextureParms( int *w, int *h, int texnum );
void R_GetSpriteParms( int *frameWidth, int *frameHeight, int *numFrames, int curFrame, const struct model_s *pSprite );
void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty );
void R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
qboolean R_SpeedsMessage( char *out, size_t size );
void R_SetupSky( const char *skyboxname );
2017-03-13 22:00:00 +01:00
qboolean R_CullBox( const vec3_t mins, const vec3_t maxs );
2011-04-06 22:00:00 +02:00
qboolean R_WorldToScreen( const vec3_t point, vec3_t screen );
void R_ScreenToWorld( const vec3_t screen, vec3_t point );
qboolean R_AddEntity( struct cl_entity_s *pRefEntity, int entityType );
2011-07-22 22:00:00 +02:00
void Mod_LoadMapSprite( struct model_s *mod, const void *buffer, size_t size, qboolean *loaded );
2011-04-06 22:00:00 +02:00
void Mod_UnloadSpriteModel( struct model_s *mod );
void Mod_UnloadStudioModel( struct model_s *mod );
void Mod_UnloadBrushModel( struct model_s *mod );
2017-06-23 23:00:00 +02:00
void Mod_UnloadAliasModel( struct model_s *mod );
2011-04-06 22:00:00 +02:00
void GL_SetRenderMode( int mode );
void R_RunViewmodelEvents( void );
void R_DrawViewModel( void );
int R_GetSpriteTexture( const struct model_s *m_pSpriteModel, int frame );
2017-03-14 22:00:00 +01:00
void R_DecalShoot( int textureIndex, int entityIndex, int modelIndex, vec3_t pos, int flags, float scale );
2011-04-06 22:00:00 +02:00
void R_RemoveEfrags( struct cl_entity_s *ent );
void R_AddEfrags( struct cl_entity_s *ent );
void R_DecalRemoveAll( int texture );
byte *Mod_GetCurrentVis( void );
2011-08-21 22:00:00 +02:00
void Mod_SetOrthoBounds( float *mins, float *maxs );
2011-04-06 22:00:00 +02:00
void R_NewMap( void );
2010-11-28 22:00:00 +01:00
/*
=======================================================================
GL STATE MACHINE
=======================================================================
*/
enum
{
GL_OPENGL_110 = 0, // base
2016-08-13 23:00:00 +02:00
GL_WGL_EXTENSIONS,
2010-11-28 22:00:00 +01:00
GL_WGL_SWAPCONTROL,
2011-07-07 22:00:00 +02:00
GL_WGL_PROCADDRESS,
2010-11-28 22:00:00 +01:00
GL_ARB_MULTITEXTURE,
2016-11-14 22:00:00 +01:00
GL_TEXTURE_CUBEMAP_EXT,
2010-11-28 22:00:00 +01:00
GL_ANISOTROPY_EXT,
2016-11-14 22:00:00 +01:00
GL_TEXTURE_LOD_BIAS,
2010-11-28 22:00:00 +01:00
GL_TEXTURE_COMPRESSION_EXT,
GL_SHADER_GLSL100_EXT,
2016-09-19 23:00:00 +02:00
GL_TEXTURE_2D_RECT_EXT,
GL_TEXTURE_ARRAY_EXT,
2010-11-28 22:00:00 +01:00
GL_TEXTURE_3D_EXT,
GL_CLAMPTOEDGE_EXT,
GL_ARB_TEXTURE_NPOT_EXT,
GL_CLAMP_TEXBORDER_EXT,
2014-04-01 22:00:00 +02:00
GL_ARB_TEXTURE_FLOAT_EXT,
2015-04-25 23:00:00 +02:00
GL_ARB_DEPTH_FLOAT_EXT,
GL_ARB_SEAMLESS_CUBEMAP,
2016-11-14 22:00:00 +01:00
GL_EXT_GPU_SHADER4, // shaders only
2010-11-28 22:00:00 +01:00
GL_DEPTH_TEXTURE,
2016-11-14 22:00:00 +01:00
GL_DEBUG_OUTPUT,
2010-11-28 22:00:00 +01:00
GL_EXTCOUNT, // must be last
};
enum
{
2013-12-07 21:00:00 +01:00
GL_KEEP_UNIT = -1,
2010-11-28 22:00:00 +01:00
GL_TEXTURE0 = 0,
2018-03-01 22:00:00 +01:00
GL_TEXTURE1, // used in some cases
2013-12-01 21:00:00 +01:00
MAX_TEXTURE_UNITS = 32 // can't acess to all over units without GLSL or cg
2010-11-28 22:00:00 +01:00
};
2016-11-14 22:00:00 +01:00
typedef enum
{
GLHW_GENERIC, // where everthing works the way it should
GLHW_RADEON, // where you don't have proper GLSL support
2017-09-04 23:00:00 +02:00
GLHW_NVIDIA, // Geforce 8/9 class DX10 hardware
GLHW_INTEL // Intel Mobile Graphics
2016-11-14 22:00:00 +01:00
} glHWType_t;
2010-11-28 22:00:00 +01:00
typedef struct
{
const char *renderer_string; // ptrs to OpenGL32.dll, use with caution
const char *vendor_string;
const char *version_string;
2016-11-14 22:00:00 +01:00
glHWType_t hardware_type;
2010-11-28 22:00:00 +01:00
// list of supported extensions
const char *extensions_string;
2016-08-13 23:00:00 +02:00
const char *wgl_extensions_string;
2010-11-28 22:00:00 +01:00
byte extension[GL_EXTCOUNT];
int max_texture_units;
2013-12-01 21:00:00 +01:00
int max_texture_coords;
int max_teximage_units;
2010-11-28 22:00:00 +01:00
GLint max_2d_texture_size;
GLint max_2d_rectangle_size;
2016-09-19 23:00:00 +02:00
GLint max_2d_texture_layers;
2010-11-28 22:00:00 +01:00
GLint max_3d_texture_size;
2010-11-29 22:00:00 +01:00
GLint max_cubemap_size;
2010-11-28 22:00:00 +01:00
GLfloat max_texture_anisotropy;
2016-11-14 22:00:00 +01:00
GLfloat max_texture_lod_bias;
2015-03-02 22:00:00 +01:00
GLint max_vertex_uniforms;
GLint max_vertex_attribs;
2010-11-28 22:00:00 +01:00
2018-04-17 23:00:00 +02:00
GLint max_multisamples;
2010-11-28 22:00:00 +01:00
int color_bits;
2010-12-11 22:00:00 +01:00
int alpha_bits;
2010-11-28 22:00:00 +01:00
int depth_bits;
int stencil_bits;
2016-12-10 22:00:00 +01:00
gl_context_type_t context;
gles_wrapper_t wrapper;
2015-10-15 23:00:00 +02:00
qboolean softwareGammaUpdate;
2019-06-08 23:00:00 +02:00
qboolean fCustomRenderer;
2010-11-28 22:00:00 +01:00
int prev_mode;
} glconfig_t;
typedef struct
{
int width, height;
qboolean fullScreen;
qboolean wideScreen;
int activeTMU;
2012-12-21 21:00:00 +01:00
GLint currentTextures[MAX_TEXTURE_UNITS];
2012-01-27 21:00:00 +01:00
GLuint currentTextureTargets[MAX_TEXTURE_UNITS];
2010-11-28 22:00:00 +01:00
GLboolean texIdentityMatrix[MAX_TEXTURE_UNITS];
GLint genSTEnabled[MAX_TEXTURE_UNITS]; // 0 - disabled, OR 1 - S, OR 2 - T, OR 4 - R
2013-12-07 21:00:00 +01:00
GLint texCoordArrayMode[MAX_TEXTURE_UNITS]; // 0 - disabled, 1 - enabled, 2 - cubemap
2019-02-21 22:00:00 +01:00
GLint isFogEnabled;
2010-11-28 22:00:00 +01:00
int faceCull;
qboolean stencilEnabled;
qboolean in2DMode;
} glstate_t;
typedef struct
{
HDC hDC; // handle to device context
HGLRC hGLRC; // handle to GL rendering context
int desktopBitsPixel;
int desktopWidth;
int desktopHeight;
qboolean initialized; // OpenGL subsystem started
2016-11-14 22:00:00 +01:00
qboolean extended; // extended context allows to GL_Debug
2010-11-28 22:00:00 +01:00
} glwstate_t;
extern glconfig_t glConfig;
extern glstate_t glState;
extern glwstate_t glw_state;
//
// renderer cvars
//
extern convar_t *gl_texture_anisotropy;
extern convar_t *gl_extensions;
extern convar_t *gl_check_errors;
extern convar_t *gl_texture_lodbias;
2016-11-14 22:00:00 +01:00
extern convar_t *gl_texture_nearest;
2017-09-20 23:00:00 +02:00
extern convar_t *gl_lightmap_nearest;
2012-12-23 21:00:00 +01:00
extern convar_t *gl_keeptjunctions;
2018-10-17 23:00:00 +02:00
extern convar_t *gl_emboss_scale;
2018-04-16 23:00:00 +02:00
extern convar_t *gl_round_down;
2013-12-01 21:00:00 +01:00
extern convar_t *gl_detailscale;
2011-04-15 22:00:00 +02:00
extern convar_t *gl_wireframe;
2017-08-20 23:00:00 +02:00
extern convar_t *gl_polyoffset;
2010-11-29 22:00:00 +01:00
extern convar_t *gl_finish;
2012-12-28 21:00:00 +01:00
extern convar_t *gl_nosort;
2010-11-29 22:00:00 +01:00
extern convar_t *gl_clear;
2010-12-13 22:00:00 +01:00
extern convar_t *gl_test; // cvar to testify new effects
2018-05-08 23:00:00 +02:00
extern convar_t *gl_msaa;
2010-11-28 22:00:00 +01:00
2010-12-02 22:00:00 +01:00
extern convar_t *r_speeds;
2010-12-03 22:00:00 +01:00
extern convar_t *r_fullbright;
2010-12-06 22:00:00 +01:00
extern convar_t *r_norefresh;
2018-11-26 22:00:00 +01:00
extern convar_t *r_showtree; // build graph of visible hull
2011-02-25 22:00:00 +01:00
extern convar_t *r_lighting_extended;
2010-12-06 22:00:00 +01:00
extern convar_t *r_lighting_modulate;
2010-12-16 22:00:00 +01:00
extern convar_t *r_lighting_ambient;
2017-07-02 23:00:00 +02:00
extern convar_t *r_studio_lambert;
2011-07-07 22:00:00 +02:00
extern convar_t *r_detailtextures;
2010-12-11 22:00:00 +01:00
extern convar_t *r_drawentities;
2010-12-06 22:00:00 +01:00
extern convar_t *r_adjust_fov;
2010-12-23 22:00:00 +01:00
extern convar_t *r_decals;
2010-12-06 22:00:00 +01:00
extern convar_t *r_novis;
extern convar_t *r_nocull;
extern convar_t *r_lockpvs;
2017-03-06 22:00:00 +01:00
extern convar_t *r_lockfrustum;
2017-03-08 22:00:00 +01:00
extern convar_t *r_traceglow;
2010-12-06 22:00:00 +01:00
extern convar_t *r_dynamic;
extern convar_t *r_lightmap;
2010-11-28 22:00:00 +01:00
extern convar_t *vid_displayfrequency;
extern convar_t *vid_fullscreen;
2017-03-07 22:00:00 +01:00
extern convar_t *vid_brightness;
2010-11-28 22:00:00 +01:00
extern convar_t *vid_gamma;
extern convar_t *vid_mode;
2010-11-22 22:00:00 +01:00
#endif//GL_LOCAL_H