From 027ddfe2a31744d0dd6d1b6ac7d9f0c257a6b147 Mon Sep 17 00:00:00 2001 From: cholleme <> Date: Sun, 29 Jun 2003 21:36:50 +0000 Subject: [PATCH] Made some initial changes for supporting shader lights --- glquake.h | 6 +++-- textures.c | 74 +++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/glquake.h b/glquake.h index e6a49dd..b694b66 100644 --- a/glquake.h +++ b/glquake.h @@ -380,6 +380,7 @@ extern cvar_t gl_fog; extern float fog_color[4]; extern cvar_t r_tangentscale; //scale tangent/binormal by this extern cvar_t sh_delux; +extern cvar_t sh_rtlights; extern int mirrortexturenum; // quake texturenum, not gltexturenum extern qboolean mirror; @@ -1143,6 +1144,7 @@ typedef struct shadowlight_s { float haloalpha; //alpha of halo vec3_t oldlightorigin; int area; //area (from areaportals) light is in + shader_t *shader; //shader on this light } shadowlight_t; //PENTA: new @@ -1297,7 +1299,7 @@ void R_AddRectList (screenrect_t *rec); void R_AllocateMirror (msurface_t *surf); void R_AnimateLight (void); void R_AutomaticLightPos (void); -void R_CalcSvBsp (entity_t *ent); +void R_StaticLightFromEnt (entity_t *ent); qboolean R_CheckRectList (screenrect_t *rec); void R_ClearBrushInstantCaches (void); void R_ClearInstantCaches (void); @@ -1409,7 +1411,7 @@ void GL_ModulateAlphaDrawColor (void); void GL_SelectTexture (GLenum target); void GL_Set2D (void); void GL_SetupCubeMapMatrix (const transform_t *tr); -void GL_SubdivideSurface (msurface_t *fa); +//void GL_SubdivideSurface (msurface_t *fa); void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha); void R_DrawCaustics(void); int CL_PointContents (vec3_t p); diff --git a/textures.c b/textures.c index 2f46e47..a07dd46 100644 --- a/textures.c +++ b/textures.c @@ -29,9 +29,9 @@ extern unsigned char d_15to8table[65536]; cvar_t gl_max_size = {"gl_max_size", "1024"}; cvar_t gl_picmip = {"gl_picmip", "0"}; -cvar_t gl_gloss = {"gl_gloss", "0.3"}; -cvar_t gl_compress_textures = {"gl_compress_textures", "0"}; -cvar_t willi_gray_colormaps = {"willi_gray_colormaps", "0"}; +cvar_t gl_gloss = {"gl_gloss", "0.3"}; +cvar_t gl_compress_textures = {"gl_compress_textures", "0"}; +cvar_t willi_gray_colormaps = {"willi_gray_colormaps", "0"}; /* cvar_t cg_conclock = {"cg_conclock", "1", true}; @@ -717,15 +717,13 @@ static unsigned scaled[1024*1024]; // [512*256]; if (scaled_width * scaled_height > sizeof(scaled)/4) Sys_Error ("GL_LoadTexture: too big"); - if ( gl_texcomp && ((int)gl_compress_textures.value) & 1 ) - { - texturemode = GL_COMPRESSED_RGBA_ARB; - } - else - { - texturemode = GL_RGBA;//PENTA: Always upload rgb it doesn't make any difference for nvidia cards (& others) - //texturemode = alpha ? gl_alpha_format : gl_solid_format; - } + if ( gl_texcomp && ((int)gl_compress_textures.value) & 1 ) { + texturemode = GL_COMPRESSED_RGBA_ARB; + } else { + texturemode = GL_RGBA;//PENTA: Always upload rgb it doesn't make any difference for nvidia cards (& others) + //texturemode = alpha ? gl_alpha_format : gl_solid_format; + } + #if 0 if (mipmap) gluBuild2DMipmaps (GL_TEXTURE_2D, texturemode, width, height, GL_RGBA, GL_UNSIGNED_BYTE, trans); @@ -1312,6 +1310,11 @@ gltexture_t *GL_CacheTexture (char *filename, qboolean mipmap, int type) glt->mipmap = mipmap; glt->dynamic = NULL; + if (type == TEXTURE_CUBEMAP) { + GL_LoadCubemapTexture(glt); + return glt; + } + if (!strcmp(filename,"$white")) { //a uniform white texture trans[0] = LittleLong ((255 << 24)|(255 << 16)|(255 << 8)|(255)); @@ -1477,6 +1480,53 @@ char *face_names[] = "negz", }; +/** + Load a cubemap into the texture cache (used for a.o. light filters) + glt contains a valid texture identifier where the map needs to be bound + glt contains a "prexix" where the cubmap files are +*/ +int GL_LoadCubemapTexture (gltexture_t *glt) +{ + int i, width, height; + FILE *f; + char filename[MAX_OSPATH]; + int texturemode; + + if ( gl_texcomp && ((int)gl_compress_textures.value) & 1) + { + texturemode = GL_COMPRESSED_RGBA_ARB; + } else { + texturemode = GL_RGBA; + } + + glEnable(GL_TEXTURE_CUBE_MAP_ARB); + glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, glt->texnum); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + for (i = 0; i < 6; i++) + { + sprintf(filename,"%i%s.tga", glt->identifier, face_names[i]); + LoadTextureInPlace(filename, 4, (unsigned char*)&trans[0], &width, &height); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB+i, 0, texturemode, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &trans[0]); + } + + //glEnable(GL_TEXTURE_2D); + glDisable(GL_TEXTURE_CUBE_MAP_ARB); + + glt->width = width; + glt->height = height; + glt->mipmap = false; + glt->type = GL_TEXTURE_CUBE_MAP_ARB; + + texture_extension_number++; + + return texture_extension_number-1; +} + + /* ================ GL_LoadCubeMap