mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-22 20:51:31 +00:00
Merge pull request #313 from 0lvin/edges_limits
Scale edge/surfaces/verts on outof....
This commit is contained in:
commit
38a499c335
24 changed files with 630 additions and 529 deletions
|
@ -454,6 +454,7 @@ set(GL1-Source
|
|||
${REF_SRC_DIR}/files/pcx.c
|
||||
${REF_SRC_DIR}/files/stb.c
|
||||
${REF_SRC_DIR}/files/wal.c
|
||||
${REF_SRC_DIR}/files/pvs.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/md4.c
|
||||
)
|
||||
|
@ -490,6 +491,7 @@ set(GL3-Source
|
|||
${REF_SRC_DIR}/files/pcx.c
|
||||
${REF_SRC_DIR}/files/stb.c
|
||||
${REF_SRC_DIR}/files/wal.c
|
||||
${REF_SRC_DIR}/files/pvs.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/md4.c
|
||||
)
|
||||
|
@ -531,6 +533,7 @@ set(SOFT-Source
|
|||
${REF_SRC_DIR}/files/pcx.c
|
||||
${REF_SRC_DIR}/files/stb.c
|
||||
${REF_SRC_DIR}/files/wal.c
|
||||
${REF_SRC_DIR}/files/pvs.c
|
||||
${COMMON_SRC_DIR}/shared/shared.c
|
||||
${COMMON_SRC_DIR}/md4.c
|
||||
)
|
||||
|
|
3
Makefile
3
Makefile
|
@ -920,6 +920,7 @@ REFGL1_OBJS_ := \
|
|||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/pvs.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/md4.o
|
||||
|
||||
|
@ -952,6 +953,7 @@ REFGL3_OBJS_ := \
|
|||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/pvs.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/md4.o
|
||||
|
||||
|
@ -986,6 +988,7 @@ REFSOFT_OBJS_ := \
|
|||
src/client/refresh/files/pcx.o \
|
||||
src/client/refresh/files/stb.o \
|
||||
src/client/refresh/files/wal.o \
|
||||
src/client/refresh/files/pvs.o \
|
||||
src/common/shared/shared.o \
|
||||
src/common/md4.o
|
||||
|
||||
|
|
76
src/client/refresh/files/pvs.c
Normal file
76
src/client/refresh/files/pvs.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* =======================================================================
|
||||
*
|
||||
* The PVS Decompress
|
||||
*
|
||||
* =======================================================================
|
||||
*/
|
||||
|
||||
#include "../ref_shared.h"
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
Mod_DecompressVis
|
||||
===================
|
||||
*/
|
||||
byte *
|
||||
Mod_DecompressVis(byte *in, int row)
|
||||
{
|
||||
static byte decompressed[MAX_MAP_LEAFS / 8];
|
||||
int c;
|
||||
byte *out;
|
||||
|
||||
out = decompressed;
|
||||
|
||||
if (!in)
|
||||
{
|
||||
/* no vis info, so make all visible */
|
||||
while (row)
|
||||
{
|
||||
*out++ = 0xff;
|
||||
row--;
|
||||
}
|
||||
|
||||
return decompressed;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (*in)
|
||||
{
|
||||
*out++ = *in++;
|
||||
continue;
|
||||
}
|
||||
|
||||
c = in[1];
|
||||
in += 2;
|
||||
|
||||
while (c)
|
||||
{
|
||||
*out++ = 0;
|
||||
c--;
|
||||
}
|
||||
}
|
||||
while (out - decompressed < row);
|
||||
|
||||
return decompressed;
|
||||
}
|
|
@ -84,51 +84,6 @@ Mod_PointInLeaf(vec3_t p, model_t *model)
|
|||
return NULL; /* never reached */
|
||||
}
|
||||
|
||||
byte *
|
||||
Mod_DecompressVis(byte *in, model_t *model)
|
||||
{
|
||||
static byte decompressed[MAX_MAP_LEAFS / 8];
|
||||
int c;
|
||||
byte *out;
|
||||
int row;
|
||||
|
||||
row = (model->vis->numclusters + 7) >> 3;
|
||||
out = decompressed;
|
||||
|
||||
if (!in)
|
||||
{
|
||||
/* no vis info, so make all visible */
|
||||
while (row)
|
||||
{
|
||||
*out++ = 0xff;
|
||||
row--;
|
||||
}
|
||||
|
||||
return decompressed;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (*in)
|
||||
{
|
||||
*out++ = *in++;
|
||||
continue;
|
||||
}
|
||||
|
||||
c = in[1];
|
||||
in += 2;
|
||||
|
||||
while (c)
|
||||
{
|
||||
*out++ = 0;
|
||||
c--;
|
||||
}
|
||||
}
|
||||
while (out - decompressed < row);
|
||||
|
||||
return decompressed;
|
||||
}
|
||||
|
||||
byte *
|
||||
Mod_ClusterPVS(int cluster, model_t *model)
|
||||
{
|
||||
|
@ -139,7 +94,7 @@ Mod_ClusterPVS(int cluster, model_t *model)
|
|||
|
||||
return Mod_DecompressVis((byte *)model->vis +
|
||||
model->vis->bitofs[cluster][DVIS_PVS],
|
||||
model);
|
||||
(model->vis->numclusters + 7) >> 3);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -76,51 +76,6 @@ GL3_Mod_PointInLeaf(vec3_t p, gl3model_t *model)
|
|||
return NULL; /* never reached */
|
||||
}
|
||||
|
||||
static byte *
|
||||
Mod_DecompressVis(byte *in, gl3model_t *model)
|
||||
{
|
||||
static byte decompressed[MAX_MAP_LEAFS / 8];
|
||||
int c;
|
||||
byte *out;
|
||||
int row;
|
||||
|
||||
row = (model->vis->numclusters + 7) >> 3;
|
||||
out = decompressed;
|
||||
|
||||
if (!in)
|
||||
{
|
||||
/* no vis info, so make all visible */
|
||||
while (row)
|
||||
{
|
||||
*out++ = 0xff;
|
||||
row--;
|
||||
}
|
||||
|
||||
return decompressed;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (*in)
|
||||
{
|
||||
*out++ = *in++;
|
||||
continue;
|
||||
}
|
||||
|
||||
c = in[1];
|
||||
in += 2;
|
||||
|
||||
while (c)
|
||||
{
|
||||
*out++ = 0;
|
||||
c--;
|
||||
}
|
||||
}
|
||||
while (out - decompressed < row);
|
||||
|
||||
return decompressed;
|
||||
}
|
||||
|
||||
byte*
|
||||
GL3_Mod_ClusterPVS(int cluster, gl3model_t *model)
|
||||
{
|
||||
|
@ -131,7 +86,7 @@ GL3_Mod_ClusterPVS(int cluster, gl3model_t *model)
|
|||
|
||||
return Mod_DecompressVis((byte *)model->vis +
|
||||
model->vis->bitofs[cluster][DVIS_PVS],
|
||||
model);
|
||||
(model->vis->numclusters + 7) >> 3);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -67,4 +67,5 @@ extern qboolean LoadSTB(const char *origname, const char* type, byte **pic, int
|
|||
|
||||
extern void GetWalInfo(char *name, int *width, int *height);
|
||||
|
||||
extern byte* Mod_DecompressVis(byte *in, int row);
|
||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||
|
|
|
@ -158,12 +158,6 @@ extern oldrefdef_t r_refdef;
|
|||
|
||||
#define DS_SPAN_LIST_END -128
|
||||
|
||||
#define NUMSTACKEDGES 2000
|
||||
#define MINEDGES NUMSTACKEDGES
|
||||
#define NUMSTACKSURFACES 1000
|
||||
#define MINSURFACES NUMSTACKSURFACES
|
||||
#define MAXSPANS 3000
|
||||
|
||||
// flags in finalvert_t.flags
|
||||
#define ALIAS_LEFT_CLIP 0x0001
|
||||
#define ALIAS_TOP_CLIP 0x0002
|
||||
|
@ -186,8 +180,6 @@ extern oldrefdef_t r_refdef;
|
|||
|
||||
#define NEAR_CLIP 0.01
|
||||
|
||||
|
||||
#define MAXALIASVERTS 2000 // TODO: tune this
|
||||
#define ALIAS_Z_CLIP_PLANE 4
|
||||
|
||||
// turbulence stuff
|
||||
|
@ -360,8 +352,6 @@ void R_PolysetUpdateTables(void);
|
|||
|
||||
// callbacks to Quake
|
||||
|
||||
extern drawsurf_t r_drawsurf;
|
||||
|
||||
extern int c_surf;
|
||||
|
||||
extern pixel_t *r_warpbuffer;
|
||||
|
@ -487,7 +477,7 @@ void R_DrawSolidClippedSubmodelPolygons(model_t *pmodel, mnode_t *topnode);
|
|||
|
||||
void R_AliasDrawModel(void);
|
||||
void R_BeginEdgeFrame(void);
|
||||
void R_ScanEdges(void);
|
||||
void R_ScanEdges(surf_t *surface);
|
||||
void R_PushDlights(model_t *model);
|
||||
|
||||
extern void R_RotateBmodel (void);
|
||||
|
@ -504,7 +494,6 @@ extern int r_currentbkey;
|
|||
void R_DrawParticles (void);
|
||||
|
||||
extern int r_amodels_drawn;
|
||||
extern edge_t *auxedges;
|
||||
extern int r_numallocatededges;
|
||||
extern edge_t *r_edges, *edge_p, *edge_max;
|
||||
|
||||
|
@ -523,16 +512,18 @@ extern spanpackage_t *triangle_spans;
|
|||
extern byte **warp_rowptr;
|
||||
extern int *warp_column;
|
||||
extern espan_t *edge_basespans;
|
||||
extern finalvert_t *finalverts;
|
||||
extern int r_numallocatedverts;
|
||||
extern finalvert_t *finalverts, *finalverts_max;
|
||||
|
||||
extern int r_aliasblendcolor;
|
||||
|
||||
extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
|
||||
extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
|
||||
|
||||
extern int r_outofsurfaces;
|
||||
extern int r_outofedges;
|
||||
extern int r_outofsurfaces;
|
||||
extern int r_outofedges;
|
||||
extern int r_outofverts;
|
||||
|
||||
extern mvertex_t *r_pcurrentvertbase;
|
||||
extern mvertex_t *r_pcurrentvertbase;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -552,7 +543,6 @@ extern float se_time1, se_time2, de_time1, de_time2, dv_time1, dv_time2;
|
|||
extern int r_viewcluster, r_oldviewcluster;
|
||||
|
||||
extern int r_clipflags;
|
||||
extern int r_dlightframecount;
|
||||
|
||||
extern image_t *r_notexture_mip;
|
||||
extern model_t *r_worldmodel;
|
||||
|
@ -599,17 +589,6 @@ image_t *R_FindImage(char *name, imagetype_t type);
|
|||
void R_FreeUnusedImages(void);
|
||||
|
||||
void R_InitSkyBox(void);
|
||||
|
||||
typedef struct swstate_s
|
||||
{
|
||||
qboolean fullscreen;
|
||||
int prev_mode; // last valid SW mode
|
||||
|
||||
unsigned char gammatable[256];
|
||||
unsigned char currentpalette[1024];
|
||||
|
||||
} swstate_t;
|
||||
|
||||
void R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha );
|
||||
|
||||
/*
|
||||
|
|
|
@ -17,17 +17,11 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_aclip.c: clip routines for drawing Alias models directly to the screen
|
||||
// sw_aclip.c: clip routines for drawing Alias models directly to the screen
|
||||
|
||||
#include "header/local.h"
|
||||
|
||||
static finalvert_t fv[2][8];
|
||||
|
||||
void R_AliasProjectAndClipTestFinalVert (finalvert_t *fv);
|
||||
static void R_Alias_clip_top (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out);
|
||||
static void R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out);
|
||||
static void R_Alias_clip_left (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out);
|
||||
static void R_Alias_clip_right (finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out);
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -176,7 +170,8 @@ R_Alias_clip_bottom (finalvert_t *pfv0, finalvert_t *pfv1,
|
|||
}
|
||||
|
||||
|
||||
int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
|
||||
int
|
||||
R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
|
||||
void(*clip)(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out) )
|
||||
{
|
||||
int i,j,k;
|
||||
|
@ -222,10 +217,12 @@ int R_AliasClip (finalvert_t *in, finalvert_t *out, int flag, int count,
|
|||
R_AliasClipTriangle
|
||||
================
|
||||
*/
|
||||
void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2)
|
||||
void
|
||||
R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2)
|
||||
{
|
||||
int i, k, pingpong;
|
||||
unsigned clipflags;
|
||||
finalvert_t fv[2][8];
|
||||
|
||||
// copy vertexes and fix seam texture coordinates
|
||||
fv[0][0] = *index0;
|
||||
|
|
|
@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_alias.c: routines for setting up to draw alias models
|
||||
// sw_alias.c: routines for setting up to draw alias models
|
||||
|
||||
/*
|
||||
** use a real variable to control lerping
|
||||
|
@ -221,38 +221,26 @@ R_AliasPreparePoints
|
|||
General clipped case
|
||||
================
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int num_points;
|
||||
dtrivertx_t *last_verts; // verts from the last frame
|
||||
dtrivertx_t *this_verts; // verts from this frame
|
||||
finalvert_t *dest_verts; // destination for transformed verts
|
||||
} aliasbatchedtransformdata_t;
|
||||
|
||||
static aliasbatchedtransformdata_t aliasbatchedtransformdata;
|
||||
finalvert_t *finalverts;
|
||||
|
||||
static void
|
||||
R_AliasPreparePoints (void)
|
||||
R_AliasPreparePoints (finalvert_t *verts, finalvert_t *verts_max)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
dstvert_t *pstverts;
|
||||
dtriangle_t *ptri;
|
||||
finalvert_t *pfv[3];
|
||||
finalvert_t *pfinalverts;
|
||||
|
||||
// put work vertexes on stack, cache aligned
|
||||
pfinalverts = finalverts;
|
||||
if ((verts + s_pmdl->num_xyz) >= verts_max)
|
||||
{
|
||||
r_outofverts += s_pmdl->num_xyz - (verts_max - verts);
|
||||
return;
|
||||
}
|
||||
|
||||
aliasbatchedtransformdata.num_points = s_pmdl->num_xyz;
|
||||
aliasbatchedtransformdata.last_verts = r_lastframe->verts;
|
||||
aliasbatchedtransformdata.this_verts = r_thisframe->verts;
|
||||
aliasbatchedtransformdata.dest_verts = pfinalverts;
|
||||
|
||||
R_AliasTransformFinalVerts( aliasbatchedtransformdata.num_points,
|
||||
aliasbatchedtransformdata.dest_verts,
|
||||
aliasbatchedtransformdata.last_verts,
|
||||
aliasbatchedtransformdata.this_verts );
|
||||
R_AliasTransformFinalVerts( s_pmdl->num_xyz,
|
||||
verts, // destination for transformed verts
|
||||
r_lastframe->verts, // verts from the last frame
|
||||
r_thisframe->verts // verts from this frame
|
||||
);
|
||||
|
||||
// clip and draw all triangles
|
||||
//
|
||||
|
@ -263,9 +251,9 @@ R_AliasPreparePoints (void)
|
|||
{
|
||||
for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
|
||||
{
|
||||
pfv[0] = &pfinalverts[ptri->index_xyz[0]];
|
||||
pfv[1] = &pfinalverts[ptri->index_xyz[1]];
|
||||
pfv[2] = &pfinalverts[ptri->index_xyz[2]];
|
||||
pfv[0] = &verts[ptri->index_xyz[0]];
|
||||
pfv[1] = &verts[ptri->index_xyz[1]];
|
||||
pfv[2] = &verts[ptri->index_xyz[2]];
|
||||
|
||||
if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
|
||||
continue; // completely clipped
|
||||
|
@ -298,9 +286,9 @@ R_AliasPreparePoints (void)
|
|||
{
|
||||
for (i=0 ; i<s_pmdl->num_tris ; i++, ptri++)
|
||||
{
|
||||
pfv[0] = &pfinalverts[ptri->index_xyz[0]];
|
||||
pfv[1] = &pfinalverts[ptri->index_xyz[1]];
|
||||
pfv[2] = &pfinalverts[ptri->index_xyz[2]];
|
||||
pfv[0] = &verts[ptri->index_xyz[0]];
|
||||
pfv[1] = &verts[ptri->index_xyz[1]];
|
||||
pfv[2] = &verts[ptri->index_xyz[2]];
|
||||
|
||||
if ( pfv[0]->flags & pfv[1]->flags & pfv[2]->flags )
|
||||
continue; // completely clipped
|
||||
|
@ -469,7 +457,8 @@ R_AliasTransformFinalVerts( int numpoints, finalvert_t *fv, dtrivertx_t *oldv, d
|
|||
R_AliasProjectAndClipTestFinalVert
|
||||
================
|
||||
*/
|
||||
void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv )
|
||||
void
|
||||
R_AliasProjectAndClipTestFinalVert( finalvert_t *fv )
|
||||
{
|
||||
float zi;
|
||||
float x, y, z;
|
||||
|
@ -500,7 +489,8 @@ void R_AliasProjectAndClipTestFinalVert( finalvert_t *fv )
|
|||
R_AliasSetupSkin
|
||||
===============
|
||||
*/
|
||||
static qboolean R_AliasSetupSkin (void)
|
||||
static qboolean
|
||||
R_AliasSetupSkin (void)
|
||||
{
|
||||
image_t *pskindesc;
|
||||
|
||||
|
@ -704,12 +694,15 @@ R_AliasSetUpLerpData( dmdl_t *pmdl, float backlerp )
|
|||
}
|
||||
}
|
||||
|
||||
finalvert_t *finalverts = NULL, *finalverts_max = NULL;
|
||||
|
||||
/*
|
||||
================
|
||||
R_AliasDrawModel
|
||||
================
|
||||
*/
|
||||
void R_AliasDrawModel (void)
|
||||
void
|
||||
R_AliasDrawModel (void)
|
||||
{
|
||||
extern void (*d_pdrawspans)(void *);
|
||||
extern void R_PolysetDrawSpans8_Opaque( void * );
|
||||
|
@ -862,7 +855,7 @@ void R_AliasDrawModel (void)
|
|||
else
|
||||
s_ziscale = (float)0x8000 * (float)SHIFT16XYZ_MULT;
|
||||
|
||||
R_AliasPreparePoints ();
|
||||
R_AliasPreparePoints (finalverts, finalverts_max);
|
||||
|
||||
if ( currententity->flags & RF_WEAPONMODEL )
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_bsp.c
|
||||
// sw_bsp.c
|
||||
|
||||
#include "header/local.h"
|
||||
|
||||
|
@ -74,7 +74,8 @@ R_EntityRotate (vec3_t vec)
|
|||
R_RotateBmodel
|
||||
================
|
||||
*/
|
||||
void R_RotateBmodel (void)
|
||||
void
|
||||
R_RotateBmodel (void)
|
||||
{
|
||||
float angle, s, c, temp1[3][3], temp2[3][3], temp3[3][3];
|
||||
|
||||
|
@ -624,7 +625,8 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
|
|||
R_RenderWorld
|
||||
================
|
||||
*/
|
||||
void R_RenderWorld (void)
|
||||
void
|
||||
R_RenderWorld (void)
|
||||
{
|
||||
|
||||
if (!r_drawworld->value)
|
||||
|
|
|
@ -32,7 +32,8 @@ static image_t *draw_chars; // 8*8 graphic characters
|
|||
RE_Draw_FindPic
|
||||
================
|
||||
*/
|
||||
image_t *RE_Draw_FindPic (char *name)
|
||||
image_t *
|
||||
RE_Draw_FindPic (char *name)
|
||||
{
|
||||
image_t *image;
|
||||
|
||||
|
@ -56,7 +57,8 @@ image_t *RE_Draw_FindPic (char *name)
|
|||
Draw_InitLocal
|
||||
===============
|
||||
*/
|
||||
void Draw_InitLocal (void)
|
||||
void
|
||||
Draw_InitLocal (void)
|
||||
{
|
||||
draw_chars = RE_Draw_FindPic ("conchars");
|
||||
if (!draw_chars)
|
||||
|
@ -76,7 +78,8 @@ It can be clipped to the top of the screen to allow the console to be
|
|||
smoothly scrolled off.
|
||||
================
|
||||
*/
|
||||
void RE_Draw_CharScaled(int x, int y, int num, float scale)
|
||||
void
|
||||
RE_Draw_CharScaled(int x, int y, int num, float scale)
|
||||
{
|
||||
pixel_t *dest;
|
||||
byte *source;
|
||||
|
@ -134,7 +137,8 @@ void RE_Draw_CharScaled(int x, int y, int num, float scale)
|
|||
RE_Draw_GetPicSize
|
||||
=============
|
||||
*/
|
||||
void RE_Draw_GetPicSize (int *w, int *h, char *pic)
|
||||
void
|
||||
RE_Draw_GetPicSize (int *w, int *h, char *pic)
|
||||
{
|
||||
image_t *gl;
|
||||
|
||||
|
@ -153,7 +157,8 @@ void RE_Draw_GetPicSize (int *w, int *h, char *pic)
|
|||
RE_Draw_StretchPicImplementation
|
||||
=============
|
||||
*/
|
||||
void RE_Draw_StretchPicImplementation (int x, int y, int w, int h, image_t *pic)
|
||||
void
|
||||
RE_Draw_StretchPicImplementation (int x, int y, int w, int h, image_t *pic)
|
||||
{
|
||||
pixel_t *dest;
|
||||
byte *source;
|
||||
|
@ -205,7 +210,8 @@ void RE_Draw_StretchPicImplementation (int x, int y, int w, int h, image_t *pic)
|
|||
RE_Draw_StretchPic
|
||||
=============
|
||||
*/
|
||||
void RE_Draw_StretchPic (int x, int y, int w, int h, char *name)
|
||||
void
|
||||
RE_Draw_StretchPic (int x, int y, int w, int h, char *name)
|
||||
{
|
||||
image_t *pic;
|
||||
|
||||
|
@ -223,7 +229,8 @@ void RE_Draw_StretchPic (int x, int y, int w, int h, char *name)
|
|||
RE_Draw_StretchRaw
|
||||
=============
|
||||
*/
|
||||
void RE_Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data)
|
||||
void
|
||||
RE_Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data)
|
||||
{
|
||||
image_t pic;
|
||||
|
||||
|
@ -238,7 +245,8 @@ void RE_Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *d
|
|||
Draw_Pic
|
||||
=============
|
||||
*/
|
||||
void RE_Draw_PicScaled(int x, int y, char *name, float scale)
|
||||
void
|
||||
RE_Draw_PicScaled(int x, int y, char *name, float scale)
|
||||
{
|
||||
image_t *pic;
|
||||
pixel_t *dest;
|
||||
|
@ -320,7 +328,8 @@ This repeats a 64*64 tile graphic to fill the screen around a sized down
|
|||
refresh window.
|
||||
=============
|
||||
*/
|
||||
void RE_Draw_TileClear (int x, int y, int w, int h, char *name)
|
||||
void
|
||||
RE_Draw_TileClear (int x, int y, int w, int h, char *name)
|
||||
{
|
||||
int i, j;
|
||||
byte *psrc;
|
||||
|
@ -369,7 +378,8 @@ RE_Draw_Fill
|
|||
Fills a box of pixels with a single color
|
||||
=============
|
||||
*/
|
||||
void RE_Draw_Fill (int x, int y, int w, int h, int c)
|
||||
void
|
||||
RE_Draw_Fill (int x, int y, int w, int h, int c)
|
||||
{
|
||||
pixel_t *dest;
|
||||
int u, v;
|
||||
|
@ -406,7 +416,8 @@ RE_Draw_FadeScreen
|
|||
|
||||
================
|
||||
*/
|
||||
void RE_Draw_FadeScreen (void)
|
||||
void
|
||||
RE_Draw_FadeScreen (void)
|
||||
{
|
||||
int x,y;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_edge.c
|
||||
// sw_edge.c
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include "header/local.h"
|
||||
|
@ -29,12 +29,6 @@ low depth complexity -- 1 to 3 or so
|
|||
have a sentinal at both ends?
|
||||
*/
|
||||
|
||||
|
||||
edge_t *auxedges;
|
||||
edge_t *r_edges, *edge_p, *edge_max;
|
||||
|
||||
surf_t *surfaces, *surface_p, *surf_max;
|
||||
|
||||
// surfaces are generated in back to front order by the bsp, so if a surf
|
||||
// pointer is greater than another one, it should be drawn in front
|
||||
// surfaces[1] is the background, and is used as the active surface stack
|
||||
|
@ -85,13 +79,9 @@ EDGE SCANNING
|
|||
R_BeginEdgeFrame
|
||||
==============
|
||||
*/
|
||||
void R_BeginEdgeFrame (void)
|
||||
void
|
||||
R_BeginEdgeFrame (void)
|
||||
{
|
||||
edge_p = r_edges;
|
||||
edge_max = &r_edges[r_numallocatededges];
|
||||
|
||||
surface_p = &surfaces[2]; // background is surface 1,
|
||||
// surface 0 is a dummy
|
||||
surfaces[1].spans = NULL; // no background spans yet
|
||||
surfaces[1].flags = SURF_DRAWBACKGROUND;
|
||||
|
||||
|
@ -155,7 +145,8 @@ R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist)
|
|||
R_RemoveEdges
|
||||
==============
|
||||
*/
|
||||
static void R_RemoveEdges (edge_t *pedge)
|
||||
static void
|
||||
R_RemoveEdges (edge_t *pedge)
|
||||
{
|
||||
|
||||
do
|
||||
|
@ -198,7 +189,7 @@ R_StepActiveU (edge_t *pedge)
|
|||
// find out where the edge goes in the edge list
|
||||
pwedge = pedge->prev->prev;
|
||||
|
||||
while (pwedge && (pwedge->u > pedge->u))
|
||||
while (pwedge->u > pedge->u)
|
||||
{
|
||||
pwedge = pwedge->prev;
|
||||
}
|
||||
|
@ -298,8 +289,6 @@ R_LeadingEdgeBackwards (edge_t *edge)
|
|||
// end edge)
|
||||
if (++surf->spanstate == 1)
|
||||
{
|
||||
shift20_t iu;
|
||||
|
||||
surf2 = surfaces[1].next;
|
||||
|
||||
// if it's two surfaces on the same plane, the one that's already
|
||||
|
@ -307,6 +296,8 @@ R_LeadingEdgeBackwards (edge_t *edge)
|
|||
// must be two bmodels in the same leaf; don't care, because they'll
|
||||
// never be farthest anyway
|
||||
if (surf->key > surf2->key || (surf->insubmodel && (surf->key == surf2->key))) {
|
||||
shift20_t iu;
|
||||
|
||||
// emit a span (obscures current top)
|
||||
iu = edge->u >> shift_size;
|
||||
|
||||
|
@ -408,10 +399,12 @@ R_LeadingEdgeSearch
|
|||
static surf_t*
|
||||
R_LeadingEdgeSearch (edge_t *edge, surf_t *surf, surf_t *surf2)
|
||||
{
|
||||
float fu, newzi, testzi, newzitop, newzibottom;
|
||||
float testzi, newzitop;
|
||||
|
||||
do
|
||||
{
|
||||
float fu, newzi, newzibottom;
|
||||
|
||||
surf2 = D_SurfSearchForward(surf, surf2);
|
||||
|
||||
if (surf->key != surf2->key)
|
||||
|
@ -426,8 +419,10 @@ R_LeadingEdgeSearch (edge_t *edge, surf_t *surf, surf_t *surf2)
|
|||
testzi = surf2->d_ziorigin + fv*surf2->d_zistepv +
|
||||
fu*surf2->d_zistepu;
|
||||
|
||||
if (newzibottom < testzi)
|
||||
if (newzibottom >= testzi)
|
||||
{
|
||||
return surf2;
|
||||
}
|
||||
|
||||
newzitop = newzi * 1.01;
|
||||
}
|
||||
|
@ -585,7 +580,7 @@ R_GenerateSpansBackward (void)
|
|||
R_CleanupSpan ();
|
||||
}
|
||||
|
||||
static void D_DrawSurfaces (void);
|
||||
static void D_DrawSurfaces (surf_t *surface);
|
||||
|
||||
/*
|
||||
==============
|
||||
|
@ -600,7 +595,8 @@ Each surface has a linked list of its visible spans
|
|||
|
||||
==============
|
||||
*/
|
||||
void R_ScanEdges (void)
|
||||
void
|
||||
R_ScanEdges (surf_t *surface)
|
||||
{
|
||||
shift20_t iv, bottom;
|
||||
espan_t *basespan_p;
|
||||
|
@ -670,10 +666,10 @@ void R_ScanEdges (void)
|
|||
if (span_p > max_span_p)
|
||||
{
|
||||
// Draw stuff on screen
|
||||
D_DrawSurfaces ();
|
||||
D_DrawSurfaces (surface);
|
||||
|
||||
// clear the surface span pointers
|
||||
for (s = &surfaces[1] ; s<surface_p ; s++)
|
||||
for (s = &surfaces[1] ; s<surface ; s++)
|
||||
s->spans = NULL;
|
||||
|
||||
span_p = basespan_p;
|
||||
|
@ -702,7 +698,7 @@ void R_ScanEdges (void)
|
|||
(*pdrawfunc) ();
|
||||
|
||||
// draw whatever's left in the span list
|
||||
D_DrawSurfaces ();
|
||||
D_DrawSurfaces (surface);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1014,12 +1010,12 @@ To allow developers to see the polygon carving of the world
|
|||
=============
|
||||
*/
|
||||
static void
|
||||
D_DrawflatSurfaces (void)
|
||||
D_DrawflatSurfaces (surf_t *surface)
|
||||
{
|
||||
surf_t *s;
|
||||
int color = 0;
|
||||
|
||||
for (s = &surfaces[1] ; s<surface_p ; s++)
|
||||
for (s = &surfaces[1] ; s<surface ; s++)
|
||||
{
|
||||
if (!s->spans)
|
||||
continue;
|
||||
|
@ -1046,7 +1042,7 @@ May be called more than once a frame if the surf list overflows (higher res)
|
|||
==============
|
||||
*/
|
||||
static void
|
||||
D_DrawSurfaces (void)
|
||||
D_DrawSurfaces (surf_t *surface)
|
||||
{
|
||||
// currententity = NULL;
|
||||
// &r_worldentity;
|
||||
|
@ -1058,7 +1054,7 @@ D_DrawSurfaces (void)
|
|||
{
|
||||
surf_t *s;
|
||||
|
||||
for (s = &surfaces[1] ; s<surface_p ; s++)
|
||||
for (s = &surfaces[1] ; s<surface ; s++)
|
||||
{
|
||||
if (!s->spans)
|
||||
continue;
|
||||
|
@ -1076,7 +1072,7 @@ D_DrawSurfaces (void)
|
|||
}
|
||||
}
|
||||
else
|
||||
D_DrawflatSurfaces ();
|
||||
D_DrawflatSurfaces (surface);
|
||||
|
||||
currententity = NULL; //&r_worldentity;
|
||||
VectorSubtract (r_origin, vec3_origin, modelorg);
|
||||
|
|
|
@ -31,7 +31,8 @@ static int numr_images;
|
|||
R_ImageList_f
|
||||
===============
|
||||
*/
|
||||
void R_ImageList_f (void)
|
||||
void
|
||||
R_ImageList_f (void)
|
||||
{
|
||||
int i;
|
||||
image_t *image;
|
||||
|
@ -72,8 +73,8 @@ void R_ImageList_f (void)
|
|||
|
||||
//=======================================================
|
||||
|
||||
static image_t
|
||||
*R_FindFreeImage (void)
|
||||
static image_t *
|
||||
R_FindFreeImage (void)
|
||||
{
|
||||
image_t *image;
|
||||
int i;
|
||||
|
@ -101,7 +102,7 @@ R_LoadPic
|
|||
|
||||
================
|
||||
*/
|
||||
static image_t*
|
||||
static image_t *
|
||||
R_LoadPic (char *name, byte *pic, int width, int height, imagetype_t type)
|
||||
{
|
||||
image_t *image;
|
||||
|
@ -221,7 +222,8 @@ R_FindImage
|
|||
Finds or loads the given image
|
||||
===============
|
||||
*/
|
||||
image_t *R_FindImage (char *name, imagetype_t type)
|
||||
image_t *
|
||||
R_FindImage (char *name, imagetype_t type)
|
||||
{
|
||||
image_t *image;
|
||||
int i, len;
|
||||
|
@ -290,7 +292,8 @@ Any image that was not touched on this registration sequence
|
|||
will be freed.
|
||||
================
|
||||
*/
|
||||
void R_FreeUnusedImages (void)
|
||||
void
|
||||
R_FreeUnusedImages (void)
|
||||
{
|
||||
int i;
|
||||
image_t *image;
|
||||
|
@ -318,7 +321,8 @@ void R_FreeUnusedImages (void)
|
|||
R_InitImages
|
||||
===============
|
||||
*/
|
||||
void R_InitImages (void)
|
||||
void
|
||||
R_InitImages (void)
|
||||
{
|
||||
registration_sequence = 1;
|
||||
}
|
||||
|
@ -328,7 +332,8 @@ void R_InitImages (void)
|
|||
R_ShutdownImages
|
||||
===============
|
||||
*/
|
||||
void R_ShutdownImages (void)
|
||||
void
|
||||
R_ShutdownImages (void)
|
||||
{
|
||||
int i;
|
||||
image_t *image;
|
||||
|
|
|
@ -17,13 +17,10 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_light.c
|
||||
// sw_light.c
|
||||
|
||||
#include "header/local.h"
|
||||
|
||||
int r_dlightframecount;
|
||||
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
|
@ -38,7 +35,7 @@ R_MarkLights
|
|||
=============
|
||||
*/
|
||||
static void
|
||||
R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
||||
R_MarkLights (dlight_t *light, int bit, mnode_t *node, int r_dlightframecount)
|
||||
{
|
||||
mplane_t *splitplane;
|
||||
float dist;
|
||||
|
@ -61,12 +58,12 @@ R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
|
||||
if (dist > i) // PGM (dist > light->intensity)
|
||||
{
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
R_MarkLights (light, bit, node->children[0], r_dlightframecount);
|
||||
return;
|
||||
}
|
||||
if (dist < -i) // PGM (dist < -light->intensity)
|
||||
{
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
R_MarkLights (light, bit, node->children[1], r_dlightframecount);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -82,8 +79,8 @@ R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
surf->dlightbits |= bit;
|
||||
}
|
||||
|
||||
R_MarkLights (light, bit, node->children[0]);
|
||||
R_MarkLights (light, bit, node->children[1]);
|
||||
R_MarkLights (light, bit, node->children[0], r_dlightframecount);
|
||||
R_MarkLights (light, bit, node->children[1], r_dlightframecount);
|
||||
}
|
||||
|
||||
|
||||
|
@ -92,16 +89,17 @@ R_MarkLights (dlight_t *light, int bit, mnode_t *node)
|
|||
R_PushDlights
|
||||
=============
|
||||
*/
|
||||
void R_PushDlights (model_t *model)
|
||||
void
|
||||
R_PushDlights (model_t *model)
|
||||
{
|
||||
int i;
|
||||
dlight_t *l;
|
||||
|
||||
r_dlightframecount = r_framecount;
|
||||
for (i=0, l = r_newrefdef.dlights ; i<r_newrefdef.num_dlights ; i++, l++)
|
||||
{
|
||||
R_MarkLights ( l, 1<<i,
|
||||
model->nodes + model->firstnode);
|
||||
model->nodes + model->firstnode,
|
||||
r_framecount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,9 +158,6 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
|
|||
if (r >= 0)
|
||||
return r; // hit something
|
||||
|
||||
if ((back < 0) == side)
|
||||
return -1; // didn't hit anything
|
||||
|
||||
// check for impact on this node
|
||||
VectorCopy (mid, lightspot);
|
||||
|
||||
|
@ -221,7 +216,8 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
|
|||
R_LightPoint
|
||||
===============
|
||||
*/
|
||||
void R_LightPoint (vec3_t p, vec3_t color)
|
||||
void
|
||||
R_LightPoint (vec3_t p, vec3_t color)
|
||||
{
|
||||
vec3_t end;
|
||||
float r;
|
||||
|
@ -281,7 +277,7 @@ R_AddDynamicLights
|
|||
===============
|
||||
*/
|
||||
static void
|
||||
R_AddDynamicLights (void)
|
||||
R_AddDynamicLights (drawsurf_t* drawsurf)
|
||||
{
|
||||
msurface_t *surf;
|
||||
int lnum;
|
||||
|
@ -295,7 +291,7 @@ R_AddDynamicLights (void)
|
|||
dlight_t *dl;
|
||||
int negativeLight; //PGM
|
||||
|
||||
surf = r_drawsurf.surf;
|
||||
surf = drawsurf->surf;
|
||||
smax = (surf->extents[0]>>4)+1;
|
||||
tmax = (surf->extents[1]>>4)+1;
|
||||
tex = surf->texinfo;
|
||||
|
@ -382,14 +378,15 @@ R_BuildLightMap
|
|||
Combine and scale multiple lightmaps into the 8.8 format in blocklights
|
||||
===============
|
||||
*/
|
||||
void R_BuildLightMap (void)
|
||||
void
|
||||
R_BuildLightMap (drawsurf_t* drawsurf)
|
||||
{
|
||||
int smax, tmax;
|
||||
int i, size;
|
||||
byte *lightmap;
|
||||
msurface_t *surf;
|
||||
|
||||
surf = r_drawsurf.surf;
|
||||
surf = drawsurf->surf;
|
||||
|
||||
smax = (surf->extents[0]>>4)+1;
|
||||
tmax = (surf->extents[1]>>4)+1;
|
||||
|
@ -418,7 +415,7 @@ void R_BuildLightMap (void)
|
|||
{
|
||||
unsigned scale;
|
||||
|
||||
scale = r_drawsurf.lightadj[maps]; // 8.8 fraction
|
||||
scale = drawsurf->lightadj[maps]; // 8.8 fraction
|
||||
for (i=0 ; i<size ; i++)
|
||||
blocklights[i] += lightmap[i] * scale;
|
||||
lightmap += size; // skip to next lightmap
|
||||
|
@ -427,7 +424,7 @@ void R_BuildLightMap (void)
|
|||
|
||||
// add all the dynamic lights
|
||||
if (surf->dlightframe == r_framecount)
|
||||
R_AddDynamicLights ();
|
||||
R_AddDynamicLights (drawsurf);
|
||||
|
||||
// bound, invert, and shift
|
||||
for (i=0 ; i<size ; i++)
|
||||
|
|
|
@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
*/
|
||||
|
||||
// r_main.c
|
||||
// sw_main.c
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef SDL2
|
||||
|
@ -31,6 +31,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "header/local.h"
|
||||
|
||||
#define NUMSTACKEDGES 2048
|
||||
#define NUMSTACKSURFACES 1024
|
||||
#define MAXALIASVERTS 2048
|
||||
|
||||
viddef_t vid;
|
||||
pixel_t *vid_buffer = NULL;
|
||||
espan_t *vid_polygon_spans = NULL;
|
||||
|
@ -53,22 +57,36 @@ model_t *r_worldmodel;
|
|||
|
||||
pixel_t *r_warpbuffer;
|
||||
|
||||
typedef struct swstate_s
|
||||
{
|
||||
qboolean fullscreen;
|
||||
int prev_mode; // last valid SW mode
|
||||
|
||||
unsigned char gammatable[256];
|
||||
unsigned char currentpalette[1024];
|
||||
|
||||
// SDL colors
|
||||
Uint32 palette_colors[256];
|
||||
|
||||
} swstate_t;
|
||||
|
||||
static swstate_t sw_state;
|
||||
|
||||
void *colormap;
|
||||
float r_time1;
|
||||
int r_numallocatededges;
|
||||
float r_aliasuvscale = 1.0;
|
||||
int r_outofsurfaces;
|
||||
int r_outofedges;
|
||||
void *colormap;
|
||||
float r_time1;
|
||||
int r_numallocatededges;
|
||||
int r_numallocatedverts;
|
||||
float r_aliasuvscale = 1.0;
|
||||
int r_outofsurfaces;
|
||||
int r_outofedges;
|
||||
int r_outofverts;
|
||||
|
||||
qboolean r_dowarp;
|
||||
|
||||
mvertex_t *r_pcurrentvertbase;
|
||||
|
||||
int c_surf;
|
||||
static int r_maxsurfsseen, r_maxedgesseen, r_cnumsurfs;
|
||||
static qboolean r_surfsonstack;
|
||||
int c_surf;
|
||||
static int r_cnumsurfs;
|
||||
int r_clipflags;
|
||||
|
||||
//
|
||||
|
@ -149,7 +167,7 @@ static cvar_t *r_lockpvs;
|
|||
|
||||
#define STRINGER(x) "x"
|
||||
|
||||
// r_vars.c
|
||||
// sw_vars.c
|
||||
|
||||
// all global and static refresh variables are collected in a contiguous block
|
||||
// to avoid cache conflicts.
|
||||
|
@ -188,6 +206,8 @@ unsigned int d_zwidth;
|
|||
|
||||
qboolean insubmodel;
|
||||
|
||||
static qboolean sdl_palette_outdated;
|
||||
|
||||
static struct texture_buffer {
|
||||
image_t image;
|
||||
byte buffer[1024];
|
||||
|
@ -302,7 +322,7 @@ R_Register (void)
|
|||
|
||||
r_mode->modified = true; // force us to do mode specific stuff later
|
||||
vid_gamma->modified = true; // force us to rebuild the gamma table later
|
||||
sw_overbrightbits->modified = true; // force us to rebuild pallete later
|
||||
sw_overbrightbits->modified = true; // force us to rebuild palette later
|
||||
|
||||
//PGM
|
||||
r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", 0);
|
||||
|
@ -397,51 +417,123 @@ RE_Shutdown (void)
|
|||
R_NewMap
|
||||
===============
|
||||
*/
|
||||
void R_NewMap (void)
|
||||
void
|
||||
R_NewMap (void)
|
||||
{
|
||||
r_viewcluster = -1;
|
||||
}
|
||||
|
||||
r_cnumsurfs = sw_maxsurfs->value;
|
||||
static surf_t *lsurfs;
|
||||
|
||||
if (r_cnumsurfs <= MINSURFACES)
|
||||
r_cnumsurfs = MINSURFACES;
|
||||
|
||||
if (r_cnumsurfs > NUMSTACKSURFACES)
|
||||
/*
|
||||
===============
|
||||
R_ReallocateMapBuffers
|
||||
===============
|
||||
*/
|
||||
static void
|
||||
R_ReallocateMapBuffers (void)
|
||||
{
|
||||
if (!r_cnumsurfs || r_outofsurfaces)
|
||||
{
|
||||
surfaces = malloc (r_cnumsurfs * sizeof(surf_t));
|
||||
if (!surfaces)
|
||||
if(lsurfs)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "R_NewMap: Couldn't malloc %d bytes\n", (int)(r_cnumsurfs * sizeof(surf_t)));
|
||||
return;
|
||||
free(lsurfs);
|
||||
}
|
||||
|
||||
surface_p = surfaces;
|
||||
if (r_outofsurfaces)
|
||||
{
|
||||
//R_Printf(PRINT_ALL, "%s: not enough %d(+%d) surfaces\n",
|
||||
// __func__, r_cnumsurfs, r_outofsurfaces);
|
||||
r_cnumsurfs *= 2;
|
||||
}
|
||||
|
||||
if (r_cnumsurfs < NUMSTACKSURFACES)
|
||||
r_cnumsurfs = NUMSTACKSURFACES;
|
||||
|
||||
if (r_cnumsurfs < sw_maxsurfs->value)
|
||||
r_cnumsurfs = sw_maxsurfs->value;
|
||||
|
||||
lsurfs = malloc (r_cnumsurfs * sizeof(surf_t));
|
||||
if (!lsurfs)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Couldn't malloc %d bytes\n",
|
||||
__func__, (int)(r_cnumsurfs * sizeof(surf_t)));
|
||||
return;
|
||||
}
|
||||
|
||||
surfaces = lsurfs;
|
||||
// set limits
|
||||
surf_max = &surfaces[r_cnumsurfs];
|
||||
r_surfsonstack = false;
|
||||
surface_p = lsurfs;
|
||||
// surface 0 doesn't really exist; it's just a dummy because index 0
|
||||
// is used to indicate no edge attached to surface
|
||||
surfaces--;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_surfsonstack = true;
|
||||
|
||||
R_Printf(PRINT_ALL, "Allocated %d surfaces\n", r_cnumsurfs);
|
||||
}
|
||||
|
||||
r_maxedgesseen = 0;
|
||||
r_maxsurfsseen = 0;
|
||||
|
||||
r_numallocatededges = sw_maxedges->value;
|
||||
|
||||
if (r_numallocatededges < MINEDGES)
|
||||
r_numallocatededges = MINEDGES;
|
||||
|
||||
if (r_numallocatededges <= NUMSTACKEDGES)
|
||||
if (!r_numallocatededges || r_outofedges)
|
||||
{
|
||||
auxedges = NULL;
|
||||
if (!r_edges)
|
||||
{
|
||||
free(r_edges);
|
||||
}
|
||||
|
||||
if (r_outofedges)
|
||||
{
|
||||
//R_Printf(PRINT_ALL, "%s: not enough %d(+%d) edges\n",
|
||||
// __func__, r_numallocatededges, r_outofedges * 2 / 3);
|
||||
r_numallocatededges *= 2;
|
||||
}
|
||||
|
||||
if (r_numallocatededges < NUMSTACKEDGES)
|
||||
r_numallocatededges = NUMSTACKEDGES;
|
||||
|
||||
if (r_numallocatededges < sw_maxedges->value)
|
||||
r_numallocatededges = sw_maxedges->value;
|
||||
|
||||
r_edges = malloc (r_numallocatededges * sizeof(edge_t));
|
||||
if (!r_edges)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Couldn't malloc %d bytes\n",
|
||||
__func__, (int)(r_numallocatededges * sizeof(edge_t)));
|
||||
return;
|
||||
}
|
||||
|
||||
// set limits
|
||||
edge_max = &r_edges[r_numallocatededges];
|
||||
edge_p = r_edges;
|
||||
|
||||
R_Printf(PRINT_ALL, "Allocated %d edges\n", r_numallocatededges);
|
||||
}
|
||||
else
|
||||
|
||||
if (!r_numallocatedverts || r_outofverts)
|
||||
{
|
||||
auxedges = malloc (r_numallocatededges * sizeof(edge_t));
|
||||
if (finalverts)
|
||||
{
|
||||
free(finalverts);
|
||||
}
|
||||
|
||||
if (r_outofverts)
|
||||
{
|
||||
//R_Printf(PRINT_ALL, "%s: not enough %d(+%d) finalverts\n",
|
||||
// __func__, r_numallocatedverts, r_outofverts);
|
||||
r_numallocatedverts *= 2;
|
||||
}
|
||||
|
||||
if (r_numallocatedverts < MAXALIASVERTS)
|
||||
r_numallocatedverts = MAXALIASVERTS;
|
||||
|
||||
finalverts = malloc(r_numallocatedverts * sizeof(finalvert_t));
|
||||
if (!finalverts)
|
||||
{
|
||||
R_Printf(PRINT_ALL, "%s: Couldn't malloc %d bytes\n",
|
||||
__func__, (int)(r_numallocatedverts * sizeof(finalvert_t)));
|
||||
return;
|
||||
}
|
||||
finalverts_max = &finalverts[r_numallocatedverts];
|
||||
|
||||
R_Printf(PRINT_ALL, "Allocated %d verts\n", r_numallocatedverts);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -796,7 +888,6 @@ R_DrawBEntitiesOnList (void)
|
|||
|
||||
VectorCopy (modelorg, oldorigin);
|
||||
insubmodel = true;
|
||||
r_dlightframecount = r_framecount;
|
||||
|
||||
for (i=0 ; i<r_newrefdef.num_entities ; i++)
|
||||
{
|
||||
|
@ -862,9 +953,6 @@ R_DrawBEntitiesOnList (void)
|
|||
insubmodel = false;
|
||||
}
|
||||
|
||||
static edge_t *ledges;
|
||||
static surf_t *lsurfs;
|
||||
|
||||
/*
|
||||
================
|
||||
R_EdgeDrawing
|
||||
|
@ -878,26 +966,11 @@ R_EdgeDrawing (void)
|
|||
if ( r_newrefdef.rdflags & RDF_NOWORLDMODEL )
|
||||
return;
|
||||
|
||||
if (auxedges)
|
||||
{
|
||||
r_edges = auxedges;
|
||||
}
|
||||
else
|
||||
{
|
||||
r_edges = ledges;
|
||||
}
|
||||
|
||||
if (r_surfsonstack)
|
||||
{
|
||||
surfaces = lsurfs;
|
||||
surf_max = &surfaces[r_cnumsurfs];
|
||||
// surface 0 doesn't really exist; it's just a dummy because index 0
|
||||
// is used to indicate no edge attached to surface
|
||||
surfaces--;
|
||||
}
|
||||
|
||||
// Set function pointer pdrawfunc used later in this function
|
||||
R_BeginEdgeFrame ();
|
||||
edge_p = r_edges;
|
||||
surface_p = &surfaces[2]; // background is surface 1,
|
||||
// surface 0 is a dummy
|
||||
|
||||
if (r_dspeeds->value)
|
||||
{
|
||||
|
@ -924,7 +997,7 @@ R_EdgeDrawing (void)
|
|||
|
||||
// Use the Global Edge Table to maintin the Active Edge Table: Draw the world as scanlines
|
||||
// Write the Z-Buffer (but no read)
|
||||
R_ScanEdges ();
|
||||
R_ScanEdges (surface_p);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -1092,6 +1165,8 @@ RE_RenderFrame (refdef_t *fd)
|
|||
|
||||
if (sw_reportedgeout->value && r_outofedges)
|
||||
R_Printf(PRINT_ALL,"Short roughly %d edges\n", r_outofedges * 2 / 3);
|
||||
|
||||
R_ReallocateMapBuffers();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1205,6 +1280,8 @@ R_GammaCorrectAndSetPalette( const unsigned char *palette )
|
|||
sw_state.currentpalette[i*4+1] = sw_state.gammatable[palette[i*4+1]];
|
||||
sw_state.currentpalette[i*4+2] = sw_state.gammatable[palette[i*4+2]];
|
||||
}
|
||||
|
||||
sdl_palette_outdated = true;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1214,7 +1291,6 @@ static void
|
|||
RE_SetPalette(const unsigned char *palette)
|
||||
{
|
||||
byte palette32[1024];
|
||||
int i;
|
||||
|
||||
// clear screen to black to avoid any palette flash
|
||||
memset(vid_buffer, 0, vid.height * vid.width * sizeof(pixel_t));
|
||||
|
@ -1224,6 +1300,8 @@ RE_SetPalette(const unsigned char *palette)
|
|||
|
||||
if (palette)
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < 256; i++ )
|
||||
{
|
||||
palette32[i*4+0] = palette[i*3+0];
|
||||
|
@ -1651,7 +1729,8 @@ R_InitContext(void* win)
|
|||
return true;
|
||||
}
|
||||
|
||||
static qboolean CreateSDLWindow(int flags, int w, int h)
|
||||
static qboolean
|
||||
CreateSDLWindow(int flags, int w, int h)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
|
@ -1675,9 +1754,9 @@ static qboolean CreateSDLWindow(int flags, int w, int h)
|
|||
surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask);
|
||||
|
||||
texture = SDL_CreateTexture(renderer,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
w, h);
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
w, h);
|
||||
return window != NULL;
|
||||
#else
|
||||
window = SDL_SetVideoMode(w, h, 0, flags);
|
||||
|
@ -1686,7 +1765,8 @@ static qboolean CreateSDLWindow(int flags, int w, int h)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void SWimp_DestroyRender(void)
|
||||
static void
|
||||
SWimp_DestroyRender(void)
|
||||
{
|
||||
if (vid_buffer)
|
||||
{
|
||||
|
@ -1760,11 +1840,11 @@ static void SWimp_DestroyRender(void)
|
|||
}
|
||||
finalverts = NULL;
|
||||
|
||||
if(ledges)
|
||||
if(r_edges)
|
||||
{
|
||||
free(ledges);
|
||||
free(r_edges);
|
||||
}
|
||||
ledges = NULL;
|
||||
r_edges = NULL;
|
||||
|
||||
if(lsurfs)
|
||||
{
|
||||
|
@ -1926,9 +2006,18 @@ SWimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
|
|||
warp_column = malloc((vid.width+AMP2*2) * sizeof(int));
|
||||
|
||||
edge_basespans = malloc((vid.width*2) * sizeof(espan_t));
|
||||
finalverts = malloc((MAXALIASVERTS + 3) * sizeof(finalvert_t));
|
||||
ledges = malloc((NUMSTACKEDGES + 1) * sizeof(edge_t));
|
||||
lsurfs = malloc((NUMSTACKSURFACES + 1) * sizeof(surf_t));
|
||||
|
||||
// count of "out of items"
|
||||
r_outofsurfaces = r_outofedges = r_outofverts = 0;
|
||||
// pointers to allocated buffers
|
||||
finalverts = NULL;
|
||||
r_edges = NULL;
|
||||
lsurfs = NULL;
|
||||
// curently allocated items
|
||||
r_cnumsurfs = r_numallocatededges = r_numallocatedverts = 0;
|
||||
|
||||
R_ReallocateMapBuffers();
|
||||
|
||||
r_warpbuffer = malloc(vid.height * vid.width * sizeof(pixel_t));
|
||||
|
||||
if ((vid.width >= 2048) && (sizeof(shift20_t) == 4)) // 2k+ resolution and 32 == shift20_t
|
||||
|
@ -1945,12 +2034,85 @@ SWimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
|
|||
vid_polygon_spans = malloc(sizeof(espan_t) * (vid.height + 1));
|
||||
|
||||
memset(sw_state.currentpalette, 0, sizeof(sw_state.currentpalette));
|
||||
memset(sw_state.palette_colors, 0, sizeof(sw_state.palette_colors));
|
||||
|
||||
sdl_palette_outdated = true;
|
||||
X11_active = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
RE_SDLPaletteConvert (void)
|
||||
{
|
||||
int i;
|
||||
const unsigned char *palette = sw_state.currentpalette;
|
||||
Uint32 *sdl_palette = sw_state.palette_colors;
|
||||
|
||||
if (!sdl_palette_outdated)
|
||||
return;
|
||||
|
||||
sdl_palette_outdated = false;
|
||||
for ( i = 0; i < 256; i++ )
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
if (surface)
|
||||
sdl_palette[i] = SDL_MapRGB(surface->format,
|
||||
palette[i * 4 + 0], // red
|
||||
palette[i * 4 + 1], // green
|
||||
palette[i * 4 + 2] //blue
|
||||
);
|
||||
#else
|
||||
if (window)
|
||||
sdl_palette[i] = SDL_MapRGB(window->format,
|
||||
palette[i * 4 + 0], // red
|
||||
palette[i * 4 + 1], // green
|
||||
palette[i * 4 + 2] //blue
|
||||
);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
RE_CopyFrame (Uint32 * pixels, int pitch)
|
||||
{
|
||||
RE_SDLPaletteConvert();
|
||||
|
||||
// no gaps between images rows
|
||||
if (pitch == vid.width)
|
||||
{
|
||||
int y,x, buffer_pos;
|
||||
|
||||
buffer_pos = 0;
|
||||
for (y=0; y < vid.height; y++)
|
||||
{
|
||||
for (x=0; x < vid.width; x ++)
|
||||
{
|
||||
pixels[x] = sw_state.palette_colors[vid_buffer[buffer_pos + x]];
|
||||
}
|
||||
pixels += pitch;
|
||||
buffer_pos += vid.width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const Uint32 *max_pixels;
|
||||
Uint32 *pixels_pos;
|
||||
pixel_t *buffer_pos;
|
||||
|
||||
max_pixels = pixels + vid.height * vid.width;
|
||||
buffer_pos = vid_buffer;
|
||||
|
||||
for (pixels_pos = pixels; pixels_pos < max_pixels; pixels_pos++)
|
||||
{
|
||||
*pixels_pos = sw_state.palette_colors[*buffer_pos];
|
||||
buffer_pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** RE_EndFrame
|
||||
**
|
||||
|
@ -1962,45 +2124,17 @@ SWimp_InitGraphics(int fullscreen, int *pwidth, int *pheight)
|
|||
static void
|
||||
RE_EndFrame (void)
|
||||
{
|
||||
int y,x, i;
|
||||
const unsigned char *pallete = sw_state.currentpalette;
|
||||
Uint32 pallete_colors[256];
|
||||
|
||||
for(i=0; i < 256; i++)
|
||||
{
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
pallete_colors[i] = SDL_MapRGB(surface->format,
|
||||
pallete[i * 4 + 0], // red
|
||||
pallete[i * 4 + 1], // green
|
||||
pallete[i * 4 + 2] //blue
|
||||
);
|
||||
#else
|
||||
pallete_colors[i] = SDL_MapRGB(window->format,
|
||||
pallete[i * 4 + 0], // red
|
||||
pallete[i * 4 + 1], // green
|
||||
pallete[i * 4 + 2] //blue
|
||||
);
|
||||
#endif
|
||||
}
|
||||
int pitch;
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
Uint32 * pixels = (Uint32 *)surface->pixels;
|
||||
pitch = surface->pitch / sizeof(Uint32);
|
||||
#else
|
||||
Uint32 * pixels = (Uint32 *)window->pixels;
|
||||
pitch = window->pitch / sizeof(Uint32);
|
||||
#endif
|
||||
for (y=0; y < vid.height; y++)
|
||||
{
|
||||
for (x=0; x < vid.width; x ++)
|
||||
{
|
||||
int buffer_pos = y * vid.width + x;
|
||||
Uint32 color = pallete_colors[vid_buffer[buffer_pos]];
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
pixels[y * surface->pitch / sizeof(Uint32) + x] = color;
|
||||
#else
|
||||
pixels[y * window->pitch / sizeof(Uint32) + x] = color;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
RE_CopyFrame (pixels, pitch);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
||||
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
|
||||
|
@ -2062,7 +2196,8 @@ SWimp_Shutdown( void )
|
|||
}
|
||||
|
||||
// this is only here so the functions in q_shared.c and q_shwin.c can link
|
||||
void Sys_Error (char *error, ...)
|
||||
void
|
||||
Sys_Error (char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char text[1024];
|
||||
|
@ -2074,7 +2209,8 @@ void Sys_Error (char *error, ...)
|
|||
ri.Sys_Error (ERR_FATAL, "%s", text);
|
||||
}
|
||||
|
||||
void Com_Printf (char *fmt, ...)
|
||||
void
|
||||
Com_Printf (char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char text[1024];
|
||||
|
@ -2104,7 +2240,7 @@ R_ScreenShot_f(void)
|
|||
{
|
||||
int x, y;
|
||||
byte *buffer = malloc(vid.width * vid.height * 3);
|
||||
const unsigned char *pallete = sw_state.currentpalette;
|
||||
const unsigned char *palette = sw_state.currentpalette;
|
||||
|
||||
if (!buffer)
|
||||
{
|
||||
|
@ -2116,9 +2252,9 @@ R_ScreenShot_f(void)
|
|||
{
|
||||
for (y=0; y < vid.height; y ++) {
|
||||
int buffer_pos = y * vid.width + x;
|
||||
buffer[buffer_pos * 3 + 0] = pallete[vid_buffer[buffer_pos] * 4 + 0]; // red
|
||||
buffer[buffer_pos * 3 + 1] = pallete[vid_buffer[buffer_pos] * 4 + 1]; // green
|
||||
buffer[buffer_pos * 3 + 2] = pallete[vid_buffer[buffer_pos] * 4 + 2]; // blue
|
||||
buffer[buffer_pos * 3 + 0] = palette[vid_buffer[buffer_pos] * 4 + 0]; // red
|
||||
buffer[buffer_pos * 3 + 1] = palette[vid_buffer[buffer_pos] * 4 + 1]; // green
|
||||
buffer[buffer_pos * 3 + 2] = palette[vid_buffer[buffer_pos] * 4 + 2]; // blue
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ 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
|
||||
// sw_misc.c
|
||||
#ifdef SDL2
|
||||
#include <SDL2/SDL.h>
|
||||
#else // SDL1.2
|
||||
|
@ -87,7 +87,8 @@ D_ViewChanged (void)
|
|||
R_PrintTimes
|
||||
=============
|
||||
*/
|
||||
void R_PrintTimes (void)
|
||||
void
|
||||
R_PrintTimes (void)
|
||||
{
|
||||
int r_time2;
|
||||
int ms;
|
||||
|
@ -107,7 +108,8 @@ void R_PrintTimes (void)
|
|||
R_PrintDSpeeds
|
||||
=============
|
||||
*/
|
||||
void R_PrintDSpeeds (void)
|
||||
void
|
||||
R_PrintDSpeeds (void)
|
||||
{
|
||||
int ms, dp_time, r_time2, rw_time, db_time, se_time, de_time, da_time;
|
||||
|
||||
|
@ -131,7 +133,8 @@ void R_PrintDSpeeds (void)
|
|||
R_PrintAliasStats
|
||||
=============
|
||||
*/
|
||||
void R_PrintAliasStats (void)
|
||||
void
|
||||
R_PrintAliasStats (void)
|
||||
{
|
||||
R_Printf(PRINT_ALL,"%3i polygon model drawn\n", r_amodels_drawn);
|
||||
}
|
||||
|
@ -143,7 +146,8 @@ void R_PrintAliasStats (void)
|
|||
R_TransformFrustum
|
||||
===================
|
||||
*/
|
||||
void R_TransformFrustum (void)
|
||||
void
|
||||
R_TransformFrustum (void)
|
||||
{
|
||||
int i;
|
||||
vec3_t v, v2;
|
||||
|
@ -170,7 +174,8 @@ void R_TransformFrustum (void)
|
|||
TransformVector
|
||||
================
|
||||
*/
|
||||
void TransformVector (vec3_t in, vec3_t out)
|
||||
void
|
||||
TransformVector (vec3_t in, vec3_t out)
|
||||
{
|
||||
out[0] = DotProduct(in,vright);
|
||||
out[1] = DotProduct(in,vup);
|
||||
|
@ -316,7 +321,8 @@ R_ViewChanged (vrect_t *vr)
|
|||
R_SetupFrame
|
||||
===============
|
||||
*/
|
||||
void R_SetupFrame (void)
|
||||
void
|
||||
R_SetupFrame (void)
|
||||
{
|
||||
int i;
|
||||
vrect_t vrect;
|
||||
|
@ -389,6 +395,7 @@ void R_SetupFrame (void)
|
|||
r_drawnpolycount = 0;
|
||||
r_amodels_drawn = 0;
|
||||
r_outofsurfaces = 0;
|
||||
r_outofverts = 0;
|
||||
r_outofedges = 0;
|
||||
|
||||
// d_setup
|
||||
|
|
|
@ -50,7 +50,8 @@ static int modfilelen;
|
|||
Mod_Modellist_f
|
||||
================
|
||||
*/
|
||||
void Mod_Modellist_f (void)
|
||||
void
|
||||
Mod_Modellist_f (void)
|
||||
{
|
||||
int i;
|
||||
model_t *mod;
|
||||
|
@ -73,7 +74,8 @@ void Mod_Modellist_f (void)
|
|||
Mod_Init
|
||||
===============
|
||||
*/
|
||||
void Mod_Init (void)
|
||||
void
|
||||
Mod_Init (void)
|
||||
{
|
||||
memset (mod_novis, 0xff, sizeof(mod_novis));
|
||||
}
|
||||
|
@ -184,7 +186,8 @@ Mod_ForName (char *name, qboolean crash)
|
|||
Mod_PointInLeaf
|
||||
===============
|
||||
*/
|
||||
mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
|
||||
mleaf_t *
|
||||
Mod_PointInLeaf (vec3_t p, model_t *model)
|
||||
{
|
||||
mnode_t *node;
|
||||
|
||||
|
@ -209,64 +212,19 @@ mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
Mod_DecompressVis
|
||||
===================
|
||||
*/
|
||||
static byte *
|
||||
Mod_DecompressVis (byte *in, model_t *model)
|
||||
{
|
||||
static byte decompressed[MAX_MAP_LEAFS/8];
|
||||
int c;
|
||||
byte *out;
|
||||
int row;
|
||||
|
||||
row = (model->vis->numclusters+7)>>3;
|
||||
out = decompressed;
|
||||
|
||||
if (!in)
|
||||
{
|
||||
// no vis info, so make all visible
|
||||
while (row)
|
||||
{
|
||||
*out++ = 0xff;
|
||||
row--;
|
||||
}
|
||||
return decompressed;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (*in)
|
||||
{
|
||||
*out++ = *in++;
|
||||
continue;
|
||||
}
|
||||
|
||||
c = in[1];
|
||||
in += 2;
|
||||
while (c)
|
||||
{
|
||||
*out++ = 0;
|
||||
c--;
|
||||
}
|
||||
} while (out - decompressed < row);
|
||||
|
||||
return decompressed;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
Mod_ClusterPVS
|
||||
==============
|
||||
*/
|
||||
byte *Mod_ClusterPVS (int cluster, model_t *model)
|
||||
byte *
|
||||
Mod_ClusterPVS (int cluster, model_t *model)
|
||||
{
|
||||
if (cluster == -1 || !model->vis)
|
||||
return mod_novis;
|
||||
return Mod_DecompressVis ( (byte *)model->vis + model->vis->bitofs[cluster][DVIS_PVS],
|
||||
model);
|
||||
return Mod_DecompressVis ( (byte *)model->vis +
|
||||
model->vis->bitofs[cluster][DVIS_PVS],
|
||||
(model->vis->numclusters+7)>>3);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -318,7 +276,8 @@ static int r_leaftovis[MAX_MAP_LEAFS];
|
|||
static int r_vistoleaf[MAX_MAP_LEAFS];
|
||||
static int r_numvisleafs;
|
||||
|
||||
void R_NumberLeafs (mnode_t *node)
|
||||
void
|
||||
R_NumberLeafs (mnode_t *node)
|
||||
{
|
||||
if (node->contents != -1)
|
||||
{
|
||||
|
@ -1154,7 +1113,8 @@ RE_BeginRegistration
|
|||
Specifies the model that will be used as the world
|
||||
=====================
|
||||
*/
|
||||
void RE_BeginRegistration (char *model)
|
||||
void
|
||||
RE_BeginRegistration (char *model)
|
||||
{
|
||||
char fullname[MAX_QPATH];
|
||||
cvar_t *flushmap;
|
||||
|
@ -1180,7 +1140,8 @@ RE_RegisterModel
|
|||
|
||||
=====================
|
||||
*/
|
||||
struct model_s *RE_RegisterModel (char *name)
|
||||
struct model_s *
|
||||
RE_RegisterModel (char *name)
|
||||
{
|
||||
model_t *mod;
|
||||
|
||||
|
@ -1226,7 +1187,8 @@ RE_EndRegistration
|
|||
|
||||
=====================
|
||||
*/
|
||||
void RE_EndRegistration (void)
|
||||
void
|
||||
RE_EndRegistration (void)
|
||||
{
|
||||
int i;
|
||||
model_t *mod;
|
||||
|
@ -1253,7 +1215,8 @@ void RE_EndRegistration (void)
|
|||
Mod_Free
|
||||
================
|
||||
*/
|
||||
void Mod_Free (model_t *mod)
|
||||
void
|
||||
Mod_Free (model_t *mod)
|
||||
{
|
||||
Hunk_Free (mod->extradata);
|
||||
memset (mod, 0, sizeof(*mod));
|
||||
|
@ -1264,7 +1227,8 @@ void Mod_Free (model_t *mod)
|
|||
Mod_FreeAll
|
||||
================
|
||||
*/
|
||||
void Mod_FreeAll (void)
|
||||
void
|
||||
Mod_FreeAll (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -26,13 +26,6 @@ extern cvar_t *sw_custom_particles;
|
|||
#define PARTICLE_66 1
|
||||
#define PARTICLE_OPAQUE 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
particle_t *particle;
|
||||
int level;
|
||||
int color;
|
||||
} partparms_t;
|
||||
|
||||
/*
|
||||
** R_DrawParticle
|
||||
**
|
||||
|
@ -46,10 +39,9 @@ typedef struct
|
|||
** function pointer route. This exacts some overhead, but
|
||||
** it pays off in clean and easy to understand code.
|
||||
*/
|
||||
static void R_DrawParticle(partparms_t *partparms)
|
||||
static void
|
||||
R_DrawParticle(particle_t *pparticle, int level)
|
||||
{
|
||||
particle_t *pparticle = partparms->particle;
|
||||
int level = partparms->level;
|
||||
vec3_t local, transformed;
|
||||
float zi;
|
||||
byte *pdest;
|
||||
|
@ -226,10 +218,9 @@ static void R_DrawParticle(partparms_t *partparms)
|
|||
** if we're using the asm path, it simply assigns a function pointer
|
||||
** and goes.
|
||||
*/
|
||||
void R_DrawParticles (void)
|
||||
void
|
||||
R_DrawParticles (void)
|
||||
{
|
||||
partparms_t partparms;
|
||||
|
||||
particle_t *p;
|
||||
int i;
|
||||
|
||||
|
@ -239,17 +230,15 @@ void R_DrawParticles (void)
|
|||
|
||||
for (p=r_newrefdef.particles, i=0 ; i<r_newrefdef.num_particles ; i++,p++)
|
||||
{
|
||||
int level;
|
||||
|
||||
if ( p->alpha > 0.66 )
|
||||
partparms.level = PARTICLE_OPAQUE;
|
||||
level = PARTICLE_OPAQUE;
|
||||
else if ( p->alpha > 0.33 )
|
||||
partparms.level = PARTICLE_66;
|
||||
level = PARTICLE_66;
|
||||
else
|
||||
partparms.level = PARTICLE_33;
|
||||
level = PARTICLE_33;
|
||||
|
||||
partparms.particle = p;
|
||||
partparms.color = p->color;
|
||||
|
||||
R_DrawParticle(&partparms);
|
||||
R_DrawParticle(p, level);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -595,7 +595,6 @@ R_ClipPolyFace (int nump, clipplane_t *pclipplane)
|
|||
static void
|
||||
R_PolygonDrawSpans(espan_t *pspan, int iswater )
|
||||
{
|
||||
int count;
|
||||
int snext, tnext;
|
||||
float sdivz, tdivz, zi, z, du, dv, spancountminus1;
|
||||
float sdivzspanletstepu, tdivzspanletstepu, zispanletstepu;
|
||||
|
@ -621,6 +620,8 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
|
|||
|
||||
do
|
||||
{
|
||||
int count;
|
||||
|
||||
s_spanletvars.pdest = d_viewbuffer + (r_screenwidth * pspan->v) + pspan->u;
|
||||
s_spanletvars.pz = d_pzbuffer + (d_zwidth * pspan->v) + pspan->u;
|
||||
s_spanletvars.u = pspan->u;
|
||||
|
@ -910,7 +911,8 @@ R_PolygonScanRightEdge(espan_t *s_polygon_spans)
|
|||
** R_ClipAndDrawPoly
|
||||
*/
|
||||
// PGM - isturbulent was qboolean. changed to int to allow passing more flags
|
||||
void R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
|
||||
void
|
||||
R_ClipAndDrawPoly ( float alpha, int isturbulent, qboolean textured )
|
||||
{
|
||||
vec_t *pv;
|
||||
int i, nump;
|
||||
|
@ -1150,7 +1152,8 @@ R_PolygonCalculateGradients (void)
|
|||
** This should NOT be called externally since it doesn't do clipping!
|
||||
*/
|
||||
// PGM - iswater was qboolean. changed to support passing more flags
|
||||
static void R_DrawPoly(int iswater)
|
||||
static void
|
||||
R_DrawPoly(int iswater)
|
||||
{
|
||||
int i, nump;
|
||||
float ymin, ymax;
|
||||
|
@ -1206,7 +1209,8 @@ static void R_DrawPoly(int iswater)
|
|||
/*
|
||||
** R_DrawAlphaSurfaces
|
||||
*/
|
||||
void R_DrawAlphaSurfaces( void )
|
||||
void
|
||||
R_DrawAlphaSurfaces( void )
|
||||
{
|
||||
msurface_t *s = r_alpha_surfaces;
|
||||
|
||||
|
@ -1244,7 +1248,8 @@ void R_DrawAlphaSurfaces( void )
|
|||
/*
|
||||
** R_IMFlatShadedQuad
|
||||
*/
|
||||
void R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha )
|
||||
void
|
||||
R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha )
|
||||
{
|
||||
vec3_t s0, s1;
|
||||
|
||||
|
|
|
@ -110,45 +110,45 @@ static void R_PolysetScanLeftEdge_C(int height);
|
|||
// ======================
|
||||
// PGM
|
||||
// 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
||||
byte irtable[256] = { 79, 78, 77, 76, 75, 74, 73, 72, // black/white
|
||||
71, 70, 69, 68, 67, 66, 65, 64,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // dark taupe
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
static byte irtable[256] = { 79, 78, 77, 76, 75, 74, 73, 72, // black/white
|
||||
71, 70, 69, 68, 67, 66, 65, 64,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // dark taupe
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // slate grey
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
208, 208, 208, 208, 208, 208, 208, 208, // unused?'
|
||||
64, 66, 68, 70, 72, 74, 76, 78, // dark yellow
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // slate grey
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
208, 208, 208, 208, 208, 208, 208, 208, // unused?'
|
||||
64, 66, 68, 70, 72, 74, 76, 78, // dark yellow
|
||||
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // dark red
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // grey/tan
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // dark red
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // grey/tan
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
|
||||
64, 66, 68, 70, 72, 74, 76, 78, // chocolate
|
||||
68, 67, 66, 65, 64, 65, 66, 67, // mauve / teal
|
||||
68, 69, 70, 71, 72, 73, 74, 75,
|
||||
76, 76, 77, 77, 78, 78, 79, 79,
|
||||
64, 66, 68, 70, 72, 74, 76, 78, // chocolate
|
||||
68, 67, 66, 65, 64, 65, 66, 67, // mauve / teal
|
||||
68, 69, 70, 71, 72, 73, 74, 75,
|
||||
76, 76, 77, 77, 78, 78, 79, 79,
|
||||
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // more mauve
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // olive
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // more mauve
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // olive
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // maroon
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // sky blue
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // maroon
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // sky blue
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // olive again
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // nuclear green
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // bright yellow
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // olive again
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // nuclear green
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // bright yellow
|
||||
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // fire colors
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
208, 208, 64, 64, 70, 71, 72, 64, // mishmash1
|
||||
66, 68, 70, 64, 65, 66, 67, 68}; // mishmash2
|
||||
64, 65, 66, 67, 68, 69, 70, 71, // fire colors
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
208, 208, 64, 64, 70, 71, 72, 64, // mishmash1
|
||||
66, 68, 70, 64, 65, 66, 67, 68}; // mishmash2
|
||||
// PGM
|
||||
// ======================
|
||||
|
||||
|
@ -157,7 +157,8 @@ byte irtable[256] = { 79, 78, 77, 76, 75, 74, 73, 72, // black/white
|
|||
R_PolysetUpdateTables
|
||||
================
|
||||
*/
|
||||
void R_PolysetUpdateTables (void)
|
||||
void
|
||||
R_PolysetUpdateTables (void)
|
||||
{
|
||||
byte *s;
|
||||
|
||||
|
@ -179,7 +180,8 @@ void R_PolysetUpdateTables (void)
|
|||
R_DrawTriangle
|
||||
================
|
||||
*/
|
||||
void R_DrawTriangle( void )
|
||||
void
|
||||
R_DrawTriangle( void )
|
||||
{
|
||||
int dv1_ab, dv0_ac;
|
||||
int dv0_ab, dv1_ac;
|
||||
|
@ -239,7 +241,8 @@ void R_DrawTriangle( void )
|
|||
R_PolysetScanLeftEdge_C
|
||||
====================
|
||||
*/
|
||||
static void R_PolysetScanLeftEdge_C(int height)
|
||||
static void
|
||||
R_PolysetScanLeftEdge_C(int height)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -390,7 +393,8 @@ R_PolysetSetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
|
|||
R_PolysetCalcGradients
|
||||
================
|
||||
*/
|
||||
static void R_PolysetCalcGradients (int skinwidth)
|
||||
static void
|
||||
R_PolysetCalcGradients (int skinwidth)
|
||||
{
|
||||
float xstepdenominv, ystepdenominv, t0, t1;
|
||||
float p01_minus_p21, p11_minus_p21, p00_minus_p20, p10_minus_p20;
|
||||
|
@ -449,7 +453,8 @@ static void R_PolysetCalcGradients (int skinwidth)
|
|||
R_PolysetDrawSpans8
|
||||
================
|
||||
*/
|
||||
void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
|
||||
void
|
||||
R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
|
||||
{
|
||||
byte *lpdest;
|
||||
byte *lptex;
|
||||
|
@ -514,7 +519,8 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
|
|||
} while (pspanpackage->count != -999999);
|
||||
}
|
||||
|
||||
void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage)
|
||||
void
|
||||
R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage)
|
||||
{
|
||||
pixel_t *lpdest;
|
||||
int lzi;
|
||||
|
@ -559,7 +565,8 @@ void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage)
|
|||
} while (pspanpackage->count != -999999);
|
||||
}
|
||||
|
||||
void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
|
||||
void
|
||||
R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
|
||||
{
|
||||
pixel_t *lpdest;
|
||||
pixel_t *lptex;
|
||||
|
@ -625,7 +632,8 @@ void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
|
|||
} while (pspanpackage->count != -999999);
|
||||
}
|
||||
|
||||
void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
|
||||
void
|
||||
R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
|
||||
{
|
||||
pixel_t *lpdest;
|
||||
int lzi;
|
||||
|
@ -670,7 +678,8 @@ void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
|
|||
} while (pspanpackage->count != -999999);
|
||||
}
|
||||
|
||||
void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
|
||||
void
|
||||
R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_rast.c
|
||||
// sw_rast.c
|
||||
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
|
@ -37,6 +37,9 @@ clipplane_t view_clipplanes[4];
|
|||
|
||||
medge_t *r_pedge;
|
||||
|
||||
edge_t *r_edges = NULL, *edge_p = NULL, *edge_max = NULL;
|
||||
surf_t *surfaces = NULL, *surface_p = NULL, *surf_max = NULL;
|
||||
|
||||
static qboolean r_leftclipped, r_rightclipped;
|
||||
static qboolean makeleftedge, makerightedge;
|
||||
static qboolean r_nearzionly;
|
||||
|
@ -101,7 +104,8 @@ R_InitSkyBox
|
|||
|
||||
================
|
||||
*/
|
||||
void R_InitSkyBox (void)
|
||||
void
|
||||
R_InitSkyBox (void)
|
||||
{
|
||||
int i;
|
||||
extern model_t *loadmodel;
|
||||
|
@ -510,7 +514,8 @@ R_EmitCachedEdge (void)
|
|||
R_RenderFace
|
||||
================
|
||||
*/
|
||||
void R_RenderFace (msurface_t *fa, int clipflags)
|
||||
void
|
||||
R_RenderFace (msurface_t *fa, int clipflags)
|
||||
{
|
||||
int i;
|
||||
unsigned mask;
|
||||
|
@ -725,7 +730,8 @@ void R_RenderFace (msurface_t *fa, int clipflags)
|
|||
R_RenderBmodelFace
|
||||
================
|
||||
*/
|
||||
void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
|
||||
void
|
||||
R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
|
||||
{
|
||||
int i;
|
||||
unsigned mask;
|
||||
|
|
|
@ -41,7 +41,8 @@ this performs a slight compression of the screen at the same time as
|
|||
the sine warp, to keep the edges from wrapping
|
||||
=============
|
||||
*/
|
||||
void D_WarpScreen (void)
|
||||
void
|
||||
D_WarpScreen (void)
|
||||
{
|
||||
int w, h;
|
||||
int u,v;
|
||||
|
@ -98,7 +99,8 @@ void D_WarpScreen (void)
|
|||
D_DrawTurbulent8Span
|
||||
=============
|
||||
*/
|
||||
static void D_DrawTurbulent8Span (void)
|
||||
static void
|
||||
D_DrawTurbulent8Span (void)
|
||||
{
|
||||
do
|
||||
{
|
||||
|
@ -116,7 +118,8 @@ static void D_DrawTurbulent8Span (void)
|
|||
Turbulent8
|
||||
=============
|
||||
*/
|
||||
void Turbulent8 (espan_t *pspan)
|
||||
void
|
||||
Turbulent8 (espan_t *pspan)
|
||||
{
|
||||
int snext, tnext;
|
||||
float spancountminus1;
|
||||
|
@ -252,7 +255,8 @@ NonTurbulent8 - this is for drawing scrolling textures. they're warping water te
|
|||
but the turbulence is automatically 0.
|
||||
=============
|
||||
*/
|
||||
void NonTurbulent8 (espan_t *pspan)
|
||||
void
|
||||
NonTurbulent8 (espan_t *pspan)
|
||||
{
|
||||
int snext, tnext;
|
||||
float spancountminus1;
|
||||
|
@ -402,7 +406,8 @@ D_DrawSpans16
|
|||
FIXME: actually make this subdivide by 16 instead of 8!!!
|
||||
=============
|
||||
*/
|
||||
void D_DrawSpans16 (espan_t *pspan)
|
||||
void
|
||||
D_DrawSpans16 (espan_t *pspan)
|
||||
{
|
||||
int spancount;
|
||||
unsigned char *pbase;
|
||||
|
@ -569,7 +574,8 @@ void D_DrawSpans16 (espan_t *pspan)
|
|||
D_DrawZSpans
|
||||
=============
|
||||
*/
|
||||
void D_DrawZSpans (espan_t *pspan)
|
||||
void
|
||||
D_DrawZSpans (espan_t *pspan)
|
||||
{
|
||||
int izistep;
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_sprite.c
|
||||
// sw_sprite.c
|
||||
#include "header/local.h"
|
||||
|
||||
extern polydesc_t r_polydesc;
|
||||
|
@ -32,7 +32,8 @@ extern void R_ClipAndDrawPoly( float alpha, qboolean isturbulent, qboolean textu
|
|||
** Draw currententity / currentmodel as a single texture
|
||||
** mapped polygon
|
||||
*/
|
||||
void R_DrawSprite (void)
|
||||
void
|
||||
R_DrawSprite (void)
|
||||
{
|
||||
vec5_t *pverts;
|
||||
vec3_t left, up, right, down;
|
||||
|
|
|
@ -17,25 +17,23 @@ along with this program; if not, write to the Free Software
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// r_surf.c: surface-related refresh code
|
||||
// sw_surf.c: surface-related refresh code
|
||||
|
||||
#include "header/local.h"
|
||||
|
||||
drawsurf_t r_drawsurf;
|
||||
static int lightleft, blocksize, sourcetstep;
|
||||
static int lightright, lightleftstep, lightrightstep, blockdivshift;
|
||||
static void *prowdestbase;
|
||||
static unsigned char *pbasesource;
|
||||
static int surfrowbytes; // used by ASM files
|
||||
static int r_stepback;
|
||||
static int r_lightwidth;
|
||||
static int r_numhblocks, r_numvblocks;
|
||||
static unsigned char *r_source, *r_sourcemax;
|
||||
static unsigned *r_lightptr;
|
||||
|
||||
static void R_DrawSurfaceBlock8_anymip (int level);
|
||||
static void R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes);
|
||||
|
||||
void R_BuildLightMap (void);
|
||||
void R_BuildLightMap (drawsurf_t *drawsurf);
|
||||
extern unsigned blocklights[1024]; // allow some very large lightmaps
|
||||
|
||||
static float surfscale;
|
||||
|
@ -51,7 +49,8 @@ R_TextureAnimation
|
|||
Returns the proper texture for a given time and base texture
|
||||
===============
|
||||
*/
|
||||
static image_t *R_TextureAnimation (mtexinfo_t *tex)
|
||||
static image_t *
|
||||
R_TextureAnimation (mtexinfo_t *tex)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -74,7 +73,8 @@ static image_t *R_TextureAnimation (mtexinfo_t *tex)
|
|||
R_DrawSurface
|
||||
===============
|
||||
*/
|
||||
static void R_DrawSurface (void)
|
||||
static void
|
||||
R_DrawSurface (drawsurf_t *drawsurf)
|
||||
{
|
||||
unsigned char *basetptr;
|
||||
int smax, tmax, twidth;
|
||||
|
@ -84,47 +84,45 @@ static void R_DrawSurface (void)
|
|||
unsigned char *pcolumndest;
|
||||
image_t *mt;
|
||||
|
||||
surfrowbytes = r_drawsurf.rowbytes;
|
||||
mt = drawsurf->image;
|
||||
|
||||
mt = r_drawsurf.image;
|
||||
|
||||
r_source = mt->pixels[r_drawsurf.surfmip];
|
||||
r_source = mt->pixels[drawsurf->surfmip];
|
||||
|
||||
// the fractional light values should range from 0 to (VID_GRADES - 1) << 16
|
||||
// from a source range of 0 - 255
|
||||
|
||||
texwidth = mt->width >> r_drawsurf.surfmip;
|
||||
texwidth = mt->width >> drawsurf->surfmip;
|
||||
|
||||
blocksize = 16 >> r_drawsurf.surfmip;
|
||||
blockdivshift = NUM_MIPS - r_drawsurf.surfmip;
|
||||
blocksize = 16 >> drawsurf->surfmip;
|
||||
blockdivshift = NUM_MIPS - drawsurf->surfmip;
|
||||
|
||||
r_lightwidth = (r_drawsurf.surf->extents[0]>>4)+1;
|
||||
r_lightwidth = (drawsurf->surf->extents[0]>>4)+1;
|
||||
|
||||
r_numhblocks = r_drawsurf.surfwidth >> blockdivshift;
|
||||
r_numvblocks = r_drawsurf.surfheight >> blockdivshift;
|
||||
r_numhblocks = drawsurf->surfwidth >> blockdivshift;
|
||||
r_numvblocks = drawsurf->surfheight >> blockdivshift;
|
||||
|
||||
//==============================
|
||||
|
||||
// TODO: only needs to be set when there is a display settings change
|
||||
horzblockstep = blocksize;
|
||||
|
||||
smax = mt->width >> r_drawsurf.surfmip;
|
||||
smax = mt->width >> drawsurf->surfmip;
|
||||
twidth = texwidth;
|
||||
tmax = mt->height >> r_drawsurf.surfmip;
|
||||
tmax = mt->height >> drawsurf->surfmip;
|
||||
sourcetstep = texwidth;
|
||||
r_stepback = tmax * twidth;
|
||||
|
||||
r_sourcemax = r_source + (tmax * smax);
|
||||
|
||||
soffset = r_drawsurf.surf->texturemins[0];
|
||||
basetoffset = r_drawsurf.surf->texturemins[1];
|
||||
soffset = drawsurf->surf->texturemins[0];
|
||||
basetoffset = drawsurf->surf->texturemins[1];
|
||||
|
||||
// << 16 components are to guarantee positive values for %
|
||||
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << SHIFT16XYZ)) % smax;
|
||||
basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip)
|
||||
soffset = ((soffset >> drawsurf->surfmip) + (smax << SHIFT16XYZ)) % smax;
|
||||
basetptr = &r_source[((((basetoffset >> drawsurf->surfmip)
|
||||
+ (tmax << SHIFT16XYZ)) % tmax) * twidth)];
|
||||
|
||||
pcolumndest = r_drawsurf.surfdat;
|
||||
pcolumndest = drawsurf->surfdat;
|
||||
|
||||
for (u=0 ; u<r_numhblocks; u++)
|
||||
{
|
||||
|
@ -134,7 +132,7 @@ static void R_DrawSurface (void)
|
|||
|
||||
pbasesource = basetptr + soffset;
|
||||
|
||||
R_DrawSurfaceBlock8_anymip(NUM_MIPS - r_drawsurf.surfmip);
|
||||
R_DrawSurfaceBlock8_anymip(NUM_MIPS - drawsurf->surfmip, drawsurf->rowbytes);
|
||||
|
||||
soffset = soffset + blocksize;
|
||||
if (soffset >= smax)
|
||||
|
@ -152,7 +150,8 @@ static void R_DrawSurface (void)
|
|||
R_DrawSurfaceBlock8_anymip
|
||||
================
|
||||
*/
|
||||
static void R_DrawSurfaceBlock8_anymip (int level)
|
||||
static void
|
||||
R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes)
|
||||
{
|
||||
int v, i, b, lightstep, lighttemp, light, size;
|
||||
unsigned char pix, *psource, *prowdest;
|
||||
|
@ -206,7 +205,8 @@ R_InitCaches
|
|||
|
||||
================
|
||||
*/
|
||||
void R_InitCaches (void)
|
||||
void
|
||||
R_InitCaches (void)
|
||||
{
|
||||
int size;
|
||||
|
||||
|
@ -245,7 +245,8 @@ void R_InitCaches (void)
|
|||
D_FlushCaches
|
||||
==================
|
||||
*/
|
||||
void D_FlushCaches (void)
|
||||
void
|
||||
D_FlushCaches (void)
|
||||
{
|
||||
surfcache_t *c;
|
||||
|
||||
|
@ -269,7 +270,8 @@ void D_FlushCaches (void)
|
|||
D_SCAlloc
|
||||
=================
|
||||
*/
|
||||
static surfcache_t *D_SCAlloc (int width, int size)
|
||||
static surfcache_t *
|
||||
D_SCAlloc (int width, int size)
|
||||
{
|
||||
surfcache_t *new;
|
||||
|
||||
|
@ -335,14 +337,17 @@ static surfcache_t *D_SCAlloc (int width, int size)
|
|||
|
||||
//=============================================================================
|
||||
|
||||
static drawsurf_t r_drawsurf;
|
||||
|
||||
/*
|
||||
================
|
||||
D_CacheSurface
|
||||
================
|
||||
*/
|
||||
surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel)
|
||||
surfcache_t *
|
||||
D_CacheSurface (msurface_t *surface, int miplevel)
|
||||
{
|
||||
surfcache_t *cache;
|
||||
surfcache_t *cache;
|
||||
|
||||
//
|
||||
// if the surface is animating or flashing, flush the cache
|
||||
|
@ -408,10 +413,10 @@ surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel)
|
|||
c_surf++;
|
||||
|
||||
// calculate the lightings
|
||||
R_BuildLightMap ();
|
||||
R_BuildLightMap (&r_drawsurf);
|
||||
|
||||
// rasterize the surface into the cache
|
||||
R_DrawSurface ();
|
||||
R_DrawSurface (&r_drawsurf);
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue