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/public/render_api.h

129 lines
4.5 KiB
C

//=======================================================================
// Copyright XashXT Group 2008 ©
// render_api.h - xash renderer api
//=======================================================================
#ifndef RENDER_API_H
#define RENDER_API_H
#include "ref_params.h"
// shader types used for shader loading
#define SHADER_SKY 1 // sky box shader
#define SHADER_FONT 2 // special case for displayed fonts
#define SHADER_NOMIP 3 // 2d images
#define SHADER_GENERIC 4 // generic shader
// screenshot types
#define VID_SCREENSHOT 0
#define VID_LEVELSHOT 1
#define VID_SAVESHOT 2
// render supported extensions
#define R_WGL_SWAPCONTROL 1
#define R_HARDWARE_GAMMA_CONTROL 2
#define R_ARB_VERTEX_BUFFER_OBJECT_EXT 3
#define R_ENV_COMBINE_EXT 4
#define R_ARB_MULTITEXTURE 5
#define R_TEXTURECUBEMAP_EXT 6
#define R_DOT3_ARB_EXT 7
#define R_ANISOTROPY_EXT 8
#define R_TEXTURE_LODBIAS 9
#define R_OCCLUSION_QUERIES_EXT 10
#define R_TEXTURE_COMPRESSION_EXT 11
#define R_SHADER_GLSL100_EXT 12
typedef struct
{
int numverts;
vec3_t *verts;
vec2_t *stcoords;
rgba_t *colors;
union
{
struct ref_shader_s *shader;
shader_t shadernum;
};
int fognum;
vec3_t normal;
} poly_t;
typedef struct
{
int firstvert;
int numverts; // can't exceed MAX_POLY_VERTS
int fognum; // -1 - do not bother adding fog later at rendering stage
// 0 - determine fog later
// >0 - valid fog volume number returned by R_GetClippedFragments
vec3_t normal;
} fragment_t;
/*
==============================================================================
RENDER.DLL INTERFACE
==============================================================================
*/
typedef struct render_exp_s
{
// interface validator
size_t api_size; // must matched with sizeof(render_exp_t)
size_t com_size; // must matched with sizeof(stdlib_api_t)
// initialize
bool (*Init)( bool full ); // init all render systems
void (*Shutdown)( bool full ); // shutdown all render systems
void (*BeginRegistration)( const char *map, const dvis_t *visData );
bool (*RegisterModel)( const char *name, int cl_index ); // also build replacement index table
shader_t (*RegisterShader)( const char *name, int shaderType );
void (*EndRegistration)( const char *skyname );
// prepare frame to rendering
bool (*AddRefEntity)( edict_t *pRefEntity, int ed_type );
bool (*AddDynLight)( const void *dlight );
bool (*AddPolygon)( const poly_t *poly );
bool (*AddLightStyle)( int stylenum, vec3_t color );
void (*ClearScene)( void );
void (*BeginFrame)( const ref_params_t *fd );
void (*RenderFrame)( const ref_params_t *fd );
void (*EndFrame)( void );
// misc utilities
void (*SetColor)( const rgba_t color );
void (*SetParms)( shader_t handle, kRenderMode_t rendermode, int frame );
void (*GetParms)( int *w, int *h, int *frames, int frame, shader_t shader );
bool (*ScrShot)( const char *filename, int shot_type ); // write screenshot with same name
bool (*EnvShot)( const char *filename, uint size, bool skyshot ); // write envshot with same name
void (*LightForPoint)( const vec3_t point, vec3_t ambientLight );
void (*DrawFill)( float x, float y, float w, float h );
void (*DrawStretchRaw)( int x, int y, int w, int h, int cols, int rows, byte *data, bool redraw );
void (*DrawStretchPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, shader_t shader );
int (*GetFragments)( const vec3_t org, float rad, vec3_t axis[3], int maxverts, vec3_t *verts, int maxfrags, fragment_t *frags );
int (*WorldToScreen)( const float *world, float *screen );
void (*ScreenToWorld)( const float *screen, float *world );
bool (*RSpeedsMessage)( char *out, size_t size );
bool (*Support)( int extension );
} render_exp_t;
typedef struct render_imp_s
{
// interface validator
size_t api_size; // must matched with sizeof(render_imp_t)
// client fundamental callbacks
void (*UpdateScreen)( void ); // update screen while loading
void (*StudioEvent)( dstudioevent_t *event, edict_t *ent );
void (*StudioFxTransform)( edict_t *ent, float matrix[4][4] );
void (*ShowCollision)( cmdraw_t callback ); // debug
bool (*Trace)( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end );
long (*WndProc)( void *hWnd, uint uMsg, uint wParam, long lParam );
edict_t *(*GetClientEdict)( int index );
edict_t *(*GetLocalPlayer)( void );
int (*GetMaxClients)( void );
float (*GetLerpFrac)( void );
} render_imp_t;
#endif//RENDER_API_H