Skip to content

Commit

Permalink
Spearmint: CGame API 0.34
Browse files Browse the repository at this point in the history
Allow specifying shader for trap_R_AddLightToScene.
Allow specifying sort level for trap_R_AddPoly(s)ToScene.

Add trap_R_AddVertexLightToScene (ET vertex ball dlight).
Add trap_R_AddJuniorLightToScene (does not affect world surfaces).
  • Loading branch information
zturtleman committed Jun 9, 2015
1 parent aad1c92 commit a97cfac
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 18 deletions.
4 changes: 3 additions & 1 deletion code/cgame/cg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Suite 120, Rockville, Maryland 20850 USA.
// major 0 means each minor is an API break.
// major > 0 means each major is an API break and each minor extends API.
#define CG_API_MAJOR_VERSION 0
#define CG_API_MINOR_VERSION 33
#define CG_API_MINOR_VERSION 34


#define CMD_BACKUP 64
Expand Down Expand Up @@ -294,6 +294,8 @@ typedef enum {
CG_R_ADDPOLYTOSCENE,
CG_R_ADDLIGHTTOSCENE,
CG_R_ADDADDITIVELIGHTTOSCENE,
CG_R_ADDVERTEXLIGHTTOSCENE,
CG_R_ADDJUNIORLIGHTTOSCENE,
CG_R_ADDCORONATOSCENE,
CG_R_RENDERSCENE,
CG_R_SETCOLOR,
Expand Down
12 changes: 9 additions & 3 deletions code/client/cl_cgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,22 +1363,28 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
re.AddRefEntityToScene( VMA(1), args[2], args[3], VMA(4), args[5] );
return 0;
case CG_R_ADDPOLYTOSCENE:
re.AddPolyToScene( args[1], args[2], VMA(3), 1, args[4] );
re.AddPolyToScene( args[1], args[2], VMA(3), 1, args[4], args[5] );
return 0;
case CG_R_ADDPOLYSTOSCENE:
re.AddPolyToScene( args[1], args[2], VMA(3), args[4], args[5] );
re.AddPolyToScene( args[1], args[2], VMA(3), args[4], args[5], args[6] );
return 0;
case CG_R_ADDPOLYBUFFERTOSCENE:
re.AddPolyBufferToScene( VMA( 1 ) );
return 0;
case CG_R_LIGHTFORPOINT:
return re.LightForPoint( VMA(1), VMA(2), VMA(3), VMA(4) );
case CG_R_ADDLIGHTTOSCENE:
re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6) );
re.AddLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6), args[7] );
return 0;
case CG_R_ADDADDITIVELIGHTTOSCENE:
re.AddAdditiveLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6) );
return 0;
case CG_R_ADDVERTEXLIGHTTOSCENE:
re.AddVertexLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6) );
return 0;
case CG_R_ADDJUNIORLIGHTTOSCENE:
re.AddJuniorLightToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), VMF(6) );
return 0;
case CG_R_ADDCORONATOSCENE:
re.AddCoronaToScene( VMA(1), VMF(2), VMF(3), VMF(4), VMF(5), args[6], args[7], args[8] );
return 0;
Expand Down
6 changes: 4 additions & 2 deletions code/renderercommon/tr_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ typedef struct {
// Nothing is drawn until R_RenderScene is called.
void (*ClearScene)( void );
void (*AddRefEntityToScene)( const refEntity_t *re, int bufsize, int numVerts, const polyVert_t *verts, int numPolys );
void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum );
void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum, int sortLevel );
void (*AddPolyBufferToScene)( polyBuffer_t* pPolyBuffer );
int (*LightForPoint)( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
void (*AddLightToScene)( const vec3_t org, float radius, float intensity, float r, float g, float b );
void (*AddLightToScene)( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader );
void (*AddAdditiveLightToScene)( const vec3_t org, float radius, float intensity, float r, float g, float b );
void (*AddVertexLightToScene)( const vec3_t org, float radius, float intensity, float r, float g, float b );
void (*AddJuniorLightToScene)( const vec3_t org, float radius, float intensity, float r, float g, float b );
void (*AddCoronaToScene)( const vec3_t org, float r, float g, float b, float scale, int id, qboolean visible, qhandle_t hShader );
void (*RenderScene)( const refdef_t *fd, int bufsize );

Expand Down
2 changes: 2 additions & 0 deletions code/renderergl1/tr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,8 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp, qboolean headless )
re.LightForPoint = R_LightForPoint;
re.AddLightToScene = RE_AddLightToScene;
re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene;
re.AddVertexLightToScene = RE_AddVertexLightToScene;
re.AddJuniorLightToScene = RE_AddJuniorLightToScene;
re.AddCoronaToScene = RE_AddCoronaToScene;
re.RenderScene = RE_RenderScene;

Expand Down
6 changes: 4 additions & 2 deletions code/renderergl1/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1571,10 +1571,12 @@ qhandle_t RE_AddSkinToFrame( int numSurfaces, const qhandle_t *surfaces );

void RE_ClearScene( void );
void RE_AddRefEntityToScene( const refEntity_t *ent, int entBufSize, int numVerts, const polyVert_t *verts, int numPolys );
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum );
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum, int sortLevel );
void RE_AddPolyBufferToScene( polyBuffer_t* pPolyBuffer );
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader );
void RE_AddAdditiveLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddVertexLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddJuniorLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddCoronaToScene( const vec3_t org, float r, float g, float b, float scale, int id, qboolean visible, qhandle_t hShader );
void RE_RenderScene( const refdef_t *fd, int fdSize );

Expand Down
27 changes: 23 additions & 4 deletions code/renderergl1/tr_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,9 @@ RE_AddPolyToScene
=====================
*/
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum ) {
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum, int sortLevel ) {
srfPoly_t *poly;
int j;
int sortLevel = 0; // ZTM: TODO: make this an argument, breaks renderer API compatibility

if ( !tr.registered ) {
return;
Expand Down Expand Up @@ -473,8 +472,8 @@ RE_AddLightToScene
=====================
*/
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT, 0 );
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT, hShader );
}

/*
Expand All @@ -487,6 +486,26 @@ void RE_AddAdditiveLightToScene( const vec3_t org, float radius, float intensity
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT | REF_ADDITIVE_DLIGHT, 0 );
}

/*
=====================
RE_AddVertexLightToScene
=====================
*/
void RE_AddVertexLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT | REF_VERTEX_DLIGHT, 0 );
}

/*
=====================
RE_AddJuniorLightToScene
=====================
*/
void RE_AddJuniorLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT, 0 );
}

/*
==============
RE_AddCoronaToScene
Expand Down
2 changes: 2 additions & 0 deletions code/renderergl2/tr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,8 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp, qboolean headless )
re.LightForPoint = R_LightForPoint;
re.AddLightToScene = RE_AddLightToScene;
re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene;
re.AddVertexLightToScene = RE_AddVertexLightToScene;
re.AddJuniorLightToScene = RE_AddJuniorLightToScene;
re.AddCoronaToScene = RE_AddCoronaToScene;
re.RenderScene = RE_RenderScene;

Expand Down
6 changes: 4 additions & 2 deletions code/renderergl2/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -2448,10 +2448,12 @@ qhandle_t RE_AddSkinToFrame( int numSurfaces, const qhandle_t *surfaces );

void RE_ClearScene( void );
void RE_AddRefEntityToScene( const refEntity_t *ent, int entBufSize, int numVerts, const polyVert_t *verts, int numPolys );
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum );
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum, int sortLevel );
void RE_AddPolyBufferToScene( polyBuffer_t* pPolyBuffer );
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader );
void RE_AddAdditiveLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddVertexLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddJuniorLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b );
void RE_AddCoronaToScene( const vec3_t org, float r, float g, float b, float scale, int id, qboolean visible, qhandle_t hShader );
void RE_BeginScene( const refdef_t *fd );
void RE_RenderScene( const refdef_t *fd, int fdSize );
Expand Down
27 changes: 23 additions & 4 deletions code/renderergl2/tr_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,9 @@ RE_AddPolyToScene
=====================
*/
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum ) {
void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys, int bmodelNum, int sortLevel ) {
srfPoly_t *poly;
int j;
int sortLevel = 0; // ZTM: TODO: make this an argument, breaks renderer API compatibility

if ( !tr.registered ) {
return;
Expand Down Expand Up @@ -478,8 +477,8 @@ RE_AddLightToScene
=====================
*/
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT, 0 );
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT, hShader );
}

/*
Expand All @@ -492,6 +491,26 @@ void RE_AddAdditiveLightToScene( const vec3_t org, float radius, float intensity
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT | REF_ADDITIVE_DLIGHT, 0 );
}

/*
=====================
RE_AddVertexLightToScene
=====================
*/
void RE_AddVertexLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT | REF_SURFACE_DLIGHT | REF_VERTEX_DLIGHT, 0 );
}

/*
=====================
RE_AddJuniorLightToScene
=====================
*/
void RE_AddJuniorLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b ) {
RE_AddDynamicLightToScene( org, radius, intensity, r, g, b, REF_GRID_DLIGHT, 0 );
}

/*
==============
RE_AddCoronaToScene
Expand Down

0 comments on commit a97cfac

Please sign in to comment.