mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-22 11:52:04 +00:00
Share R_TextureAnimation
This commit is contained in:
parent
42bfb2014c
commit
c17210b34a
6 changed files with 63 additions and 81 deletions
3
Makefile
3
Makefile
|
@ -927,6 +927,7 @@ REFGL1_OBJS_ := \
|
||||||
src/client/refresh/gl1/gl1_surf.o \
|
src/client/refresh/gl1/gl1_surf.o \
|
||||||
src/client/refresh/gl1/gl1_warp.o \
|
src/client/refresh/gl1/gl1_warp.o \
|
||||||
src/client/refresh/gl1/gl1_sdl.o \
|
src/client/refresh/gl1/gl1_sdl.o \
|
||||||
|
src/client/refresh/files/surf.o \
|
||||||
src/client/refresh/files/models.o \
|
src/client/refresh/files/models.o \
|
||||||
src/client/refresh/files/pcx.o \
|
src/client/refresh/files/pcx.o \
|
||||||
src/client/refresh/files/stb.o \
|
src/client/refresh/files/stb.o \
|
||||||
|
@ -958,6 +959,7 @@ REFGL3_OBJS_ := \
|
||||||
src/client/refresh/gl3/gl3_surf.o \
|
src/client/refresh/gl3/gl3_surf.o \
|
||||||
src/client/refresh/gl3/gl3_warp.o \
|
src/client/refresh/gl3/gl3_warp.o \
|
||||||
src/client/refresh/gl3/gl3_shaders.o \
|
src/client/refresh/gl3/gl3_shaders.o \
|
||||||
|
src/client/refresh/files/surf.o \
|
||||||
src/client/refresh/files/models.o \
|
src/client/refresh/files/models.o \
|
||||||
src/client/refresh/files/pcx.o \
|
src/client/refresh/files/pcx.o \
|
||||||
src/client/refresh/files/stb.o \
|
src/client/refresh/files/stb.o \
|
||||||
|
@ -1000,6 +1002,7 @@ REFSOFT_OBJS_ := \
|
||||||
src/client/refresh/soft/sw_scan.o \
|
src/client/refresh/soft/sw_scan.o \
|
||||||
src/client/refresh/soft/sw_sprite.o \
|
src/client/refresh/soft/sw_sprite.o \
|
||||||
src/client/refresh/soft/sw_surf.o \
|
src/client/refresh/soft/sw_surf.o \
|
||||||
|
src/client/refresh/files/surf.o \
|
||||||
src/client/refresh/files/models.o \
|
src/client/refresh/files/models.o \
|
||||||
src/client/refresh/files/pcx.o \
|
src/client/refresh/files/pcx.o \
|
||||||
src/client/refresh/files/stb.o \
|
src/client/refresh/files/stb.o \
|
||||||
|
|
55
src/client/refresh/files/surf.c
Normal file
55
src/client/refresh/files/surf.c
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* =======================================================================
|
||||||
|
*
|
||||||
|
* Surface logic
|
||||||
|
*
|
||||||
|
* =======================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../ref_shared.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
===============
|
||||||
|
R_TextureAnimation
|
||||||
|
|
||||||
|
Returns the proper texture for a given time and base texture
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
struct image_s *
|
||||||
|
R_TextureAnimation(const entity_t *currententity, const mtexinfo_t *tex)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
|
||||||
|
if (!tex->next)
|
||||||
|
return tex->image;
|
||||||
|
|
||||||
|
if (!currententity)
|
||||||
|
return tex->image;
|
||||||
|
|
||||||
|
c = currententity->frame % tex->numframes;
|
||||||
|
while (c && tex)
|
||||||
|
{
|
||||||
|
tex = tex->next;
|
||||||
|
c--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tex->image;
|
||||||
|
}
|
|
@ -42,30 +42,6 @@ qboolean LM_AllocBlock(int w, int h, int *x, int *y);
|
||||||
void R_SetCacheState(msurface_t *surf);
|
void R_SetCacheState(msurface_t *surf);
|
||||||
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride);
|
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride);
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the proper texture for a given time and base texture
|
|
||||||
*/
|
|
||||||
static image_t *
|
|
||||||
R_TextureAnimation(entity_t *currententity, mtexinfo_t *tex)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (!tex->next)
|
|
||||||
{
|
|
||||||
return tex->image;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = currententity->frame % tex->numframes;
|
|
||||||
|
|
||||||
while (c)
|
|
||||||
{
|
|
||||||
tex = tex->next;
|
|
||||||
c--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tex->image;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
R_DrawGLPoly(glpoly_t *p)
|
R_DrawGLPoly(glpoly_t *p)
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,31 +156,6 @@ CullBox(vec3_t mins, vec3_t maxs)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Returns the proper texture for a given time and base texture
|
|
||||||
*/
|
|
||||||
static gl3image_t *
|
|
||||||
TextureAnimation(entity_t *currententity, mtexinfo_t *tex)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (!tex->next)
|
|
||||||
{
|
|
||||||
return tex->image;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = currententity->frame % tex->numframes;
|
|
||||||
|
|
||||||
while (c)
|
|
||||||
{
|
|
||||||
tex = tex->next;
|
|
||||||
c--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tex->image;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SetLightFlags(msurface_t *surf)
|
SetLightFlags(msurface_t *surf)
|
||||||
{
|
{
|
||||||
|
@ -345,7 +320,7 @@ RenderBrushPoly(entity_t *currententity, msurface_t *fa)
|
||||||
|
|
||||||
c_brush_polys++;
|
c_brush_polys++;
|
||||||
|
|
||||||
image = TextureAnimation(currententity, fa->texinfo);
|
image = R_TextureAnimation(currententity, fa->texinfo);
|
||||||
|
|
||||||
if (fa->flags & SURF_DRAWTURB)
|
if (fa->flags & SURF_DRAWTURB)
|
||||||
{
|
{
|
||||||
|
@ -490,7 +465,7 @@ static void
|
||||||
RenderLightmappedPoly(entity_t *currententity, msurface_t *surf)
|
RenderLightmappedPoly(entity_t *currententity, msurface_t *surf)
|
||||||
{
|
{
|
||||||
int map;
|
int map;
|
||||||
gl3image_t *image = TextureAnimation(currententity, surf->texinfo);
|
gl3image_t *image = R_TextureAnimation(currententity, surf->texinfo);
|
||||||
|
|
||||||
hmm_vec4 lmScales[MAX_LIGHTMAPS_PER_SURFACE] = {0};
|
hmm_vec4 lmScales[MAX_LIGHTMAPS_PER_SURFACE] = {0};
|
||||||
lmScales[0] = HMM_Vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
lmScales[0] = HMM_Vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
@ -782,7 +757,7 @@ RecursiveWorldNode(entity_t *currententity, mnode_t *node)
|
||||||
/* add to the translucent chain */
|
/* add to the translucent chain */
|
||||||
surf->texturechain = gl3_alpha_surfaces;
|
surf->texturechain = gl3_alpha_surfaces;
|
||||||
gl3_alpha_surfaces = surf;
|
gl3_alpha_surfaces = surf;
|
||||||
gl3_alpha_surfaces->texinfo->image = TextureAnimation(currententity, surf->texinfo);
|
gl3_alpha_surfaces->texinfo->image = R_TextureAnimation(currententity, surf->texinfo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -798,7 +773,7 @@ RecursiveWorldNode(entity_t *currententity, mnode_t *node)
|
||||||
#endif // 0
|
#endif // 0
|
||||||
{
|
{
|
||||||
/* the polygon is visible, so add it to the texture sorted chain */
|
/* the polygon is visible, so add it to the texture sorted chain */
|
||||||
image = TextureAnimation(currententity, surf->texinfo);
|
image = R_TextureAnimation(currententity, surf->texinfo);
|
||||||
surf->texturechain = image->texturechain;
|
surf->texturechain = image->texturechain;
|
||||||
image->texturechain = surf;
|
image->texturechain = surf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,5 +208,6 @@ extern void Mod_LoadSurfedges (const char *name, int **surfedges, int *numsurfed
|
||||||
const byte *mod_base, const lump_t *l, int extra);
|
const byte *mod_base, const lump_t *l, int extra);
|
||||||
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
extern int Mod_CalcLumpHunkSize(const lump_t *l, int inSize, int outSize, int extra);
|
||||||
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);
|
extern mleaf_t *Mod_PointInLeaf(const vec3_t p, mnode_t *node);
|
||||||
|
extern struct image_s *R_TextureAnimation(const entity_t *currententity, const mtexinfo_t *tex);
|
||||||
|
|
||||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||||
|
|
|
@ -36,34 +36,6 @@ static int sc_size;
|
||||||
static surfcache_t *sc_rover;
|
static surfcache_t *sc_rover;
|
||||||
surfcache_t *sc_base;
|
surfcache_t *sc_base;
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
R_TextureAnimation
|
|
||||||
|
|
||||||
Returns the proper texture for a given time and base texture
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static image_t *
|
|
||||||
R_TextureAnimation (const entity_t *currententity, mtexinfo_t *tex)
|
|
||||||
{
|
|
||||||
int c;
|
|
||||||
|
|
||||||
if (!tex->next)
|
|
||||||
return tex->image;
|
|
||||||
|
|
||||||
if (!currententity)
|
|
||||||
return tex->image;
|
|
||||||
|
|
||||||
c = currententity->frame % tex->numframes;
|
|
||||||
while (c && tex)
|
|
||||||
{
|
|
||||||
tex = tex->next;
|
|
||||||
c--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tex->image;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Color light apply is not required
|
* Color light apply is not required
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue