r_state.h
Go to the documentation of this file.00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef R_STATE_H
00027 #define R_STATE_H
00028
00029 #include "r_program.h"
00030 #include "r_material.h"
00031 #include "r_framebuffer.h"
00032 #include "r_light.h"
00033
00034
00035 #define MAX_GL_ARRAY_LENGTH 0x40000
00036 extern const vec2_t default_texcoords[4];
00037
00039 typedef struct gltexunit_s {
00040 qboolean enabled;
00041 GLenum texture;
00042 GLint texnum;
00043 GLenum texenv;
00044 GLfloat texcoord_array[MAX_GL_ARRAY_LENGTH * 2];
00045 } gltexunit_t;
00046
00047 #define MAX_GL_TEXUNITS 5
00048
00049
00050 #define texunit_0 r_state.texunits[0]
00051 #define texunit_1 r_state.texunits[1]
00052 #define texunit_2 r_state.texunits[2]
00053 #define texunit_3 r_state.texunits[3]
00054 #define texunit_4 r_state.texunits[4]
00055
00056 #define texunit_diffuse texunit_0
00057 #define texunit_lightmap texunit_1
00058 #define texunit_deluxemap texunit_2
00059 #define texunit_normalmap texunit_3
00060 #define texunit_glowmap texunit_4
00061 #define texunit_specularmap texunit_1
00062 #define texunit_roughnessmap texunit_2
00063
00064
00065 #define DOWNSAMPLE_PASSES 5
00066 #define DOWNSAMPLE_SCALE 2
00067
00068 #define fbo_screen NULL
00069 #define fbo_render r_state.renderBuffer
00070 #define fbo_bloom0 r_state.bloomBuffer0
00071 #define fbo_bloom1 r_state.bloomBuffer1
00072
00073 #define default_program NULL
00074
00075 typedef struct {
00076 qboolean fullscreen;
00077
00078
00079 GLfloat vertex_array_3d[MAX_GL_ARRAY_LENGTH * 3];
00080 GLshort vertex_array_2d[MAX_GL_ARRAY_LENGTH * 2];
00081 GLfloat color_array[MAX_GL_ARRAY_LENGTH * 4];
00082 GLfloat normal_array[MAX_GL_ARRAY_LENGTH * 3];
00083 GLfloat tangent_array[MAX_GL_ARRAY_LENGTH * 4];
00084 GLfloat next_vertex_array_3d[MAX_GL_ARRAY_LENGTH * 3];
00085 GLfloat next_normal_array[MAX_GL_ARRAY_LENGTH * 3];
00086 GLfloat next_tangent_array[MAX_GL_ARRAY_LENGTH * 4];
00087
00088
00089 gltexunit_t texunits[MAX_GL_TEXUNITS];
00090
00091
00092 gltexunit_t *active_texunit;
00093
00094
00095 r_light_t dynamicLights[MAX_DYNAMIC_LIGHTS];
00096 int numActiveLights;
00097
00098
00099
00100 r_framebuffer_t *renderBuffer;
00101 r_framebuffer_t *bloomBuffer0;
00102 r_framebuffer_t *bloomBuffer1;
00103 r_framebuffer_t *buffers0[DOWNSAMPLE_PASSES];
00104 r_framebuffer_t *buffers1[DOWNSAMPLE_PASSES];
00105 r_framebuffer_t *buffers2[DOWNSAMPLE_PASSES];
00106 qboolean frameBufferObjectsInitialized;
00107 const r_framebuffer_t *activeFramebuffer;
00108
00109
00110 r_shader_t shaders[MAX_SHADERS];
00111 r_program_t programs[MAX_PROGRAMS];
00112 r_program_t *world_program;
00113 r_program_t *warp_program;
00114 r_program_t *geoscape_program;
00115 r_program_t *convolve_program;
00116 r_program_t *combine2_program;
00117 r_program_t *atmosphere_program;
00118 r_program_t *simple_glow_program;
00119 r_program_t *active_program;
00120
00121
00122 GLenum blend_src, blend_dest;
00123
00124 const material_t *active_material;
00125
00126
00127 qboolean shell_enabled;
00128 qboolean blend_enabled;
00129 qboolean color_array_enabled;
00130 qboolean alpha_test_enabled;
00131 qboolean lighting_enabled;
00132 qboolean bumpmap_enabled;
00133 qboolean warp_enabled;
00134 qboolean fog_enabled;
00135 qboolean blur_enabled;
00136 qboolean glowmap_enabled;
00137 qboolean draw_glow_enabled;
00138 qboolean dynamic_lighting_enabled;
00139 qboolean specularmap_enabled;
00140 qboolean roughnessmap_enabled;
00141 qboolean animation_enabled;
00142 qboolean renderbuffer_enabled;
00143 } rstate_t;
00144
00145 extern rstate_t r_state;
00146
00147 void R_SetDefaultState(void);
00148 void R_Setup2D(void);
00149 void R_Setup3D(void);
00150
00151 void R_TexEnv(GLenum value);
00152 void R_BlendFunc(GLenum src, GLenum dest);
00153
00154 qboolean R_SelectTexture(gltexunit_t *texunit);
00155
00156 void R_BindTextureDebug(int texnum, const char *file, int line, const char *function);
00157 #define R_BindTexture(tn) R_BindTextureDebug(tn, __FILE__, __LINE__, __PRETTY_FUNCTION__)
00158 void R_BindTextureForTexUnit(GLuint texnum, gltexunit_t *texunit);
00159 void R_BindLightmapTexture(GLuint texnum);
00160 void R_BindDeluxemapTexture(GLuint texnum);
00161 void R_BindNormalmapTexture(GLuint texnum);
00162 void R_BindBuffer(GLenum target, GLenum type, GLuint id);
00163 void R_BindArray(GLenum target, GLenum type, const void *array);
00164 void R_BindDefaultArray(GLenum target);
00165
00166 void R_EnableTexture(gltexunit_t *texunit, qboolean enable);
00167 void R_EnableBlend(qboolean enable);
00168 void R_EnableAlphaTest(qboolean enable);
00169 void R_EnableColorArray(qboolean enable);
00170 qboolean R_EnableLighting(r_program_t *program, qboolean enable);
00171 void R_EnableBumpmap(const image_t *normalmap, qboolean enable);
00172 void R_EnableWarp(r_program_t *program, qboolean enable);
00173 void R_EnableBlur(r_program_t *program, qboolean enable, r_framebuffer_t *source, r_framebuffer_t *dest, int dir);
00174 void R_EnableShell(qboolean enable);
00175 void R_EnableFog(qboolean enable);
00176 void R_EnableDrawAsGlow(qboolean enable);
00177 void R_EnableGlowMap(const image_t *image, qboolean enable);
00178 void R_EnableDynamicLights(const entity_t *ent, qboolean enable);
00179 void R_EnableSpecularMap(const image_t *image, qboolean enable);
00180 void R_EnableRoughnessMap(const image_t *image, qboolean enable);
00181 void R_EnableAnimation(const mAliasMesh_t *mesh, float backlerp, qboolean enable);
00182
00183 #endif