-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathRefAPI.h
More file actions
236 lines (187 loc) · 9.31 KB
/
RefAPI.h
File metadata and controls
236 lines (187 loc) · 9.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/*
===========================================================================
Daemon GPL Source Code
Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
Copyright (C) 2006-2010 Robert Beckebans
This file is part of the Daemon GPL Source Code (Daemon Source Code).
Daemon Source Code 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.
Daemon Source Code 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 Daemon Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Daemon Source Code is also subject to certain additional terms.
You should have received a copy of these additional terms immediately following the
terms and conditions of the GNU General Public License which accompanied the Daemon
Source Code. If not, please request a copy in writing from id Software at the address
below.
If you have questions concerning this license or the applicable additional terms, you
may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville,
Maryland 20850 USA.
===========================================================================
*/
// RefAPI.h
#ifndef REF_API_H
#define REF_API_H
#include <string>
#include "renderer/tr_types.h"
#define REF_API_VERSION 10
extern Cvar::Modified<Cvar::Cvar<bool>> r_fullscreen;
// font support
struct glyphInfo_t
{
int height; // number of scan lines
int top; // top of glyph in buffer
int bottom; // bottom of glyph in buffer
int pitch; // width for copying
int xSkip; // x adjustment
int imageWidth; // width of actual image
int imageHeight; // height of actual image
float s; // x offset in image where glyph starts
float t; // y offset in image where glyph starts
float s2;
float t2;
qhandle_t glyph; // handle to the shader with the glyph
char shaderName[ 32 ];
};
struct fontInfo_t
{
void *face, *faceData;
glyphInfo_t *glyphBlock[0x110000 / 256]; // glyphBlock_t
int pointSize;
char name[ MAX_QPATH ];
};
//
// these are the functions exported by the refresh module
//
struct refexport_t {
// called before the library is unloaded
// if the system is just reconfiguring, pass destroyWindow = false,
// which will keep the screen from flashing to the desktop.
void ( *Shutdown )( bool destroyWindow );
// All data that will be used in a level should be
// registered before rendering any frames to prevent disk hits,
// but they can still be registered at a later time
// if necessary.
//
// BeginRegistration makes any existing media pointers invalid
// and returns the current gl configuration, including screen width
// and height, which can be used by the client to intelligently
// size display elements. Returns false if the renderer couldn't
// be initialized.
bool( *BeginRegistration )( WindowConfig* windowCfg );
qhandle_t( *RegisterModel )( const char* name );
//qhandle_t (*RegisterModelAllLODs) (const char *name);
qhandle_t( *RegisterSkin )( const char* name );
qhandle_t( *RegisterShader )( const char* name, int flags );
fontInfo_t* ( *RegisterFont )( const char* fontName, int pointSize );
void ( *UnregisterFont )( fontInfo_t* font );
void ( *GlyphChar )( fontInfo_t* font, int ch, glyphInfo_t* glyph );
void ( *LoadWorld )( const char* name );
// the vis data is a large enough block of data that we go to the trouble
// of sharing it with the clipmodel subsystem
void ( *SetWorldVisData )( const byte* vis );
// EndRegistration will draw a tiny polygon with each texture, forcing
// them to be loaded into card memory
void ( *EndRegistration )( );
// a scene is built up by calls to R_ClearScene and the various R_Add functions.
// Nothing is drawn until R_RenderScene is called.
void ( *ClearScene )( );
void ( *AddRefEntityToScene )( const refEntity_t* re );
void ( *AddPolyToScene )( qhandle_t hShader, int numVerts, const polyVert_t* verts );
void ( *AddPolysToScene )( qhandle_t hShader, int numVerts, const polyVert_t* verts, int numPolys );
void ( *AddLightToScene )( const vec3_t org, float radius, float r, float g, float b, int flags );
void ( *AddAdditiveLightToScene )( const vec3_t org, float intensity, float r, float g, float b );
void ( *RenderScene )( const refdef_t* fd );
void ( *SetColor )( const Color::Color& rgba ); // nullptr = 1,1,1,1
void ( *SetClipRegion )( const float* region );
void ( *DrawStretchPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); // 0 = white
void ( *DrawRotatedPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle ); // NERVE - SMF
void ( *DrawStretchPicGradient )( float x, float y, float w, float h, float s1, float t1, float s2, float t2,
qhandle_t hShader, const Color::Color& gradientColor, int gradientType );
void ( *Add2dPolys )( polyVert_t* polys, int numverts, qhandle_t hShader );
void ( *BeginFrame )( );
// if the pointers are not nullptr, timing info will be returned
void ( *EndFrame )( int* frontEndMsec, int* backEndMsec );
int ( *MarkFragments )( int numPoints, const vec3_t* points, const vec3_t projection,
int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t* fragmentBuffer );
int ( *LerpTag )( orientation_t* tag, const refEntity_t* refent, const char* tagName, int startIndex );
void ( *ModelBounds )( qhandle_t model, vec3_t mins, vec3_t maxs );
void ( *RemapShader )( const char* oldShader, const char* newShader, const char* offsetTime );
bool( *inPVS )( const vec3_t p1, const vec3_t p2 );
bool( *inPVVS )( const vec3_t p1, const vec3_t p2 );
// XreaL BEGIN
void ( *TakeVideoFrame )( int h, int w, byte* captureBuffer, byte* encodeBuffer, bool motionJpeg );
// RB: alternative skeletal animation system
qhandle_t( *RegisterAnimation )( const char* name );
int ( *CheckSkeleton )( refSkeleton_t* skel, qhandle_t model, qhandle_t anim );
int ( *BuildSkeleton )( refSkeleton_t* skel, qhandle_t anim, int startFrame, int endFrame, float frac,
bool clearOrigin );
int ( *BlendSkeleton )( refSkeleton_t* skel, const refSkeleton_t* blend, float frac );
int ( *BoneIndex )( qhandle_t hModel, const char* boneName );
int ( *AnimNumFrames )( qhandle_t hAnim );
int ( *AnimFrameRate )( qhandle_t hAnim );
// XreaL END
// VisTest API
qhandle_t( *RegisterVisTest ) ( );
void ( *AddVisTestToScene ) ( qhandle_t hTest, const vec3_t pos,
float depthAdjust, float area );
float ( *CheckVisibility ) ( qhandle_t hTest );
void ( *UnregisterVisTest ) ( qhandle_t hTest );
// color grading
void ( *SetColorGrading ) ( int slot, qhandle_t hShader );
void ( *ScissorEnable ) ( bool enable );
void ( *ScissorSet ) ( int x, int y, int w, int h );
void ( *SetAltShaderTokens ) ( const char* );
void ( *GetTextureSize )( int textureID, int* width, int* height );
void ( *Add2dPolysIndexed )( polyVert_t* polys, int numverts, int* indexes, int numindexes, int trans_x, int trans_y, qhandle_t shader );
qhandle_t( *GenerateTexture )( const byte* pic, int width, int height );
const char* ( *ShaderNameFromHandle )( qhandle_t shader );
void ( *SendBotDebugDrawCommands )( std::vector<char> commands );
void ( *SetMatrixTransform )( const matrix_t matrix );
void ( *ResetMatrixTransform )( );
};
//
// these are the functions imported by the refresh module
//
struct refimport_t {
// milliseconds should only be used for profiling, never
// for anything game related. Get time from the refdef
int ( *Milliseconds )( );
int ( *RealTime )( qtime_t* qtime );
// stack based memory allocation for per-level things that
// won't be freed
void* ( *Hunk_Alloc )( int size, ha_pref pref );
void* ( *Hunk_AllocateTempMemory )( int size );
void ( *Hunk_FreeTempMemory )( void* block );
// a -1 return means the file does not exist
// nullptr can be passed for buf to just determine existence
int ( *FS_ReadFile )( const char* name, void** buf );
void ( *FS_FreeFile )( void* buf );
char** ( *FS_ListFiles )( const char* name, const char* extension, int* numfilesfound );
void ( *FS_FreeFileList )( char** filelist );
void ( *FS_WriteFile )( const char* qpath, const void* buffer, int size );
int ( *FS_Seek )( fileHandle_t f, long offset, fsOrigin_t origin );
int ( *FS_FTell )( fileHandle_t f );
int ( *FS_Read )( void* buffer, int len, fileHandle_t f );
int ( *FS_FCloseFile )( fileHandle_t f );
int ( *FS_FOpenFileRead )( const char* qpath, fileHandle_t* file );
// XreaL BEGIN
bool( *CL_VideoRecording )( );
void ( *CL_WriteAVIVideoFrame )( const byte* buffer, int size );
// XreaL END
// input event handling
void ( *IN_Init )( void* windowData );
void ( *IN_Shutdown )( );
void ( *IN_Restart )( );
};
// this is the only function actually exported at the linker level
// If the module can't init to a valid rendering state, nullptr will be
// returned.
// RB: changed to GetRefAPI_t
using GetRefAPI_t = refexport_t * ( * )( int apiVersion, refimport_t* rimp );
#endif // REF_API_H