2004-08-22 22:29:09 +00:00
|
|
|
/*
|
|
|
|
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"
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef GLQUAKE
|
2004-08-22 22:29:09 +00:00
|
|
|
#include "glquake.h"
|
2004-09-13 03:20:04 +00:00
|
|
|
#include "gl_draw.h"
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-10 01:00:41 +00:00
|
|
|
#if 1
|
|
|
|
texid_t GenerateNormalisationCubeMap(void)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2012-05-10 01:00:41 +00:00
|
|
|
texid_t normalisationCubeMap;
|
2004-08-22 22:29:09 +00:00
|
|
|
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;
|
2011-01-29 21:01:40 +00:00
|
|
|
|
2012-09-30 05:52:03 +00:00
|
|
|
normalisationCubeMap = R_AllocNewTexture("normalisationcubemap", 32, 32, 0);
|
2012-05-10 01:00:41 +00:00
|
|
|
GL_MTBind(0, GL_TEXTURE_CUBE_MAP_ARB, normalisationCubeMap);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//positive x
|
|
|
|
bytePtr=data;
|
|
|
|
|
|
|
|
for(j=0; j<size; j++)
|
|
|
|
{
|
|
|
|
for(i=0; i<size; i++)
|
|
|
|
{
|
|
|
|
tempVector[0] = halfSize;
|
|
|
|
tempVector[1] = -(j+offset-halfSize);
|
|
|
|
tempVector[2] = -(i+offset-halfSize);
|
|
|
|
|
|
|
|
VectorNormalize(tempVector);
|
|
|
|
|
|
|
|
bytePtr[0]=(unsigned char)((tempVector[0]/2 + 0.5)*255);
|
|
|
|
bytePtr[1]=(unsigned char)((tempVector[1]/2 + 0.5)*255);
|
|
|
|
bytePtr[2]=(unsigned char)((tempVector[2]/2 + 0.5)*255);
|
|
|
|
|
|
|
|
bytePtr+=3;
|
|
|
|
}
|
|
|
|
}
|
2005-01-07 03:04:42 +00:00
|
|
|
qglTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
|
2012-05-11 01:57:00 +00:00
|
|
|
0, GL_RGBA, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//negative x
|
|
|
|
bytePtr=data;
|
|
|
|
|
|
|
|
for(j=0; j<size; j++)
|
|
|
|
{
|
|
|
|
for(i=0; i<size; i++)
|
|
|
|
{
|
|
|
|
tempVector[0] = (-halfSize);
|
|
|
|
tempVector[1] = (-(j+offset-halfSize));
|
|
|
|
tempVector[2] = ((i+offset-halfSize));
|
|
|
|
|
|
|
|
VectorNormalize(tempVector);
|
|
|
|
|
|
|
|
bytePtr[0]=(unsigned char)((tempVector[0]/2 + 0.5)*255);
|
|
|
|
bytePtr[1]=(unsigned char)((tempVector[1]/2 + 0.5)*255);
|
|
|
|
bytePtr[2]=(unsigned char)((tempVector[2]/2 + 0.5)*255);
|
|
|
|
|
|
|
|
bytePtr+=3;
|
|
|
|
}
|
|
|
|
}
|
2005-01-07 03:04:42 +00:00
|
|
|
qglTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
|
2012-05-11 01:57:00 +00:00
|
|
|
0, GL_RGBA, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//positive y
|
|
|
|
bytePtr=data;
|
|
|
|
|
|
|
|
for(j=0; j<size; j++)
|
|
|
|
{
|
|
|
|
for(i=0; i<size; i++)
|
|
|
|
{
|
|
|
|
tempVector[0] = (i+offset-halfSize);
|
|
|
|
tempVector[1] = (halfSize);
|
|
|
|
tempVector[2] = ((j+offset-halfSize));
|
|
|
|
|
|
|
|
VectorNormalize(tempVector);
|
|
|
|
|
|
|
|
bytePtr[0]=(unsigned char)((tempVector[0]/2 + 0.5)*255);
|
|
|
|
bytePtr[1]=(unsigned char)((tempVector[1]/2 + 0.5)*255);
|
|
|
|
bytePtr[2]=(unsigned char)((tempVector[2]/2 + 0.5)*255);
|
|
|
|
|
|
|
|
bytePtr+=3;
|
|
|
|
}
|
|
|
|
}
|
2005-01-07 03:04:42 +00:00
|
|
|
qglTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
|
2012-05-11 01:57:00 +00:00
|
|
|
0, GL_RGBA, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//negative y
|
|
|
|
bytePtr=data;
|
|
|
|
|
|
|
|
for(j=0; j<size; j++)
|
|
|
|
{
|
|
|
|
for(i=0; i<size; i++)
|
|
|
|
{
|
|
|
|
tempVector[0] = (i+offset-halfSize);
|
|
|
|
tempVector[1] = (-halfSize);
|
|
|
|
tempVector[2] = (-(j+offset-halfSize));
|
|
|
|
|
|
|
|
VectorNormalize(tempVector);
|
|
|
|
|
|
|
|
bytePtr[0]=(unsigned char)((tempVector[0]/2 + 0.5)*255);
|
|
|
|
bytePtr[1]=(unsigned char)((tempVector[1]/2 + 0.5)*255);
|
|
|
|
bytePtr[2]=(unsigned char)((tempVector[2]/2 + 0.5)*255);
|
|
|
|
|
|
|
|
bytePtr+=3;
|
|
|
|
}
|
|
|
|
}
|
2005-01-07 03:04:42 +00:00
|
|
|
qglTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
|
2012-05-11 01:57:00 +00:00
|
|
|
0, GL_RGBA, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//positive z
|
|
|
|
bytePtr=data;
|
|
|
|
|
|
|
|
for(j=0; j<size; j++)
|
|
|
|
{
|
|
|
|
for(i=0; i<size; i++)
|
|
|
|
{
|
|
|
|
tempVector[0] = (i+offset-halfSize);
|
|
|
|
tempVector[1] = (-(j+offset-halfSize));
|
|
|
|
tempVector[2] = (halfSize);
|
|
|
|
|
|
|
|
VectorNormalize(tempVector);
|
|
|
|
|
|
|
|
bytePtr[0]=(unsigned char)((tempVector[0]/2 + 0.5)*255);
|
|
|
|
bytePtr[1]=(unsigned char)((tempVector[1]/2 + 0.5)*255);
|
|
|
|
bytePtr[2]=(unsigned char)((tempVector[2]/2 + 0.5)*255);
|
|
|
|
|
|
|
|
bytePtr+=3;
|
|
|
|
}
|
|
|
|
}
|
2005-01-07 03:04:42 +00:00
|
|
|
qglTexImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
|
2012-05-11 01:57:00 +00:00
|
|
|
0, GL_RGBA, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//negative z
|
|
|
|
bytePtr=data;
|
|
|
|
|
|
|
|
for(j=0; j<size; j++)
|
|
|
|
{
|
|
|
|
for(i=0; i<size; i++)
|
|
|
|
{
|
|
|
|
tempVector[0] = (-(i+offset-halfSize));
|
|
|
|
tempVector[1] = (-(j+offset-halfSize));
|
|
|
|
tempVector[2] = (-halfSize);
|
|
|
|
|
|
|
|
VectorNormalize(tempVector);
|
|
|
|
|
|
|
|
bytePtr[0]=(unsigned char)((tempVector[0]/2 + 0.5)*255);
|
|
|
|
bytePtr[1]=(unsigned char)((tempVector[1]/2 + 0.5)*255);
|
|
|
|
bytePtr[2]=(unsigned char)((tempVector[2]/2 + 0.5)*255);
|
|
|
|
|
|
|
|
bytePtr+=3;
|
|
|
|
}
|
|
|
|
}
|
2005-01-07 03:04:42 +00:00
|
|
|
qglTexImage2D( GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
|
2012-05-11 01:57:00 +00:00
|
|
|
0, GL_RGBA, 32, 32, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
|
2011-01-29 21:01:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
|
|
qglTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2012-05-10 01:00:41 +00:00
|
|
|
return normalisationCubeMap;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
texid_t normalisationCubeMap;
|
|
|
|
#endif
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
/*
|
|
|
|
===============
|
|
|
|
R_Init
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void GLR_ReInit (void)
|
2011-10-27 16:16:29 +00:00
|
|
|
{
|
|
|
|
R_NetgraphInit();
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2013-12-29 22:48:28 +00:00
|
|
|
|
|
|
|
#if 1
|
2004-08-22 22:29:09 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
long offset; // Position of the entry in WAD
|
|
|
|
long dsize; // Size of the entry in WAD file
|
|
|
|
long size; // Size of the entry in memory
|
|
|
|
char type; // type of entry
|
|
|
|
char cmprs; // Compression. 0 if none.
|
|
|
|
short dummy; // Not used
|
|
|
|
char name[16]; // we use only first 8
|
|
|
|
} wad2entry_t;
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char magic[4]; //should be WAD2
|
|
|
|
long num; //number of entries
|
|
|
|
long offset; //location of directory
|
|
|
|
} wad2_t;
|
|
|
|
void R_MakeTexWad_f(void)
|
|
|
|
{
|
2013-12-29 22:48:28 +00:00
|
|
|
//this function is written as little endian. nothing will fix that.
|
2004-08-22 22:29:09 +00:00
|
|
|
miptex_t dummymip = {"", 0, 0, {0, 0, 0, 0}};
|
|
|
|
wad2_t wad2 = {"WAD2",0,0};
|
|
|
|
wad2entry_t entry[2048];
|
|
|
|
int entries = 0, i;
|
2013-12-29 22:48:28 +00:00
|
|
|
vfsfile_t *f;
|
2004-08-22 22:29:09 +00:00
|
|
|
char base[128];
|
|
|
|
// qbyte b;
|
2013-12-29 22:48:28 +00:00
|
|
|
qboolean hasalpha;
|
2004-08-22 22:29:09 +00:00
|
|
|
int width, height;
|
|
|
|
|
|
|
|
qbyte *buf, *outmip;
|
|
|
|
qbyte *mip, *stack;
|
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
char *wadname = Cmd_Argv(1);
|
|
|
|
char *imagename = Cmd_Argv(2);
|
|
|
|
float scale = atof(Cmd_Argv(3));
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
if (!scale)
|
|
|
|
scale = 2;
|
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
if (!*wadname || !*imagename)
|
2004-08-22 22:29:09 +00:00
|
|
|
return;
|
2013-12-29 22:48:28 +00:00
|
|
|
f=FS_OpenVFS(wadname, "w+b", FS_GAMEONLY);
|
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
mip = BZ_Malloc(1024*1024);
|
|
|
|
// initbuf = BZ_Malloc(1024*1024*4);
|
|
|
|
stack = BZ_Malloc(1024*1024*4+1024);
|
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
VFS_SEEK(f, 0);
|
|
|
|
VFS_READ(f, &wad2, sizeof(wad2_t));
|
|
|
|
|
|
|
|
VFS_SEEK(f, wad2.offset);
|
|
|
|
VFS_READ(f, entry, sizeof(entry[0]) * wad2.num);
|
|
|
|
|
|
|
|
//find the end of the data.
|
|
|
|
wad2.offset = sizeof(wad2_t);
|
|
|
|
for (entries = 0; entries < wad2.num; entries++)
|
|
|
|
if (wad2.offset < entry[entries].offset + entry[entries].dsize)
|
|
|
|
wad2.offset = entry[entries].offset + entry[entries].dsize;
|
|
|
|
VFS_SEEK(f, wad2.offset);
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2013-12-29 22:48:28 +00:00
|
|
|
COM_StripExtension(imagename, base, sizeof(base));
|
2004-08-22 22:29:09 +00:00
|
|
|
base[15]=0;
|
|
|
|
for (i =0; i < entries; i++)
|
2013-12-29 22:48:28 +00:00
|
|
|
if (!stricmp(entry[i].name, base))
|
2004-08-22 22:29:09 +00:00
|
|
|
break;
|
|
|
|
if (i != entries)
|
2013-12-29 22:48:28 +00:00
|
|
|
Con_Printf("Replacing %s, you'll want to compact your wad at some point.\n", base); //this will leave a gap. we don't support compacting.
|
|
|
|
else
|
|
|
|
entries++;
|
|
|
|
entry[i].offset = VFS_TELL(f);
|
|
|
|
entry[i].dsize = entry[i].size = 0;
|
|
|
|
entry[i].type = TYP_MIPTEX;
|
|
|
|
entry[i].cmprs = 0;
|
|
|
|
entry[i].dummy = 0;
|
|
|
|
strcpy(entry[i].name, base);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
strcpy(dummymip.name, base);
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
qbyte *data;
|
|
|
|
int h;
|
|
|
|
float x, xi;
|
|
|
|
float y, yi;
|
|
|
|
|
|
|
|
char *path[] ={
|
|
|
|
"%s",
|
|
|
|
"override/%s.tga",
|
2013-12-29 22:48:28 +00:00
|
|
|
|
|
|
|
"textures/%s.png",
|
|
|
|
"textures/%s.tga",
|
|
|
|
|
|
|
|
"%s.png",
|
2004-08-22 22:29:09 +00:00
|
|
|
"%s.tga",
|
|
|
|
"progs/%s"};
|
|
|
|
for (h = 0, buf=NULL; h < sizeof(path)/sizeof(char *); h++)
|
|
|
|
{
|
2013-12-29 22:48:28 +00:00
|
|
|
buf = COM_LoadStackFile(va(path[h], imagename), stack, 1024*1024*4+1024);
|
2004-08-22 22:29:09 +00:00
|
|
|
if (buf)
|
|
|
|
break;
|
|
|
|
}
|
2014-02-07 08:38:40 +00:00
|
|
|
width = 16;
|
|
|
|
height = 16;
|
2013-12-29 22:48:28 +00:00
|
|
|
if (buf)
|
|
|
|
data = Read32BitImageFile(buf, com_filesize, &width, &height, &hasalpha, imagename);
|
|
|
|
else
|
|
|
|
data = NULL;
|
|
|
|
if (!data)
|
2014-02-07 08:38:40 +00:00
|
|
|
data = Z_Malloc(width*height*4);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
dummymip.width = (int)(width/scale) & ~0xf;
|
|
|
|
dummymip.height = (int)(height/scale) & ~0xf;
|
|
|
|
if (dummymip.width<=0)
|
|
|
|
dummymip.width=16;
|
|
|
|
if (dummymip.height<=0)
|
|
|
|
dummymip.height=16;
|
2013-12-29 22:48:28 +00:00
|
|
|
if (dummymip.width > 1024)
|
|
|
|
dummymip.width = 1024;
|
|
|
|
if (dummymip.height > 1024)
|
|
|
|
dummymip.height = 1024;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
VFS_WRITE(f, &dummymip, sizeof(dummymip));
|
2004-08-22 22:29:09 +00:00
|
|
|
outmip=mip;
|
|
|
|
for (outmip=mip, y = 0; y < height; y+=yi)
|
|
|
|
for (x = 0; x < width; x+=xi)
|
|
|
|
{
|
2007-09-22 19:28:27 +00:00
|
|
|
*outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0],
|
2004-08-22 22:29:09 +00:00
|
|
|
data[(int)(x+y*width)*4+1],
|
|
|
|
data[(int)(x+y*width)*4+2]);
|
|
|
|
}
|
2013-12-29 22:48:28 +00:00
|
|
|
VFS_WRITE(f, mip, dummymip.width * dummymip.height);
|
2004-08-22 22:29:09 +00:00
|
|
|
for (outmip=mip, y = 0; y < height; y+=yi*2)
|
|
|
|
for (x = 0; x < width; x+=xi*2)
|
|
|
|
{
|
2007-09-22 19:28:27 +00:00
|
|
|
*outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0],
|
2004-08-22 22:29:09 +00:00
|
|
|
data[(int)(x+y*width)*4+1],
|
|
|
|
data[(int)(x+y*width)*4+2]);
|
|
|
|
}
|
2013-12-29 22:48:28 +00:00
|
|
|
VFS_WRITE(f, mip, (dummymip.width/2) * (dummymip.height/2));
|
2004-08-22 22:29:09 +00:00
|
|
|
for (outmip=mip, y = 0; y < height; y+=yi*4)
|
|
|
|
for (x = 0; x < width; x+=xi*4)
|
|
|
|
{
|
2007-09-22 19:28:27 +00:00
|
|
|
*outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0],
|
2004-08-22 22:29:09 +00:00
|
|
|
data[(int)(x+y*width)*4+1],
|
|
|
|
data[(int)(x+y*width)*4+2]);
|
|
|
|
}
|
2013-12-29 22:48:28 +00:00
|
|
|
VFS_WRITE(f, mip, (dummymip.width/4) * (dummymip.height/4));
|
2004-08-22 22:29:09 +00:00
|
|
|
for (outmip=mip, y = 0; y < height; y+=yi*8)
|
|
|
|
for (x = 0; x < width; x+=xi*8)
|
|
|
|
{
|
2007-09-22 19:28:27 +00:00
|
|
|
*outmip++ = GetPaletteIndex( data[(int)(x+y*width)*4+0],
|
2004-08-22 22:29:09 +00:00
|
|
|
data[(int)(x+y*width)*4+1],
|
|
|
|
data[(int)(x+y*width)*4+2]);
|
|
|
|
}
|
2013-12-29 22:48:28 +00:00
|
|
|
VFS_WRITE(f, mip, (dummymip.width/8) * (dummymip.height/8));
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
BZ_Free(data);
|
|
|
|
}
|
2013-12-29 22:48:28 +00:00
|
|
|
entry[i].dsize = VFS_TELL(f) - entry[i].offset;
|
2004-08-22 22:29:09 +00:00
|
|
|
Con_Printf("Added %s\n", base);
|
|
|
|
}
|
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
wad2.offset = VFS_TELL(f);
|
2004-08-22 22:29:09 +00:00
|
|
|
wad2.num = entries;
|
2013-12-29 22:48:28 +00:00
|
|
|
VFS_WRITE(f, entry, entries*sizeof(wad2entry_t));
|
|
|
|
VFS_SEEK(f, 0);
|
|
|
|
VFS_WRITE(f, &wad2, sizeof(wad2_t));
|
|
|
|
VFS_CLOSE(f);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
BZ_Free(mip);
|
|
|
|
// BZ_Free(initbuf);
|
|
|
|
BZ_Free(stack);
|
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
Con_Printf("%s now has %i entries\n", wadname, entries);
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2013-12-29 22:48:28 +00:00
|
|
|
#endif
|
2004-08-22 22:29:09 +00:00
|
|
|
void GLR_TimeRefresh_f (void);
|
|
|
|
|
2011-10-27 16:16:29 +00:00
|
|
|
extern cvar_t v_contrast, r_drawflat;
|
2006-04-15 06:57:13 +00:00
|
|
|
extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2006-04-14 04:31:29 +00:00
|
|
|
// callback defines
|
2011-03-12 13:51:40 +00:00
|
|
|
extern cvar_t gl_font;
|
2006-04-15 06:57:13 +00:00
|
|
|
extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth;
|
2006-04-15 05:28:44 +00:00
|
|
|
extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname;
|
2006-05-08 04:30:04 +00:00
|
|
|
extern cvar_t r_floorcolour, r_wallcolour, r_floortexture, r_walltexture;
|
2008-01-13 05:05:30 +00:00
|
|
|
extern cvar_t r_fastskycolour;
|
2006-05-06 05:50:33 +00:00
|
|
|
void GLV_Gamma_Callback(struct cvar_s *var, char *oldvalue);
|
2006-04-14 04:31:29 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
void GLR_DeInit (void)
|
|
|
|
{
|
|
|
|
Cmd_RemoveCommand ("timerefresh");
|
|
|
|
|
|
|
|
Cmd_RemoveCommand ("makewad");
|
|
|
|
|
2006-04-15 05:28:44 +00:00
|
|
|
Cvar_Unhook(&r_skyboxname);
|
2006-04-15 06:57:13 +00:00
|
|
|
Cvar_Unhook(&vid_conautoscale);
|
|
|
|
Cvar_Unhook(&vid_conheight);
|
|
|
|
Cvar_Unhook(&vid_conwidth);
|
2006-05-08 04:30:04 +00:00
|
|
|
Cvar_Unhook(&r_walltexture);
|
|
|
|
Cvar_Unhook(&r_floortexture);
|
2006-05-06 03:28:48 +00:00
|
|
|
Cvar_Unhook(&r_drawflat);
|
2006-05-06 05:50:33 +00:00
|
|
|
Cvar_Unhook(&v_gamma);
|
|
|
|
Cvar_Unhook(&v_contrast);
|
2013-05-11 14:02:55 +00:00
|
|
|
Cvar_Unhook(&v_brightness);
|
2006-04-14 04:31:29 +00:00
|
|
|
|
2009-11-07 13:29:15 +00:00
|
|
|
Surf_DeInit();
|
2011-10-27 16:16:29 +00:00
|
|
|
|
|
|
|
GLDraw_DeInit();
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLR_Init (void)
|
|
|
|
{
|
2012-05-09 15:30:53 +00:00
|
|
|
Cmd_AddCommand ("timerefresh", GLR_TimeRefresh_f);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2013-12-29 22:48:28 +00:00
|
|
|
Cmd_AddCommand ("makewad", R_MakeTexWad_f);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
// Cvar_Hook(&r_floortexture, GLR_Floortexture_Callback);
|
|
|
|
// Cvar_Hook(&r_walltexture, GLR_Walltexture_Callback);
|
|
|
|
// Cvar_Hook(&r_drawflat, GLR_Drawflat_Callback);
|
2006-04-14 04:31:29 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
GLR_ReInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
R_NewMap
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void GLR_NewMap (void)
|
|
|
|
{
|
2005-04-26 16:04:12 +00:00
|
|
|
char namebuf[MAX_QPATH];
|
2013-10-08 14:28:11 +00:00
|
|
|
extern cvar_t host_mapname;
|
2004-08-22 22:29:09 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0 ; i<256 ; i++)
|
|
|
|
d_lightstylevalue[i] = 264; // normal light value
|
|
|
|
|
|
|
|
memset (&r_worldentity, 0, sizeof(r_worldentity));
|
2004-11-17 18:13:33 +00:00
|
|
|
AngleVectors(r_worldentity.angles, r_worldentity.axis[0], r_worldentity.axis[1], r_worldentity.axis[2]);
|
|
|
|
VectorInverse(r_worldentity.axis[1]);
|
2004-08-22 22:29:09 +00:00
|
|
|
r_worldentity.model = cl.worldmodel;
|
2012-01-17 07:57:46 +00:00
|
|
|
Vector4Set(r_worldentity.shaderRGBAf, 1, 1, 1, 1);
|
2013-03-12 23:24:15 +00:00
|
|
|
VectorSet(r_worldentity.light_avg, 1, 1, 1);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-04-26 16:04:12 +00:00
|
|
|
|
2006-03-11 03:12:10 +00:00
|
|
|
COM_StripExtension(COM_SkipPath(cl.worldmodel->name), namebuf, sizeof(namebuf));
|
2005-04-26 16:04:12 +00:00
|
|
|
Cvar_Set(&host_mapname, namebuf);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-07 13:29:15 +00:00
|
|
|
Surf_DeInit();
|
2008-11-09 22:29:28 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
r_viewleaf = NULL;
|
2013-07-14 12:22:51 +00:00
|
|
|
r_oldviewleaf = NULL;
|
2004-08-22 22:29:09 +00:00
|
|
|
r_viewcluster = -1;
|
|
|
|
r_oldviewcluster = 0;
|
|
|
|
r_viewcluster2 = -1;
|
Fixes, workarounds, and breakages. Hexen2 should work much better (-hexen2 says no mission pack, -portals says h2mp). Started working on splitting bigcoords per client, far too much work still to go on that. Removed gl_ztrick entirely. Enabled csprogs download by default. Added client support for fitzquake's 666 protocol, needs testing, some cleanup for dp protocols too, no server support, couldn't selectively enable it anyway. Now attempting to cache shadow meshes for explosions and stuff. Played with lightmaps a little, should potentially run a little faster on certain (intel?) cards. Tweeked npfte a little to try to avoid deadlocks and crashes. Fixed sky worldspawn parsing. Added h2mp's model format. Fixed baseline issue in q2 client, made servers generate q2 baselines. MOVETYPE_PUSH will not rotate extra if rotation is forced. Made status command show allowed client types. Changed lighting on weapons - should now be shaded.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3572 fc73d0e0-1445-4013-8a0c-d673dee63da5
2010-08-11 03:36:31 +00:00
|
|
|
|
|
|
|
Mod_ParseInfoFromEntityLump(cl.worldmodel, cl.worldmodel->entities, cl.worldmodel->name);
|
|
|
|
|
2014-04-29 02:29:04 +00:00
|
|
|
if (!pe)
|
|
|
|
Cvar_ForceCallback(&r_particlesystem);
|
2004-10-10 06:32:29 +00:00
|
|
|
TRACE(("dbg: GLR_NewMap: clear particles\n"));
|
2005-03-10 03:55:18 +00:00
|
|
|
P_ClearParticles ();
|
2004-10-10 06:32:29 +00:00
|
|
|
TRACE(("dbg: GLR_NewMap: wiping them stains (getting the cloth out)\n"));
|
2009-11-07 13:29:15 +00:00
|
|
|
Surf_WipeStains();
|
2010-12-18 17:02:47 +00:00
|
|
|
CL_RegisterParticles();
|
2004-10-10 06:32:29 +00:00
|
|
|
TRACE(("dbg: GLR_NewMap: building lightmaps\n"));
|
2009-11-07 13:29:15 +00:00
|
|
|
Surf_BuildLightmaps ();
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2010-12-05 02:46:07 +00:00
|
|
|
|
2004-10-10 06:32:29 +00:00
|
|
|
TRACE(("dbg: GLR_NewMap: ui\n"));
|
2005-09-09 23:40:55 +00:00
|
|
|
#ifdef VM_UI
|
2004-08-22 22:29:09 +00:00
|
|
|
UI_Reset();
|
2005-09-09 23:40:55 +00:00
|
|
|
#endif
|
2004-10-10 06:32:29 +00:00
|
|
|
TRACE(("dbg: GLR_NewMap: tp\n"));
|
2004-09-30 22:47:31 +00:00
|
|
|
TP_NewMap();
|
2010-07-11 02:22:39 +00:00
|
|
|
R_SetSky(cl.skyname);
|
2004-11-27 08:16:25 +00:00
|
|
|
|
2011-03-03 13:32:27 +00:00
|
|
|
#ifdef MAP_PROC
|
2011-02-25 04:22:14 +00:00
|
|
|
if (cl.worldmodel->fromgame == fg_doom3)
|
|
|
|
D3_GenerateAreas(cl.worldmodel);
|
2011-03-03 13:32:27 +00:00
|
|
|
#endif
|
2011-02-25 04:22:14 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef RTLIGHTS
|
2011-12-23 03:12:29 +00:00
|
|
|
Sh_PreGenerateLights();
|
2009-11-04 21:16:50 +00:00
|
|
|
#endif
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLR_PreNewMap(void)
|
|
|
|
{
|
2013-10-08 14:28:11 +00:00
|
|
|
r_loadbumpmapping = r_deluxemapping.ival || r_glsl_offsetmapping.ival;
|
|
|
|
#ifdef RTLIGHTS
|
|
|
|
r_loadbumpmapping |= r_shadow_realtime_world.ival || r_shadow_realtime_dlight.ival;
|
|
|
|
#endif
|
2013-07-14 12:22:51 +00:00
|
|
|
r_viewleaf = NULL;
|
|
|
|
r_oldviewleaf = NULL;
|
|
|
|
r_viewleaf2 = NULL;
|
|
|
|
r_oldviewleaf2 = NULL;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
R_TimeRefresh_f
|
|
|
|
|
|
|
|
For program optimization
|
|
|
|
====================
|
|
|
|
*/
|
|
|
|
void GLR_TimeRefresh_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
float start, stop, time;
|
2010-11-02 23:17:25 +00:00
|
|
|
qboolean finish;
|
|
|
|
int frames = 128;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
finish = atoi(Cmd_Argv(1));
|
|
|
|
frames = atoi(Cmd_Argv(2));
|
|
|
|
if (frames < 1)
|
|
|
|
frames = 128;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
if (finish == 2)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
2010-11-02 23:17:25 +00:00
|
|
|
qglFinish ();
|
|
|
|
start = Sys_DoubleTime ();
|
|
|
|
for (i=0 ; i<frames ; i++)
|
|
|
|
{
|
|
|
|
r_refdef.viewangles[1] = i/(float)frames*360.0;
|
|
|
|
R_RenderView ();
|
2014-03-30 00:39:37 +00:00
|
|
|
VID_SwapBuffers();
|
2010-11-02 23:17:25 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
2010-11-02 23:17:25 +00:00
|
|
|
else
|
|
|
|
{
|
2012-04-09 19:12:12 +00:00
|
|
|
if (qglDrawBuffer)
|
|
|
|
qglDrawBuffer (GL_FRONT);
|
2010-11-02 23:17:25 +00:00
|
|
|
qglFinish ();
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-11-02 23:17:25 +00:00
|
|
|
start = Sys_DoubleTime ();
|
|
|
|
for (i=0 ; i<frames ; i++)
|
|
|
|
{
|
|
|
|
r_refdef.viewangles[1] = i/(float)frames*360.0;
|
|
|
|
R_RenderView ();
|
|
|
|
if (finish)
|
|
|
|
qglFinish ();
|
|
|
|
}
|
|
|
|
}
|
2005-01-07 03:04:42 +00:00
|
|
|
qglFinish ();
|
2004-08-22 22:29:09 +00:00
|
|
|
stop = Sys_DoubleTime ();
|
|
|
|
time = stop-start;
|
2010-11-02 23:17:25 +00:00
|
|
|
Con_Printf ("%f seconds (%f fps)\n", time, frames/time);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2012-04-09 19:12:12 +00:00
|
|
|
if (qglDrawBuffer)
|
|
|
|
qglDrawBuffer (GL_BACK);
|
2004-08-22 22:29:09 +00:00
|
|
|
GL_EndRendering ();
|
2014-03-30 00:39:37 +00:00
|
|
|
VID_SwapBuffers();
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
2004-12-15 19:53:30 +00:00
|
|
|
#endif
|