/* Copyright (C) 1996-1997 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // r_misc.c #include "quakedef.h" #ifdef GLQUAKE #include "glquake.h" #include "gl_draw.h" /* ================== R_InitTextures ================== * void GLR_InitTextures (void) { int x,y, m; qbyte *dest; // create a simple checkerboard texture for the default r_notexture_mip = Hunk_AllocName (sizeof(texture_t) + 16*16+8*8+4*4+2*2, "notexture"); r_notexture_mip->width = r_notexture_mip->height = 16; r_notexture_mip->offsets[0] = sizeof(texture_t); r_notexture_mip->offsets[1] = r_notexture_mip->offsets[0] + 16*16; r_notexture_mip->offsets[2] = r_notexture_mip->offsets[1] + 8*8; r_notexture_mip->offsets[3] = r_notexture_mip->offsets[2] + 4*4; for (m=0 ; m<4 ; m++) { dest = (qbyte *)r_notexture_mip + r_notexture_mip->offsets[m]; for (y=0 ; y< (16>>m) ; y++) for (x=0 ; x< (16>>m) ; x++) { if ( (y< (8>>m) ) ^ (x< (8>>m) ) ) *dest++ = 0; else *dest++ = 0xff; } } }*/ #ifdef RTLIGHTS texid_t GenerateNormalisationCubeMap(void) { texid_t normalisationCubeMap; unsigned char data[32*32*3]; //some useful variables int size=32; float offset=0.5f; float halfSize=16.0f; vec3_t tempVector; unsigned char * bytePtr; int i, j; normalisationCubeMap = Image_CreateTexture("normalisationcubemap", NULL, IF_CUBEMAP); qglGenTextures(1, &normalisationCubeMap->num); GL_MTBind(0, GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap); //positive x bytePtr=data; for(j=0; j 1024) dummymip.width = 1024; if (dummymip.height > 1024) dummymip.height = 1024; dummymip.offsets[0] = sizeof(dummymip); dummymip.offsets[1] = dummymip.offsets[0]+dummymip.width*dummymip.height; dummymip.offsets[2] = dummymip.offsets[1]+dummymip.width/2*dummymip.height/2; dummymip.offsets[3] = dummymip.offsets[2]+dummymip.width/4*dummymip.height/4; entry[entries].dsize = entry[entries].size = dummymip.offsets[3]+dummymip.width/8*dummymip.height/8; xi = (float)width/dummymip.width; yi = (float)height/dummymip.height; VFS_WRITE(f, &dummymip, sizeof(dummymip)); outmip=mip; for (outmip=mip, y = 0; y < height; y+=yi) for (x = 0; x < width; x+=xi) { *outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0], data[(int)(x+y*width)*4+1], data[(int)(x+y*width)*4+2]); } VFS_WRITE(f, mip, dummymip.width * dummymip.height); for (outmip=mip, y = 0; y < height; y+=yi*2) for (x = 0; x < width; x+=xi*2) { *outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0], data[(int)(x+y*width)*4+1], data[(int)(x+y*width)*4+2]); } VFS_WRITE(f, mip, (dummymip.width/2) * (dummymip.height/2)); for (outmip=mip, y = 0; y < height; y+=yi*4) for (x = 0; x < width; x+=xi*4) { *outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0], data[(int)(x+y*width)*4+1], data[(int)(x+y*width)*4+2]); } VFS_WRITE(f, mip, (dummymip.width/4) * (dummymip.height/4)); for (outmip=mip, y = 0; y < height; y+=yi*8) for (x = 0; x < width; x+=xi*8) { *outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0], data[(int)(x+y*width)*4+1], data[(int)(x+y*width)*4+2]); } VFS_WRITE(f, mip, (dummymip.width/8) * (dummymip.height/8)); BZ_Free(data); } entry[i].dsize = VFS_TELL(f) - entry[i].offset; Con_Printf("Added %s\n", base); } wad2.offset = VFS_TELL(f); wad2.num = entries; VFS_WRITE(f, entry, entries*sizeof(wad2entry_t)); VFS_SEEK(f, 0); VFS_WRITE(f, &wad2, sizeof(wad2_t)); VFS_CLOSE(f); BZ_Free(mip); // BZ_Free(initbuf); BZ_Free(stack); Con_Printf("%s now has %i entries\n", wadname, entries); } #endif void GLR_TimeRefresh_f (void); extern cvar_t v_contrast, r_drawflat; extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount; // callback defines extern cvar_t gl_font; extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth; extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname; extern cvar_t r_fastskycolour; void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue); void GLR_DeInit (void) { Cmd_RemoveCommand ("timerefresh"); // Cmd_RemoveCommand ("makewad"); Cvar_Unhook(&r_skyboxname); Cvar_Unhook(&vid_conautoscale); Cvar_Unhook(&vid_conheight); Cvar_Unhook(&vid_conwidth); // Cvar_Unhook(&v_gamma); // Cvar_Unhook(&v_contrast); // Cvar_Unhook(&v_brightness); Surf_DeInit(); GLDraw_DeInit(); } void GLR_Init (void) { Cmd_AddCommand ("timerefresh", GLR_TimeRefresh_f); // Cmd_AddCommand ("makewad", R_MakeTexWad_f); GLR_ReInit(); } /* ==================== R_TimeRefresh_f For program optimization ==================== */ void GLR_TimeRefresh_f (void) { int i; float start, stop, time; int finish; int frames = 128; finish = atoi(Cmd_Argv(1)); frames = atoi(Cmd_Argv(2)); if (frames < 1) frames = 128; if (finish == 2) { qglFinish (); start = Sys_DoubleTime (); for (i=0 ; i