11 Jan 2008
This commit is contained in:
parent
3fe7f7fa6d
commit
59bec04c9f
|
@ -469,7 +469,7 @@ void WradMain ( bool option )
|
|||
if( extrasamples )
|
||||
{
|
||||
numbounce = 8;
|
||||
//ambient = 3; //FIXME: check result
|
||||
ambient = 125; //FIXME: check result
|
||||
}
|
||||
else numbounce = 3;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ shader_t *FindShader( const char *texture )
|
|||
strlower(texture, texname );
|
||||
|
||||
// build full path
|
||||
sprintf (shader, "textures/%s", texname );
|
||||
com.sprintf (shader, "textures/%s", texname );
|
||||
|
||||
// look for it
|
||||
for (i = 0, texshader = shaderInfo; i < numShaderInfo; i++, texshader++)
|
||||
|
|
|
@ -38,7 +38,7 @@ int FindMiptex( char *name )
|
|||
textureref[i].value = LittleLong (si->intensity);
|
||||
textureref[i].flags = LittleLong (si->surfaceFlags);
|
||||
textureref[i].contents = LittleLong (si->contents);
|
||||
strcpy(textureref[i].animname, si->nextframe);
|
||||
com.strcpy(textureref[i].animname, si->nextframe);
|
||||
}
|
||||
nummiptex++;
|
||||
|
||||
|
@ -107,7 +107,7 @@ int TexinfoForBrushTexture (plane_t *plane, brush_texture_t *bt, vec3_t origin)
|
|||
|
||||
if (bt->txcommand)
|
||||
{
|
||||
memcpy(tx.vecs, bt->vects.quark.vects, sizeof(tx.vecs));
|
||||
Mem_Copy(tx.vecs, bt->vects.quark.vects, sizeof(tx.vecs));
|
||||
|
||||
if (origin[0] || origin[1] || origin[2])
|
||||
{
|
||||
|
|
|
@ -392,7 +392,7 @@ Image_Resample
|
|||
*/
|
||||
byte *Image_Resample (const void *indata, int inwidth, int inheight, int outwidth, int outheight, int in_type )
|
||||
{
|
||||
bool quality = true; //FIXME
|
||||
bool quality = false; //FIXME
|
||||
byte *outdata;
|
||||
|
||||
// nothing to resample ?
|
||||
|
@ -447,9 +447,10 @@ bool Image_Processing( const char *name, rgbdata_t **pix, int width, int height
|
|||
else if(image->type == PF_RGB_24) pixel = 3;
|
||||
else if(image->type == PF_RGB_24_FLIP) pixel = 3;
|
||||
else return false; // unknown format
|
||||
MsgDev(D_INFO,"Resampling %s from[%d x %d] to[%d x %d]\n",name, image->width, image->height, w, h );
|
||||
MsgDev(D_INFO,"Resampling %s from[%d x %d] to [%d x %d]\n",name, image->width, image->height,w,h );
|
||||
Mem_Move( Sys.imagepool, &image->buffer, out, w * h * pixel ); // update image->buffer
|
||||
image->width = w, image->height = h;
|
||||
image->size = w * h * pixel;
|
||||
*pix = image;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -782,6 +782,9 @@ _inline int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, cplane_t *p)
|
|||
}
|
||||
}
|
||||
|
||||
#define PlaneDist(point,plane) ((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal))
|
||||
#define PlaneDiff(point,plane) (((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal)) - (plane)->dist)
|
||||
|
||||
_inline void ConvertDimensionToPhysic( vec3_t v )
|
||||
{
|
||||
vec3_t tmp;
|
||||
|
|
|
@ -235,6 +235,7 @@ extern cvar_t *r_bloom_sample_size;
|
|||
extern cvar_t *r_bloom_fast_sample;
|
||||
extern cvar_t *r_motionblur_intens;
|
||||
extern cvar_t *r_motionblur;
|
||||
extern cvar_t *r_mirroralpha;
|
||||
|
||||
extern cvar_t *gl_nosubimage;
|
||||
extern cvar_t *gl_bitdepth;
|
||||
|
|
|
@ -645,7 +645,6 @@ void Mod_LoadFaces (lump_t *l)
|
|||
}
|
||||
GL_SubdivideSurface (out); // cut up polygon for warps
|
||||
}
|
||||
|
||||
// create lightmaps and polygons
|
||||
if(!(out->texinfo->flags & (SURF_SKY|SURF_BLEND|SURF_WARP) ) )
|
||||
GL_CreateSurfaceLightmap (out);
|
||||
|
|
|
@ -1,22 +1,9 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 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.
|
||||
|
||||
*/
|
||||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// r_mirror.h - realtime stencil mirror
|
||||
//=======================================================================
|
||||
#ifndef R_MODEL_H
|
||||
#define R_MODEL_H
|
||||
|
||||
#include "basefiles.h"
|
||||
|
||||
|
@ -295,4 +282,6 @@ void Mod_FreeAll (void);
|
|||
void Mod_Free (model_t *mod);
|
||||
|
||||
|
||||
int R_StudioExtractBbox( studiohdr_t *phdr, int sequence, float *mins, float *maxs );
|
||||
int R_StudioExtractBbox( studiohdr_t *phdr, int sequence, float *mins, float *maxs );
|
||||
|
||||
#endif//R_MODEL_H
|
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
// r_main.c
|
||||
#include "gl_local.h"
|
||||
#include "r_mirror.h"
|
||||
|
||||
void R_Clear (void);
|
||||
|
||||
|
@ -92,6 +93,7 @@ cvar_t *r_lefthand;
|
|||
cvar_t *r_loading;
|
||||
|
||||
cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light level
|
||||
cvar_t *r_mirroralpha;
|
||||
cvar_t *gl_nosubimage;
|
||||
cvar_t *gl_allow_software;
|
||||
|
||||
|
@ -572,6 +574,8 @@ void R_SetupGL (void)
|
|||
//
|
||||
// set up viewport
|
||||
//
|
||||
qglMatrixMode( GL_PROJECTION );
|
||||
qglLoadIdentity();
|
||||
x = floor(r_newrefdef.x * r_width->integer / r_width->integer);
|
||||
x2 = ceil((r_newrefdef.x + r_newrefdef.width) * r_width->integer / r_width->integer);
|
||||
y = floor(r_height->integer - r_newrefdef.y * r_height->integer / r_height->integer);
|
||||
|
@ -580,21 +584,20 @@ void R_SetupGL (void)
|
|||
w = x2 - x;
|
||||
h = y - y2;
|
||||
|
||||
if( mirror ) Mirror_Scale();
|
||||
else qglCullFace(GL_FRONT);
|
||||
qglViewport (x, y2, w, h);
|
||||
|
||||
//
|
||||
// set up projection matrix
|
||||
//
|
||||
screenaspect = (float)r_newrefdef.width/r_newrefdef.height;
|
||||
screenaspect = (float)r_newrefdef.width/r_newrefdef.height;
|
||||
// yfov = 2*atan((float)r_newrefdef.height/r_newrefdef.width)*180/M_PI;
|
||||
qglMatrixMode(GL_PROJECTION);
|
||||
qglLoadIdentity ();
|
||||
|
||||
qglPerspective (r_newrefdef.fov_y, screenaspect, 4, 4096);
|
||||
|
||||
qglCullFace(GL_FRONT);
|
||||
|
||||
qglMatrixMode(GL_MODELVIEW);
|
||||
qglLoadIdentity ();
|
||||
qglLoadIdentity ();
|
||||
|
||||
qglRotatef (-90, 1, 0, 0); // put Z going up
|
||||
qglRotatef (90, 0, 0, 1); // put Z going up
|
||||
|
@ -610,8 +613,7 @@ void R_SetupGL (void)
|
|||
//
|
||||
if (gl_cull->value)
|
||||
qglEnable(GL_CULL_FACE);
|
||||
else
|
||||
qglDisable(GL_CULL_FACE);
|
||||
else qglDisable(GL_CULL_FACE);
|
||||
|
||||
qglDisable(GL_BLEND);
|
||||
qglDisable(GL_ALPHA_TEST);
|
||||
|
@ -656,11 +658,13 @@ void R_Clear (void)
|
|||
qglClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
else qglClear (GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
gldepthmin = 0;
|
||||
gldepthmax = 1;
|
||||
if( r_mirroralpha->value < 1.0 )
|
||||
gldepthmax = 0.5;
|
||||
else gldepthmax = 1;
|
||||
qglDepthFunc (GL_LEQUAL);
|
||||
}
|
||||
|
||||
qglDepthRange (gldepthmin, gldepthmax);
|
||||
}
|
||||
|
||||
|
@ -716,7 +720,7 @@ R_RenderView
|
|||
r_newrefdef must be set before the first call
|
||||
================
|
||||
*/
|
||||
void R_RenderView (refdef_t *fd)
|
||||
void R_RenderView( refdef_t *fd )
|
||||
{
|
||||
if (r_norefresh->value)
|
||||
return;
|
||||
|
@ -758,6 +762,8 @@ void R_DrawPauseScreen( void )
|
|||
if(r_newrefdef.rdflags & RDF_NOWORLDMODEL)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
if(r_pause->modified )
|
||||
{
|
||||
// reset saturation value
|
||||
|
@ -809,7 +815,7 @@ int R_DrawRSpeeds(char *S)
|
|||
dword blurtex = 0;
|
||||
dword blur_shader = 0;
|
||||
|
||||
void R_SetGL2D (void)
|
||||
void R_SetGL2D( void )
|
||||
{
|
||||
R_DrawPauseScreen();
|
||||
|
||||
|
@ -946,8 +952,13 @@ R_RenderFrame
|
|||
*/
|
||||
void R_RenderFrame (refdef_t *fd)
|
||||
{
|
||||
r_mirroralpha->value = bound( 0.0f, r_mirroralpha->value, 1.0f );
|
||||
mirror = false;
|
||||
mirror_render = false;
|
||||
|
||||
R_RenderView( fd );
|
||||
R_SetLightLevel ();
|
||||
if( mirror ) R_Mirror( fd );
|
||||
R_SetGL2D ();
|
||||
}
|
||||
|
||||
|
@ -1000,6 +1011,8 @@ void R_Register( void )
|
|||
r_minimap_style = Cvar_Get ("r_minimap_style", "1", CVAR_ARCHIVE );
|
||||
r_minimap = Cvar_Get("r_minimap", "0", CVAR_ARCHIVE );
|
||||
|
||||
r_mirroralpha = Cvar_Get( "r_mirroralpha", "0.5", CVAR_ARCHIVE );
|
||||
|
||||
gl_modulate = Cvar_Get ("gl_modulate", "1", CVAR_ARCHIVE );
|
||||
gl_log = Cvar_Get( "gl_log", "0", 0 );
|
||||
gl_bitdepth = Cvar_Get( "gl_bitdepth", "0", 0 );
|
||||
|
|
|
@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
// GL_RSURF.C: surface-related refresh code
|
||||
#include "gl_local.h"
|
||||
#include "r_mirror.h"
|
||||
|
||||
static vec3_t modelorg; // relative to viewpoint
|
||||
|
||||
|
@ -1027,6 +1028,17 @@ void R_RecursiveWorldNode (mnode_t *node)
|
|||
surf->texturechain = r_alpha_surfaces;
|
||||
r_alpha_surfaces = surf;
|
||||
}
|
||||
else if (surf->texinfo->flags & SURF_NODRAW)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (r_mirroralpha->value < 1.0f && !mirror_render && surf->texinfo->flags & SURF_MIRROR)
|
||||
{
|
||||
mirror = true;
|
||||
surf->texturechain = mirrorchain;
|
||||
mirrorchain = surf;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( qglMTexCoord2fSGIS && !( surf->flags & SURF_DRAWTURB ) )
|
||||
|
@ -1168,9 +1180,11 @@ void R_MarkLeaves (void)
|
|||
mleaf_t *leaf;
|
||||
int cluster;
|
||||
|
||||
if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && !r_novis->value && r_viewcluster != -1)
|
||||
if( r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && !r_novis->value && r_viewcluster != -1)
|
||||
return;
|
||||
|
||||
if( mirror ) return;
|
||||
|
||||
// development aid to let you run around and see exactly where
|
||||
// the pvs ends
|
||||
if (gl_lockpvs->value)
|
||||
|
|
|
@ -555,6 +555,6 @@ bool VID_ScreenShot( const char *filename, bool levelshot )
|
|||
|
||||
// write image
|
||||
FS_SaveImage( filename, r_shot );
|
||||
FS_FreeImage( r_shot );
|
||||
Mem_Free( r_shot );
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// r_sprite.c - render sprite models
|
||||
//=======================================================================
|
||||
|
||||
#include "gl_local.h"
|
||||
#include "r_mirror.h"
|
||||
|
||||
// glmsurface_t == msurface_t
|
||||
bool mirror;
|
||||
cplane_t *mirror_plane;
|
||||
msurface_t *mirrorchain = NULL;
|
||||
bool mirror_render; // true when reflections are being rendered
|
||||
float r_base_world_matrix[16];
|
||||
|
||||
void Mirror_Scale( void )
|
||||
{
|
||||
if( mirror_plane->normal[2] )
|
||||
qglScalef( 1, -1, 1);
|
||||
else qglScalef(-1, 1, 1);
|
||||
qglCullFace( GL_BACK );
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
R_Mirror
|
||||
=============
|
||||
*/
|
||||
void R_Mirror( refdef_t *fd )
|
||||
{
|
||||
float d, *v, mirror_alpha;
|
||||
vec3_t old_vieworg;
|
||||
vec3_t old_viewangles;
|
||||
vec3_t old_vforward;
|
||||
msurface_t *s;
|
||||
glpoly_t *p;
|
||||
int i;
|
||||
|
||||
// don't have infinite reflections if 2 mirrors are facing each other (looks ugly but
|
||||
// better than hanging the engine)
|
||||
mirror_render = true;
|
||||
|
||||
Mem_Copy( r_base_world_matrix, r_world_matrix, sizeof(r_base_world_matrix));
|
||||
VectorCopy(r_newrefdef.vieworg, old_vieworg);
|
||||
VectorCopy(r_newrefdef.viewangles, old_viewangles);
|
||||
VectorCopy(vforward, old_vforward);
|
||||
|
||||
// r_mirroralpha values of more than about 0.65 don't really look well or have any effect
|
||||
mirror_alpha = r_mirroralpha->value * (1.0 / 1.5);
|
||||
|
||||
for( s = mirrorchain; s; s = s->texturechain )
|
||||
{
|
||||
mirror_plane = s->plane;
|
||||
|
||||
d = PlaneDiff( old_vieworg, mirror_plane);
|
||||
VectorMA( old_vieworg, -2 * d, mirror_plane->normal, r_newrefdef.vieworg);
|
||||
|
||||
d = DotProduct( old_vforward, mirror_plane->normal);
|
||||
VectorMA( old_vforward, -2 * d, mirror_plane->normal, vforward);
|
||||
|
||||
r_newrefdef.viewangles[0] = -asin(vforward[2]) / M_PI * 180;
|
||||
r_newrefdef.viewangles[1] = atan2(vforward[1], vforward[0]) / M_PI * 180;
|
||||
r_newrefdef.viewangles[2] = -old_viewangles[2];
|
||||
|
||||
gldepthmin = 0.5;
|
||||
gldepthmax = 1;
|
||||
qglDepthRange( gldepthmin, gldepthmax );
|
||||
qglDepthFunc( GL_LEQUAL );
|
||||
|
||||
R_RenderView( &r_newrefdef ); // do reflection
|
||||
|
||||
gldepthmin = 0;
|
||||
gldepthmax = 0.5;
|
||||
qglDepthRange( gldepthmin, gldepthmax );
|
||||
qglDepthFunc( GL_LEQUAL );
|
||||
qglMatrixMode( GL_PROJECTION );
|
||||
|
||||
if (mirror_plane->normal[2])
|
||||
qglScalef (1, -1, 1);
|
||||
else qglScalef (-1, 1, 1);
|
||||
|
||||
qglCullFace( GL_FRONT );
|
||||
qglMatrixMode( GL_MODELVIEW );
|
||||
qglLoadMatrixf( r_base_world_matrix );
|
||||
GL_EnableBlend();
|
||||
qglBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
qglColor4f( 1.0f, 1.0f, 1.0f, mirror_alpha );
|
||||
GL_Bind(s->texinfo->image->texnum[0]);
|
||||
|
||||
p = s->polys;
|
||||
v = p->verts[0];
|
||||
|
||||
qglBegin( GL_POLYGON );
|
||||
|
||||
// draw mirror surface
|
||||
for (i = 0; i < p->numverts; i++, v += VERTEXSIZE)
|
||||
{
|
||||
qglTexCoord2fv(&v[3]);
|
||||
qglVertex3fv(v);
|
||||
}
|
||||
qglEnd();
|
||||
qglColor4f( 1.0, 1.0f, 1.0f, 1.0f );
|
||||
GL_DisableBlend();
|
||||
}
|
||||
|
||||
mirrorchain = NULL;
|
||||
mirror = false;
|
||||
mirror_render = false;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// r_mirror.h - realtime stencil mirror
|
||||
//=======================================================================
|
||||
#ifndef R_MIRROR_H
|
||||
#define R_MIRROR_H
|
||||
|
||||
#include "gl_model.h"
|
||||
|
||||
void Mirror_Scale( void );
|
||||
void Mirror_Clear( void );
|
||||
void R_Mirror( refdef_t *fd );
|
||||
extern bool mirror;
|
||||
extern cplane_t *mirror_plane;
|
||||
extern msurface_t *mirrorchain;
|
||||
extern bool mirror_render;
|
||||
|
||||
#endif//R_MIRROR_H
|
|
@ -237,7 +237,7 @@ bool R_GetPixelFormat( rgbdata_t *pic, imagetype_t type )
|
|||
MsgDev(D_WARN, "R_GetPixelFormat: invalid image size (%i should be %i)\n", pic->size, totalsize );
|
||||
return false;
|
||||
}
|
||||
if(s&3) // will be resampled, not error
|
||||
if(s&3) // will be resample, not error
|
||||
{
|
||||
MsgDev(D_WARN, "R_GetPixelFormat: s&3 [%d x %d]\n", image_desc.width, image_desc.height );
|
||||
return false;
|
||||
|
|
|
@ -57,8 +57,8 @@ LINK32=link.exe
|
|||
# ADD LINK32 msvcrt.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /libpath:"../public/libs/"
|
||||
# SUBTRACT LINK32 /debug
|
||||
# Begin Custom Build
|
||||
TargetDir=\XASH3D\src_main\!source\temp\render\!release
|
||||
InputPath=\XASH3D\src_main\!source\temp\render\!release\render.dll
|
||||
TargetDir=\XASH3D\src_main\temp\render\!release
|
||||
InputPath=\XASH3D\src_main\temp\render\!release\render.dll
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
"D:\Xash3D\bin\render.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
|
@ -94,8 +94,8 @@ LINK32=link.exe
|
|||
# ADD LINK32 msvcrt.lib user32.lib gdi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept /libpath:"../public/libs/"
|
||||
# SUBTRACT LINK32 /profile /incremental:no /map
|
||||
# Begin Custom Build
|
||||
TargetDir=\XASH3D\src_main\!source\temp\render\!debug
|
||||
InputPath=\XASH3D\src_main\!source\temp\render\!debug\render.dll
|
||||
TargetDir=\XASH3D\src_main\temp\render\!debug
|
||||
InputPath=\XASH3D\src_main\temp\render\!debug\render.dll
|
||||
SOURCE="$(InputPath)"
|
||||
|
||||
"D:\Xash3D\bin\render.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
|
@ -162,6 +162,10 @@ SOURCE=.\r_bspmod.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\r_mirror.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\r_sprite.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -198,6 +202,10 @@ SOURCE=.\qmenu.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\r_mirror.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\r_opengl.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
Reference in New Issue