UFO: Alien Invasion
cl_renderer.h
Go to the documentation of this file.
1
5/*
6All original material Copyright (C) 2002-2022 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#pragma once
26
27#include "renderer/r_image.h"
28#include "renderer/r_model.h"
29#include "renderer/r_program.h"
30
31#include <SDL.h>
32
33/* e.g. used for sequences and particle editor */
34#define RDF_NOWORLDMODEL 1
35#define RDF_IRGOGGLES 2
37#define WEATHER_NONE 0
38#define WEATHER_FOG 1
39
40#define VID_NORM_WIDTH 1024
41#define VID_NORM_HEIGHT 768
42
43#define MAX_PTL_ART 1024
44#define MAX_PTLS 2048
45
47typedef struct corona_s {
49 float radius;
51} corona_t;
52
53#define MAX_CORONAS 128
54
55#define MAX_GL_LIGHTS 8
56
57typedef struct {
59 const char* name;
61 float* origin;
62 float* angles;
63 float* scale;
64 float* center;
66 int frame, oldframe;
67 float backlerp;
69 int skin;
70 int mesh;
71 float* color;
73
74typedef struct ptlCmd_s {
75 byte cmd;
76 byte type;
77 int ref;
79} ptlCmd_t;
80
81typedef struct ptlDef_s {
82 char name[MAX_VAR];
88} ptlDef_t;
89
91typedef enum artType_s {
95
96typedef struct ptlArt_s {
97 char name[MAX_VAR];
98 int frame;
99 int skin;
100 union {
103 } art;
105} ptlArt_t;
106
107typedef struct ptl_s {
108 bool inuse;
109 bool invis;
129
130 int skin;
132 struct ptl_s* children;
133 struct ptl_s* next;
134 struct ptl_s* parent;
136 /* private */
139 int frame, endFrame;
140 float fps;
141 float lastFrame;
142 float tps;
144 fade_t thinkFade, frameFade;
145 float t;
146 float dt;
147 float life;
148 int rounds;
150 float scrollS;
151 float scrollT;
156 bool physics;
157 bool autohide;
161 bool weather;
163 bool hitSolid;
164 bool stick;
165 bool bounce;
166} ptl_t;
167
168typedef struct {
169 bool ready;
171 float fieldOfViewX, fieldOfViewY;
174 float time;
177 int brushCount, aliasCount, batchCount;
178 int FFPToShaderCount, shaderToShaderCount, shaderToFFPCount;
179
188 /* entity, dynamic lights and corona lists are repopulated each frame, don't use them as persistent */
191 light_t dynamicLights[MAX_GL_LIGHTS];
192
193 /* static lights (populated when loading the world) */
196
199
201 struct entity_s* traceEntity;
202
205
207
208/* threading state */
209typedef enum {
216
217typedef enum {
221
224
225typedef struct renderer_threadstate_s {
226 SDL_Thread* thread;
229
231
232void R_Color(const vec4_t rgba);
233
234void R_ModBeginLoading(const char* tiles, bool day, const char* pos, const char* mapName, const char* mapZone);
235void R_SwitchModelMemPoolTag(void);
236
237void R_LoadImage(const char* name, byte** pic, int* width, int* height);
238
239void R_FontShutdown(void);
240void R_FontInit(void);
241void R_FontRegister(const char* name, int size, const char* path, const char* style);
242void R_FontSetTruncationMarker(const char* marker);
243
244void R_FontTextSize(const char* fontId, const char* text, int maxWidth, longlines_t method, int* width, int* height, int* lines, bool* isTruncated);
245int R_FontDrawString(const char* fontId, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char* c, int boxHeight, int scrollPos, int* curLine, longlines_t method);
threadstate_t
Definition: cl_renderer.h:209
@ THREAD_DEAD
Definition: cl_renderer.h:210
@ THREAD_RENDERER
Definition: cl_renderer.h:214
@ THREAD_IDLE
Definition: cl_renderer.h:211
@ THREAD_BSP
Definition: cl_renderer.h:213
@ THREAD_CLIENT
Definition: cl_renderer.h:212
void R_FontInit(void)
Definition: r_font.cpp:722
void R_FontTextSize(const char *fontId, const char *text, int maxWidth, longlines_t method, int *width, int *height, int *lines, bool *isTruncated)
Supply information about the size of the text when it is linewrapped and rendered,...
Definition: r_font.cpp:524
longlines_t
Definition: cl_renderer.h:217
@ LONGLINES_WRAP
Definition: cl_renderer.h:218
@ LONGLINES_LAST
Definition: cl_renderer.h:222
@ LONGLINES_CHOP
Definition: cl_renderer.h:219
@ LONGLINES_PRETTYCHOP
Definition: cl_renderer.h:220
void R_FontSetTruncationMarker(const char *marker)
Definition: r_font.cpp:112
void R_SwitchModelMemPoolTag(void)
After all static models are loaded, switch the pool tag for these models to not free them everytime R...
Definition: r_model.cpp:299
renderer_threadstate_t r_threadstate
Definition: r_thread.cpp:34
int R_FontDrawString(const char *fontId, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char *c, int boxHeight, int scrollPos, int *curLine, longlines_t method)
Definition: r_font.cpp:687
void R_FontRegister(const char *name, int size, const char *path, const char *style)
Definition: r_font.cpp:750
void R_ModBeginLoading(const char *tiles, bool day, const char *pos, const char *mapName, const char *mapZone)
Specifies the model that will be used as the world.
void R_LoadImage(const char *name, byte **pic, int *width, int *height)
Generic image-data loading fucntion.
Definition: r_image.cpp:152
#define MAX_GL_LIGHTS
Definition: cl_renderer.h:55
void R_FontShutdown(void)
frees the SDL_ttf fonts
Definition: r_font.cpp:144
rendererData_t refdef
Definition: r_main.cpp:45
#define MAX_CORONAS
Definition: cl_renderer.h:53
void R_Color(const vec4_t rgba)
Change the color to given value.
Definition: r_state.cpp:1011
artType_t
particle art type
Definition: cl_renderer.h:91
@ ART_MODEL
Definition: cl_renderer.h:93
@ ART_PIC
Definition: cl_renderer.h:92
voidpf void uLong size
Definition: ioapi.h:42
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
#define MAX_STATIC_LIGHTS
Definition: r_light.h:47
Brush model header file.
style_t
Definition: scripts.h:124
align_t
We need this here for checking the boundaries from script values.
Definition: scripts.h:89
blend_t
Definition: scripts.h:113
fade_t
Definition: scripts.h:135
#define MAX_VAR
Definition: shared.h:36
coronas are soft, alpha-blended, rounded polys
Definition: cl_renderer.h:47
vec3_t color
Definition: cl_renderer.h:50
vec3_t org
Definition: cl_renderer.h:48
float radius
Definition: cl_renderer.h:49
a light source
Definition: r_light.h:29
float * origin
Definition: cl_renderer.h:61
float * center
Definition: cl_renderer.h:64
float * angles
Definition: cl_renderer.h:62
float backlerp
Definition: cl_renderer.h:67
const char * name
Definition: cl_renderer.h:59
float * color
Definition: cl_renderer.h:71
model_t * model
Definition: cl_renderer.h:58
float * scale
Definition: cl_renderer.h:63
bool hitSolid
Definition: cl_renderer.h:163
vec3_t scale
Definition: cl_renderer.h:119
vec3_t offset
Definition: cl_renderer.h:123
vec4_t color
Definition: cl_renderer.h:120
bool physics
Definition: cl_renderer.h:156
float fps
Definition: cl_renderer.h:140
struct ptl_s * parent
Definition: cl_renderer.h:134
float lightIntensity
Definition: cl_renderer.h:126
ptlArt_t * model
Definition: cl_renderer.h:114
vec2_t size
Definition: cl_renderer.h:118
float t
Definition: cl_renderer.h:145
bool stick
Definition: cl_renderer.h:164
ptlArt_t * pic
Definition: cl_renderer.h:113
vec3_t lightColor
Definition: cl_renderer.h:125
vec3_t angles
Definition: cl_renderer.h:124
vec3_t oldV
Definition: cl_renderer.h:154
vec3_t a
Definition: cl_renderer.h:152
float lastFrame
Definition: cl_renderer.h:141
bool invis
Definition: cl_renderer.h:109
int rounds
Definition: cl_renderer.h:148
bool weather
Definition: cl_renderer.h:161
float scrollT
Definition: cl_renderer.h:151
fade_t frameFade
Definition: cl_renderer.h:144
vec3_t s
Definition: cl_renderer.h:121
struct ptl_s * next
Definition: cl_renderer.h:133
blend_t blend
Definition: cl_renderer.h:116
float dt
Definition: cl_renderer.h:146
vec3_t v
Definition: cl_renderer.h:153
int endFrame
Definition: cl_renderer.h:139
int skin
Definition: cl_renderer.h:130
bool autohide
Definition: cl_renderer.h:157
bool stayalive
Definition: cl_renderer.h:160
bool bounce
Definition: cl_renderer.h:165
int levelFlags
Definition: cl_renderer.h:128
bool inuse
Definition: cl_renderer.h:108
float tps
Definition: cl_renderer.h:142
int roundsCnt
Definition: cl_renderer.h:149
float scrollS
Definition: cl_renderer.h:150
ptlDef_t * ctrl
Definition: cl_renderer.h:137
style_t style
Definition: cl_renderer.h:117
struct ptl_s * children
Definition: cl_renderer.h:132
float lightSustain
Definition: cl_renderer.h:127
vec3_t origin
Definition: cl_renderer.h:122
float lastThink
Definition: cl_renderer.h:143
float life
Definition: cl_renderer.h:147
r_program_t * program
Definition: cl_renderer.h:111
vec3_t omega
Definition: cl_renderer.h:155
int startTime
Definition: cl_renderer.h:138
const image_t * image
Definition: cl_renderer.h:101
artType_t type
Definition: cl_renderer.h:104
int frame
Definition: cl_renderer.h:98
int skin
Definition: cl_renderer.h:99
model_t * model
Definition: cl_renderer.h:102
byte cmd
Definition: cl_renderer.h:75
byte type
Definition: cl_renderer.h:76
ptlCmd_t * run
Definition: cl_renderer.h:84
ptlCmd_t * think
Definition: cl_renderer.h:85
ptlCmd_t * round
Definition: cl_renderer.h:86
ptlCmd_t * init
Definition: cl_renderer.h:83
ptlCmd_t * physics
Definition: cl_renderer.h:87
threadstate_t state
Definition: cl_renderer.h:227
float fieldOfViewX
Definition: cl_renderer.h:171
vec4_t ambientColor
Definition: cl_renderer.h:182
vec4_t sunSpecularColor
Definition: cl_renderer.h:185
vec4_t modelAmbientColor
Definition: cl_renderer.h:183
vec3_t viewOrigin
Definition: cl_renderer.h:172
vec3_t viewAngles
Definition: cl_renderer.h:173
vec4_t sunDiffuseColor
Definition: cl_renderer.h:184
mapTiles_t * mapTiles
Definition: cl_renderer.h:203
vec4_t sunVector
Definition: cl_renderer.h:186
struct entity_s * traceEntity
Definition: cl_renderer.h:201
static const char * mapName
vec_t vec3_t[3]
Definition: ufotypes.h:39
vec_t vec4_t[4]
Definition: ufotypes.h:40
vec_t vec2_t[2]
Definition: ufotypes.h:38