/* Copyright (C) 2003-2006 Andrey Nazarov 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 2 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. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "com_local.h" #include "files.h" #include "ref_public.h" #include "in_public.h" #include "vid_public.h" #include "cl_public.h" #include "sys_public.h" #include "q_list.h" #include "bsp.h" #include "r_shared.h" #include "r_models.h" #include "qgl_local.h" #include "qgl_api.h" /* * gl_main.c * */ #define MAX_TMUS 2 typedef struct { int numTextureUnits; int maxTextureSize; qboolean registering; GLuint prog_warp, prog_light; struct { bsp_t *cache; mempool_t pool; vec_t *vertices; } world; float inverse_intensity; } glStatic_t; typedef struct { refdef_t fd; vec3_t viewaxis[3]; int visframe; int drawframe; int viewcluster1; int viewcluster2; cplane_t frustumPlanes[4]; entity_t *ent; vec3_t entaxis[3]; qboolean entrotated; float scroll; int num_beams; } glRefdef_t; extern glStatic_t gl_static; extern glconfig_t gl_config; extern glRefdef_t glr; typedef struct { int nodesVisible; int nodesDrawn; int facesMarked; int facesDrawn; int texSwitches; int trisDrawn; int batchesDrawn; int nodesCulled; int facesCulled; int boxesCulled; int spheresCulled; int rotatedBoxesCulled; } statCounters_t; extern statCounters_t c; extern cvar_t *gl_celshading; extern cvar_t *gl_partscale; extern cvar_t *gl_znear; extern cvar_t *gl_zfar; extern cvar_t *gl_modulate; extern cvar_t *gl_showtris; extern cvar_t *gl_cull_nodes; extern cvar_t *gl_bind; extern cvar_t *gl_clear; extern cvar_t *gl_novis; extern cvar_t *gl_lockpvs; extern cvar_t *gl_lightmap; extern cvar_t *gl_drawsky; extern cvar_t *gl_dynamic; extern cvar_t *gl_fullbright; extern cvar_t *gl_mode; extern cvar_t *gl_hwgamma; extern cvar_t *gl_fullscreen; typedef enum { CULL_OUT, CULL_IN, CULL_CLIP } glCullResult_t; glCullResult_t GL_CullBox( vec3_t bounds[2] ); glCullResult_t GL_CullSphere( const vec3_t origin, float radius ); glCullResult_t GL_CullLocalBox( const vec3_t origin, vec3_t bounds[2] ); void GL_RotateForEntity( void ); void GL_DrawBox( const vec3_t origin, vec3_t bounds[2] ); void GL_ShowErrors( const char *func ); /* * gl_model.c * */ typedef struct maliastc_s { float st[2]; } maliastc_t; typedef struct maliasvert_s { short pos[3]; byte normalindex; byte pad; } maliasvert_t; typedef struct maliasframe_s { vec3_t scale; vec3_t translate; vec3_t bounds[2]; vec_t radius; } maliasframe_t; typedef struct maliasmesh_s { int numverts; int numtris; int numindices; uint32_t *indices; maliasvert_t *verts; maliastc_t *tcoords; image_t *skins[MAX_ALIAS_SKINS]; int numskins; } maliasmesh_t; /* xyz[3] + st[2] + lmst[2] */ #define VERTEX_SIZE 7 /* * gl_surf.c * */ #define LM_MAX_LIGHTMAPS 32 #define LM_BLOCK_WIDTH 256 #define LM_BLOCK_HEIGHT 256 #define LM_TEXNUM ( MAX_RIMAGES + 2 ) typedef struct { int inuse[LM_BLOCK_WIDTH]; byte buffer[LM_BLOCK_WIDTH * LM_BLOCK_HEIGHT * 4]; int numMaps; int highWater; } lightmapBuilder_t; extern lightmapBuilder_t lm; void GL_AdjustColor( byte *dst, const byte *src, int what ); void GL_LoadWorld( const char *name ); void GL_FreeWorld( void ); /* * gl_state.c * */ typedef enum { GLS_CULL_DISABLE, GLS_CULL_FRONT, GLS_CULL_BACK } glCullFace_t; typedef enum { GLS_DEFAULT = 0, GLS_DEPTHMASK_FALSE = ( 1 << 0 ), GLS_DEPTHTEST_DISABLE = ( 1 << 1 ), GLS_BLEND_BLEND = ( 1 << 2 ), GLS_BLEND_ADD = ( 1 << 3 ), GLS_BLEND_MODULATE = ( 1 << 4 ), GLS_ALPHATEST_ENABLE = ( 1 << 5 ) } glStateBits_t; #define GLS_BLEND_MASK (GLS_BLEND_BLEND|GLS_BLEND_ADD|GLS_BLEND_MODULATE) typedef struct { int tmu; int texnum[MAX_TMUS]; GLenum texenv[MAX_TMUS]; glStateBits_t bits; glCullFace_t cull; } glState_t; extern glState_t gls; void GL_BindTexture( int texnum ); void GL_SelectTMU( int tmu ); void GL_TexEnv( GLenum texenv ); void GL_CullFace( glCullFace_t cull ); void GL_Bits( glStateBits_t bits ); void GL_Setup2D( void ); void GL_Setup3D( void ); void GL_SetDefaultState( void ); void GL_InitPrograms( void ); void GL_ShutdownPrograms( void ); void GL_EnableWarp( void ); void GL_DisableWarp( void ); void GL_EnableOutlines( void ); void GL_DisableOutlines( void ); /* * gl_draw.c * */ typedef struct { color_t color; int flags; float scale; } drawStatic_t; extern drawStatic_t draw; void Draw_Stringf( int x, int y, const char *fmt, ... ); void Draw_Stats( void ); /* * gl_images.c * */ extern image_t *r_notexture; extern image_t *r_particletexture; extern image_t *r_beamtexture; extern image_t *r_warptexture; extern image_t *r_whiteimage; extern image_t *r_blackimage; extern int gl_filter_min; extern int gl_filter_max; extern float gl_filter_anisotropy; extern int gl_tex_alpha_format; extern int gl_tex_solid_format; void Scrap_Upload( void ); void GL_InitImages( void ); void GL_ShutdownImages( void ); void GL_UpdateGammaTable( qboolean realTime ); image_t *R_ImageForHandle( qhandle_t hPic ); qhandle_t R_RegisterSkin( const char *name ); qhandle_t R_RegisterPic( const char *name ); /* * gl_tess.c * */ #define TESS_MAX_FACES 256 #define TESS_MAX_VERTICES ( 16 * TESS_MAX_FACES ) #define TESS_MAX_INDICES ( 3 * TESS_MAX_VERTICES ) typedef struct { vec_t vertices[VERTEX_SIZE*TESS_MAX_VERTICES]; int indices[TESS_MAX_INDICES]; byte colors[4*TESS_MAX_VERTICES]; int texnum[MAX_TMUS]; int numverts; int numindices; int flags; } tesselator_t; extern tesselator_t tess; void GL_StretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, const byte *color, image_t *image ); void GL_Flush2D( void ); void GL_DrawParticles( void ); void GL_DrawBeams( void ); void GL_AddFace( mface_t *face ); void GL_AddSolidFace( mface_t *face ); void GL_DrawAlphaFaces( void ); void GL_DrawSolidFaces( void ); /* * gl_world.c * */ extern vec3_t modelViewOrigin; void GL_MarkLeaves( void ); void GL_MarkLights( void ); void GL_DrawBspModel( mmodel_t *model ); void GL_DrawWorld( void ); qboolean GL_LightPoint( vec3_t origin, vec3_t color ); /* * gl_sky.c * */ void R_AddSkySurface( mface_t *surf ); void R_ClearSkyBox( void ); void R_DrawSkyBox( void ); void R_SetSky( const char *name, float rotate, vec3_t axis ); /* * gl_mesh.c * */ void GL_DrawAliasModel( model_t *model );