Skip to content

Commit

Permalink
ref: gl: implement mirrors
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Jan 15, 2024
1 parent 52978fb commit a2efa92
Show file tree
Hide file tree
Showing 8 changed files with 708 additions and 11 deletions.
2 changes: 2 additions & 0 deletions ref/gl/gl_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void GL_BackendEndFrame( void )
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i tempents\n%3i viewbeams\n%3i particles",
r_stats.c_active_tents_count, r_stats.c_view_beams_count, r_stats.c_particle_count );
break;
case 6:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i mirrors\n", r_stats.c_mirror_passes );
}

memset( &r_stats, 0, sizeof( r_stats ));
Expand Down
26 changes: 24 additions & 2 deletions ref/gl/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ extern poolhandle_t r_temppool;
#define SUBDIVIDE_SIZE 64
#define MAX_DECAL_SURFS 4096
#define MAX_DRAW_STACK 2 // normal view and menu view
#define MAX_MIRRORS 32 // per frame
#define MAX_MIRROR_ENTITIES MAX_VISIBLE_PACKET

#define SHADEDOT_QUANT 16 // precalculated dot products for quantized angles
#define SHADE_LAMBERT 1.4953241
Expand Down Expand Up @@ -137,6 +139,13 @@ typedef struct gltexture_s
struct gltexture_s *nextHash;
} gl_texture_t;

// mirror entity
typedef struct
{
cl_entity_t *ent;
mextrasurf_t *chain;
} gl_entity_t;

typedef struct
{
int params; // rendering parameters
Expand Down Expand Up @@ -201,9 +210,11 @@ 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];
gl_entity_t mirror_entities[MAX_MIRROR_ENTITIES]; // an entities that has mirror
uint num_solid_entities;
uint num_trans_entities;
uint num_beam_entities;
uint num_mirror_entities;
} draw_list_t;

typedef struct
Expand All @@ -219,6 +230,8 @@ typedef struct
int dlightTexture; // custom dlight texture
int skyboxTextures[SKYBOX_MAX_SIDES]; // skybox sides
int cinTexture; // cinematic texture
int mirrorTextures[MAX_MIRRORS];
int num_mirrors_used;

int skytexturenum; // this not a gl_texturenum!
int skyboxbasenum; // start with 5800
Expand Down Expand Up @@ -281,6 +294,8 @@ typedef struct
uint c_client_ents; // entities that moved to client
double t_world_node;
double t_world_draw;

uint c_mirror_passes;
} ref_speeds_t;

extern ref_speeds_t r_stats;
Expand Down Expand Up @@ -499,7 +514,7 @@ void R_InitRipples( void );
void R_ResetRipples( void );
void R_AnimateRipples( void );
void R_UpdateRippleTexParams( void );
void R_UploadRipples( texture_t *image );
void R_UploadRipples( texture_t *image, qboolean is_mirror );

//
// gl_vgui.c
Expand All @@ -518,7 +533,13 @@ void VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr );
void VGUI_GetTextureSizes( int *width, int *height );
int VGUI_GenerateTexture( void );

//#include "vid_common.h"
//
// gl_mirror.c
//
void R_BeginDrawMirror( msurface_t *fa );
void R_EndDrawMirror( void );
void R_DrawMirrors( void );
void R_FindMirrors( void );

//
// renderer exports
Expand Down Expand Up @@ -769,6 +790,7 @@ extern convar_t gl_test; // cvar to testify new effects
extern convar_t gl_msaa;
extern convar_t gl_stencilbits;
extern convar_t gl_overbright;
extern convar_t gl_allow_mirrors;

extern convar_t r_lighting_extended;
extern convar_t r_lighting_ambient;
Expand Down
Loading

0 comments on commit a2efa92

Please sign in to comment.