1 /** 2 * @file 3 * @brief local graphics definitions 4 */ 5 6 /* 7 All original material Copyright (C) 2002-2013 UFO: Alien Invasion. 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License 11 as published by the Free Software Foundation; either version 2 12 of the License, or (at your option) any later version. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 18 See the GNU General Public License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 23 24 */ 25 26 #pragma once 27 28 #include "../../common/common.h" 29 #include "../../common/qfiles.h" 30 #include "../cl_renderer.h" 31 #include "../cl_video.h" 32 33 #include "r_gl.h" 34 #include "r_state.h" 35 #include "r_array.h" 36 #include "r_material.h" 37 #include "r_image.h" 38 #include "r_model.h" 39 #include "r_thread.h" 40 #include "r_framebuffer.h" 41 #include "r_lightmap.h" 42 #include "r_corona.h" 43 #include "r_flare.h" 44 45 #define MIN_GL_CONSTANT_ATTENUATION 0.01 46 47 void R_DrawSurfaces(const mBspSurfaces_t* surfs, glElementIndex_t* indexPtr); 48 void R_DrawMaterialSurfaces(const mBspSurfaces_t* surfs, glElementIndex_t* indexPtr); 49 50 void R_SetSurfaceBumpMappingParameters(const mBspSurface_t* surf, const image_t* normalMap, const image_t* specularMap); 51 52 /*==================================================== */ 53 54 extern cvar_t* r_drawworld; 55 extern cvar_t* r_drawentities; 56 extern cvar_t* r_nocull; 57 extern cvar_t* r_isometric; 58 extern cvar_t* r_anisotropic; 59 extern cvar_t* r_texture_lod; /* lod_bias */ 60 extern cvar_t* r_materials; 61 extern cvar_t* r_overridematerial; 62 extern cvar_t* r_default_specular; 63 extern cvar_t* r_default_hardness; 64 extern cvar_t* r_screenshot_format; 65 extern cvar_t* r_screenshot_jpeg_quality; 66 extern cvar_t* r_lightmap; 67 extern cvar_t* r_debug_normals; 68 extern cvar_t* r_debug_tangents; 69 extern cvar_t* r_debug_lights; 70 extern cvar_t* r_ext_texture_compression; 71 extern cvar_t* r_checkerror; 72 extern cvar_t* r_particles; 73 extern cvar_t* r_showbox; 74 extern cvar_t* r_shadows; 75 extern cvar_t* r_stencilshadows; 76 extern cvar_t* r_drawbuffer; 77 extern cvar_t* r_driver; 78 extern cvar_t* r_swapinterval; 79 extern cvar_t* r_multisample; 80 extern cvar_t* r_threads; 81 extern cvar_t* r_wire; 82 extern cvar_t* r_vertexbuffers; 83 extern cvar_t* r_maxlightmap; 84 extern cvar_t* r_warp; 85 extern cvar_t* r_programs; 86 extern cvar_t* r_glsl_version; 87 extern cvar_t* r_postprocess; 88 extern cvar_t* r_shownormals; 89 extern cvar_t* r_bumpmap; 90 extern cvar_t* r_specular; 91 extern cvar_t* r_hardness; 92 extern cvar_t* r_parallax; 93 extern cvar_t* r_fog; 94 extern cvar_t* r_flares; 95 extern cvar_t* r_coronas; 96 extern cvar_t* r_dynamic_lights; 97 extern cvar_t* r_drawtags; 98 99 /* private renderer variables */ 100 typedef struct rlocals_s { 101 /* view origin angle vectors */ 102 vec3_t up; 103 vec3_t forward; 104 vec3_t right; 105 106 /* for box culling */ 107 cBspPlane_t frustum[4]; 108 109 int frame; 110 int tracenum; 111 112 float world_matrix[16]; 113 114 /** 115 * @brief this is the currently handled bsp model 116 * @note Remember that we can have loaded more than one bsp at the same time 117 */ 118 const model_t* bufferMapTile; 119 } rlocals_t; 120 121 extern rlocals_t r_locals; 122 123 bool R_CullMeshModel(const entity_t* e); 124 125 void R_DrawModelParticle(modelInfo_t* mi); 126 void R_DrawBspNormals(int tile); 127 bool R_CullBspModel(const entity_t* e); 128 bool R_CullSphere(const vec3_t centre, const float radius, const unsigned int clipflags); 129 void R_GetLevelSurfaceLists(void); 130 void R_GetEntityLists(void); 131 void R_DrawInitLocal(void); 132 void R_DrawParticles(void); 133 void R_SetupFrustum(void); 134 135 void R_ClearBspRRefs(void); 136 void R_AddBspRRef(const mBspModel_t* model, const vec3_t origin, const vec3_t angles, const bool forceVisibility); 137 void R_RenderOpaqueBspRRefs(void); 138 void R_RenderOpaqueWarpBspRRefs(void); 139 void R_RenderAlphaTestBspRRefs(void); 140 void R_RenderMaterialBspRRefs(void); 141 void R_RenderFlareBspRRefs(void); 142 void R_RenderBlendBspRRefs(void); 143 void R_RenderBlendWarpBspRRefs(void); 144 145 146 typedef enum { 147 GLHW_GENERIC, 148 GLHW_MESA, 149 GLHW_INTEL, 150 GLHW_ATI, 151 GLHW_NVIDIA 152 } hardwareType_t; 153 154 /** @brief GL config stuff */ 155 typedef struct { 156 const char* rendererString; 157 const char* vendorString; 158 const char* versionString; 159 const char* extensionsString; 160 161 int glVersionMajor; 162 int glVersionMinor; 163 164 int glslVersionMajor; 165 int glslVersionMinor; 166 167 int maxTextureSize; 168 int maxTextureUnits; 169 int maxTextureCoords; 170 int maxVertexAttribs; 171 int maxVertexBufferSize; 172 int maxLights; 173 int maxDrawBuffers; 174 int maxRenderbufferSize; 175 int maxColorAttachments; 176 int maxVertexTextureImageUnits; 177 178 char lodDir[8]; 179 180 int videoMemory; 181 182 bool hwgamma; 183 184 int32_t maxAnisotropic; 185 bool anisotropic; 186 bool frameBufferObject; 187 bool drawBuffers; 188 189 int gl_solid_format; 190 int gl_alpha_format; 191 192 int gl_compressed_solid_format; 193 int gl_compressed_alpha_format; 194 195 int gl_filter_min; /**< filter to use if the image is smaller than the original texture or stretched on the screen */ 196 int gl_filter_max; /**< filter to use if the image is larger than the original texture or stretched on the screen */ 197 198 bool lod_bias; 199 200 bool nonPowerOfTwo; /**< support for non power of two textures */ 201 202 hardwareType_t hardwareType; 203 } rconfig_t; 204 205 extern rconfig_t r_config; 206 207 /* 208 ==================================================================== 209 IMPLEMENTATION SPECIFIC FUNCTIONS 210 ==================================================================== 211 */ 212 213 bool Rimp_Init(void); 214 void Rimp_Shutdown(void); 215 bool R_InitGraphics(const viddefContext_t* context); 216