UFO: Alien Invasion
Loading...
Searching...
No Matches
r_state.h
Go to the documentation of this file.
1
5
6/*
7All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26#pragma once
27
28#include "../../shared/cxx.h"
29
30#include "r_program.h"
31#include "r_material.h"
32#include "r_framebuffer.h"
33#include "r_light.h"
34#include "r_image.h"
35
41#define SKYBOX_DEPTH -9999.0f
42
43/* vertex arrays are used for many things */
44#define GL_ARRAY_LENGTH_CHUNK 4096
45extern const vec2_t default_texcoords[4];
46
48typedef struct gltexunit_s {
49 bool enabled;
54 /* Size of the array above - it's dynamically reallocated */
57
58#define MAX_GL_TEXUNITS 6
59
60/* these are defined for convenience */
61#define texunit_0 r_state.texunits[0]
62#define texunit_1 r_state.texunits[1]
63#define texunit_2 r_state.texunits[2]
64#define texunit_3 r_state.texunits[3]
65#define texunit_4 r_state.texunits[4]
66#define texunit_5 r_state.texunits[5]
67
68#define texunit_diffuse texunit_0
69#define texunit_lightmap texunit_1
70#define texunit_deluxemap texunit_2
71#define texunit_normalmap texunit_3
72#define texunit_glowmap texunit_4
73#define texunit_specularmap texunit_5
74#define texunit_roughnessmap texunit_2
75
76#define COMPONENTS_VERTEX_ARRAY3D 3
77#define COMPONENTS_VERTEX_ARRAY2D 2
78#define COMPONENTS_COLOR_ARRAY 4
79#define COMPONENTS_INDEX_ARRAY 1
80#define COMPONENTS_NORMAL_ARRAY 3
81#define COMPONENTS_TANGENT_ARRAY 4
82#define COMPONENTS_TEXCOORD_ARRAY 2
83
84#define DOWNSAMPLE_PASSES 5
85#define DOWNSAMPLE_SCALE 2
86
87#define fbo_screen nullptr
88#define fbo_render r_state.renderBuffer
89#define fbo_bloom0 r_state.bloomBuffer0
90#define fbo_bloom1 r_state.bloomBuffer1
91
92#define default_program nullptr
93
94struct mAliasMesh_s;
95
96typedef struct rstate_s {
98
99 /* arrays */
102 GLfloat* color_array;
104 GLfloat* normal_array;
109
110 /* Size of all arrays above - it's dynamically reallocated */
112
113 /* multitexture texunits */
115
116 /* texunit in use */
118
119 /* framebuffer objects*/
128
129 /* shaders */
141
142 /* blend function */
144
146
147 /* states */
165
166 const struct image_s* active_normalmap;
167} rstate_t;
168
169extern rstate_t r_state;
170
171void R_SetDefaultState(void);
172void R_Setup2D(void);
173void R_Setup3D(void);
175void R_ReallocateTexunitArray(gltexunit_t* texunit, int size);
176
177void R_TexEnv(GLenum value);
178void R_TexOverride (vec4_t rgba);
179void R_BlendFunc(GLenum src, GLenum dest);
180
181bool R_SelectTexture(gltexunit_t* texunit);
182
183void R_BindTextureDebug(int texnum, const char* file, int line, const char* function);
184#define R_BindTexture(tn) R_BindTextureDebug(tn, __FILE__, __LINE__, __PRETTY_FUNCTION__)
185void R_BindTextureForTexUnit(GLuint texnum, gltexunit_t* texunit);
186void R_BindLightmapTexture(GLuint texnum);
187void R_BindDeluxemapTexture(GLuint texnum);
188void R_BindNormalmapTexture(GLuint texnum);
189void R_BindBuffer(GLenum target, GLenum type, GLuint id);
190void R_BindArray(GLenum target, GLenum type, const void* array);
191void R_BindDefaultArray(GLenum target);
192void R_EnableStencilTest(bool enable);
193void R_EnableTexture(gltexunit_t* texunit, bool enable);
194void R_EnableMultisample(bool enable);
195void R_EnableBlend(bool enable);
196void R_EnableAlphaTest(bool enable);
197void R_EnableColorArray(bool enable);
198bool R_EnableLighting(r_program_t* program, bool enable);
199void R_EnableBumpmap(const struct image_s* normalmap);
200void R_EnableWarp(r_program_t* program, bool enable);
201void R_EnableBlur(r_program_t* program, bool enable, r_framebuffer_t* source, r_framebuffer_t* dest, int dir);
202void R_EnableShell(bool enable);
203void R_EnableFog(bool enable);
204void R_EnableDrawAsGlow(bool enable);
205void R_EnableGlowMap(const struct image_s* image);
206void R_EnableSpecularMap(const struct image_s* image, bool enable);
207void R_EnableRoughnessMap(const struct image_s* image, bool enable);
208void R_SetupSpotLight(int index, const light_t* light);
209void R_DisableSpotLight(int index);
210void R_EnableAnimation(const struct mAliasMesh_s* mesh, float backlerp, bool enable);
211
212void R_UseMaterial (const material_t* material);
voidpf void uLong size
Definition ioapi.h:42
QGL_EXTERN GLenum GLuint * dest
Definition r_gl.h:101
QGL_EXTERN GLint
Definition r_gl.h:135
QGL_EXTERN GLuint index
Definition r_gl.h:110
QGL_EXTERN GLint GLenum type
Definition r_gl.h:94
QGL_EXTERN GLuint
Definition r_gl.h:124
QGL_EXTERN const GLuint *QGL_EXTERN GLuint *QGL_EXTERN GLenum
Definition r_gl.h:127
rstate_t r_state
Definition r_main.cpp:48
Header file for the render material subsystem.
#define MAX_SHADERS
Definition r_program.h:66
#define MAX_PROGRAMS
Definition r_program.h:65
const vec2_t default_texcoords[4]
Definition r_state.cpp:30
void R_EnableAlphaTest(bool enable)
Definition r_state.cpp:277
void R_BindBuffer(GLenum target, GLenum type, GLuint id)
Definition r_state.cpp:213
void R_EnableTexture(gltexunit_t *texunit, bool enable)
Definition r_state.cpp:303
void R_BindDefaultArray(GLenum target)
Binds the appropriate shared vertex array to the specified target.
Definition r_state.cpp:182
void R_Setup3D(void)
Definition r_state.cpp:763
void R_TexOverride(vec4_t rgba)
Sets special texture environment mode to override texture color; don't forget to call R_TexOverride(n...
Definition r_state.cpp:968
#define DOWNSAMPLE_PASSES
Definition r_state.h:84
void R_BlendFunc(GLenum src, GLenum dest)
Definition r_state.cpp:232
void R_EnableAnimation(const struct mAliasMesh_s *mesh, float backlerp, bool enable)
#define MAX_GL_TEXUNITS
Definition r_state.h:58
void R_EnableDrawAsGlow(bool enable)
Definition r_state.cpp:692
void R_SetDefaultState(void)
Definition r_state.cpp:860
void R_EnableBlur(r_program_t *program, bool enable, r_framebuffer_t *source, r_framebuffer_t *dest, int dir)
Definition r_state.cpp:523
void R_SetupSpotLight(int index, const light_t *light)
Definition r_state.cpp:376
void R_EnableMultisample(bool enable)
Definition r_state.cpp:243
bool R_EnableLighting(r_program_t *program, bool enable)
Enables hardware-accelerated lighting with the specified program. This should be called after any tex...
Definition r_state.cpp:350
bool R_SelectTexture(gltexunit_t *texunit)
Returns false if the texunit is not supported.
Definition r_state.cpp:40
void R_Setup2D(void)
Definition r_state.cpp:825
void R_BindLightmapTexture(GLuint texnum)
Definition r_state.cpp:90
void R_DisableSpotLight(int index)
Definition r_state.cpp:403
void R_BindDeluxemapTexture(GLuint texnum)
Definition r_state.cpp:95
void R_UseMaterial(const material_t *material)
Definition r_state.cpp:105
void R_EnableGlowMap(const struct image_s *image)
void R_EnableWarp(r_program_t *program, bool enable)
Definition r_state.cpp:496
void R_EnableBumpmap(const struct image_s *normalmap)
void R_EnableBlend(bool enable)
Definition r_state.cpp:261
void R_BindTextureForTexUnit(GLuint texnum, gltexunit_t *texunit)
Definition r_state.cpp:77
void R_TexEnv(GLenum value)
Definition r_state.cpp:956
void R_ReallocateTexunitArray(gltexunit_t *texunit, int size)
Reallocate texcoord array of the specified texunit, if needed.
Definition r_state.cpp:1059
void R_EnableShell(bool enable)
Definition r_state.cpp:551
void R_EnableColorArray(bool enable)
Definition r_state.cpp:332
void R_BindNormalmapTexture(GLuint texnum)
Definition r_state.cpp:100
void R_EnableFog(bool enable)
Definition r_state.cpp:586
void R_ReallocateStateArrays(int size)
Reallocate arrays of GL primitives if needed.
Definition r_state.cpp:1029
void R_EnableSpecularMap(const struct image_s *image, bool enable)
void R_BindArray(GLenum target, GLenum type, const void *array)
Definition r_state.cpp:148
void R_EnableStencilTest(bool enable)
Definition r_state.cpp:290
void R_EnableRoughnessMap(const struct image_s *image, bool enable)
void R_BindTextureDebug(int texnum, const char *file, int line, const char *function)
Definition r_state.cpp:69
texunits maintain multitexture state
Definition r_state.h:48
GLint texnum
Definition r_state.h:51
GLenum texture
Definition r_state.h:50
GLenum texenv
Definition r_state.h:52
int array_size
Definition r_state.h:55
bool enabled
Definition r_state.h:49
GLfloat * texcoord_array
Definition r_state.h:53
a light source
Definition r_light.h:29
const struct image_s * active_normalmap
Definition r_state.h:166
GLint * index_array
Definition r_state.h:103
GLfloat * vertex_array_3d
Definition r_state.h:100
GLenum blend_src
Definition r_state.h:143
r_program_t programs[MAX_PROGRAMS]
Definition r_state.h:131
GLfloat * next_normal_array
Definition r_state.h:107
bool specularmap_enabled
Definition r_state.h:161
bool frameBufferObjectsInitialized
Definition r_state.h:126
bool dynamic_lighting_enabled
Definition r_state.h:160
GLfloat * next_tangent_array
Definition r_state.h:108
r_program_t * world_program
Definition r_state.h:132
r_framebuffer_t * buffers1[DOWNSAMPLE_PASSES]
Definition r_state.h:124
r_program_t * geoscape_program
Definition r_state.h:135
r_program_t * convolve_program
Definition r_state.h:136
gltexunit_t * active_texunit
Definition r_state.h:117
const r_framebuffer_t * activeFramebuffer
Definition r_state.h:127
r_framebuffer_t * renderBuffer
Definition r_state.h:120
bool glowmap_enabled
Definition r_state.h:158
bool animation_enabled
Definition r_state.h:163
GLfloat * tangent_array
Definition r_state.h:105
r_program_t * atmosphere_program
Definition r_state.h:138
r_framebuffer_t * bloomBuffer0
Definition r_state.h:121
bool warp_enabled
Definition r_state.h:155
bool stencil_test_enabled
Definition r_state.h:153
bool renderbuffer_enabled
Definition r_state.h:164
r_program_t * warp_program
Definition r_state.h:134
r_framebuffer_t * buffers2[DOWNSAMPLE_PASSES]
Definition r_state.h:125
bool fullscreen
Definition r_state.h:97
bool multisample_enabled
Definition r_state.h:150
bool draw_glow_enabled
Definition r_state.h:159
bool blend_enabled
Definition r_state.h:149
r_program_t * simple_glow_program
Definition r_state.h:139
bool roughnessmap_enabled
Definition r_state.h:162
r_program_t * active_program
Definition r_state.h:140
GLfloat * normal_array
Definition r_state.h:104
GLshort * vertex_array_2d
Definition r_state.h:101
r_framebuffer_t * bloomBuffer1
Definition r_state.h:122
GLfloat * next_vertex_array_3d
Definition r_state.h:106
gltexunit_t texunits[MAX_GL_TEXUNITS]
Definition r_state.h:114
GLenum blend_dest
Definition r_state.h:143
const material_t * active_material
Definition r_state.h:145
bool fog_enabled
Definition r_state.h:156
r_framebuffer_t * buffers0[DOWNSAMPLE_PASSES]
Definition r_state.h:123
r_shader_t shaders[MAX_SHADERS]
Definition r_state.h:130
r_program_t * model_program
Definition r_state.h:133
bool blur_enabled
Definition r_state.h:157
bool alpha_test_enabled
Definition r_state.h:152
int array_size
Definition r_state.h:111
r_program_t * combine2_program
Definition r_state.h:137
GLfloat * color_array
Definition r_state.h:102
bool color_array_enabled
Definition r_state.h:151
bool lighting_enabled
Definition r_state.h:154
bool shell_enabled
Definition r_state.h:148
vec_t vec4_t[4]
Definition ufotypes.h:40
vec_t vec2_t[2]
Definition ufotypes.h:38