make skytextures support texture offsets in software
This commit is contained in:
1 parent
09ce33abb9
commit
24eb888af3
5 files changed
+47
-5
No files matched your search
+5
-1
@@ -649,6 +649,7 @@ void R_LoadTextures(void)
|
||||
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
|
||||
texture->width = SHORT(patchlump->width);
|
||||
texture->height = SHORT(patchlump->height);
|
||||
texture->type = TEXTURETYPE_SINGLEPATCH;
|
||||
texture->patchcount = 1;
|
||||
texture->holes = false;
|
||||
|
||||
@@ -915,19 +916,22 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
|
||||
|
||||
// Left Curly Brace
|
||||
texturesToken = M_GetToken(NULL);
|
||||
|
||||
if (texturesToken == NULL)
|
||||
{
|
||||
I_Error("Error parsing TEXTURES lump: Unexpected end of file where open curly brace for texture \"%s\" should be",newTextureName);
|
||||
}
|
||||
|
||||
if (strcmp(texturesToken,"{")==0)
|
||||
{
|
||||
if (actuallyLoadTexture)
|
||||
{
|
||||
// Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily.
|
||||
resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t),PU_STATIC,NULL);
|
||||
resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t), PU_STATIC, NULL);
|
||||
M_Memcpy(resultTexture->name, newTextureName, 8);
|
||||
resultTexture->width = newTextureWidth;
|
||||
resultTexture->height = newTextureHeight;
|
||||
resultTexture->type = TEXTURETYPE_COMPOSITE;
|
||||
}
|
||||
Z_Free(texturesToken);
|
||||
texturesToken = M_GetToken(NULL);
|
||||
|
||||
@@ -37,6 +37,14 @@ typedef struct
|
||||
UINT16 wad, lump;
|
||||
} texpatch_t;
|
||||
|
||||
// texture type
|
||||
enum
|
||||
{
|
||||
TEXTURETYPE_UNKNOWN,
|
||||
TEXTURETYPE_SINGLEPATCH,
|
||||
TEXTURETYPE_COMPOSITE,
|
||||
};
|
||||
|
||||
// A maptexturedef_t describes a rectangular texture,
|
||||
// which is composed of one or more mappatch_t structures
|
||||
// that arrange graphic patches.
|
||||
@@ -44,6 +52,7 @@ typedef struct
|
||||
{
|
||||
// Keep name for switch changing, etc.
|
||||
char name[8];
|
||||
UINT8 type; // TEXTURETYPE_
|
||||
INT16 width, height;
|
||||
boolean holes;
|
||||
|
||||
|
||||
@@ -839,6 +839,8 @@ static void R_DrawSkyPlane(visplane_t *pl, void(*colfunc2)(drawcolumndata_t*), b
|
||||
}
|
||||
|
||||
INT32 angle = (pl->viewangle + xtoviewangle[x + i])>>ANGLETOSKYSHIFT;
|
||||
angle -= (skytextureoffset >> FRACBITS);
|
||||
|
||||
dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x + i]>>ANGLETOFINESHIFT));
|
||||
dc.x = x + i;
|
||||
dc.source =
|
||||
|
||||
+22
-3
@@ -41,6 +41,10 @@ INT32 skytexture;
|
||||
*/
|
||||
INT32 skytexturemid;
|
||||
|
||||
/** \brief the x offset of the sky texture
|
||||
*/
|
||||
INT32 skytextureoffset;
|
||||
|
||||
/** \brief the scale of the sky
|
||||
*/
|
||||
fixed_t skyscale;
|
||||
@@ -50,6 +54,7 @@ fixed_t skyscale;
|
||||
INT32 levelskynum;
|
||||
INT32 globallevelskynum;
|
||||
|
||||
|
||||
/** \brief The R_SetupSkyDraw function
|
||||
|
||||
Called at loadlevel after skytexture is set, or when sky texture changes.
|
||||
@@ -61,8 +66,20 @@ INT32 globallevelskynum;
|
||||
*/
|
||||
void R_SetupSkyDraw(void)
|
||||
{
|
||||
// the horizon line in a 256x128 sky texture
|
||||
skytexturemid = (textures[skytexture]->height/2)<<FRACBITS;
|
||||
// the horizon line in the sky texture
|
||||
skytexturemid = (textures[skytexture]->height / 2) << FRACBITS;
|
||||
skytextureoffset = 0;
|
||||
|
||||
if (textures[skytexture]->type == TEXTURETYPE_SINGLEPATCH)
|
||||
{
|
||||
// Sal: Allow for sky offsets
|
||||
texpatch_t *const tex_patch = &textures[skytexture]->patches[0];
|
||||
patch_t *patch = W_CachePatchNumPwad(tex_patch->wad, tex_patch->lump, PU_CACHE);
|
||||
|
||||
skytexturemid += (patch->topoffset << FRACBITS);
|
||||
skytextureoffset += (patch->leftoffset << FRACBITS);
|
||||
}
|
||||
|
||||
R_SetSkyScale();
|
||||
}
|
||||
|
||||
@@ -74,5 +91,7 @@ void R_SetupSkyDraw(void)
|
||||
*/
|
||||
void R_SetSkyScale(void)
|
||||
{
|
||||
skyscale = FixedDiv(fovtan, FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT));
|
||||
//skyscale = FixedDiv(fovtan, FixedDiv(vid.width*FRACUNIT, BASEVIDWIDTH*FRACUNIT));
|
||||
fixed_t difference = vid.fdupx-(vid.dupx<<FRACBITS);
|
||||
skyscale = FixedDiv(fovtan, vid.fdupx+difference);
|
||||
}
|
||||
+9
-1
@@ -14,6 +14,10 @@
|
||||
#ifndef __R_SKY__
|
||||
#define __R_SKY__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "m_fixed.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
@@ -26,7 +30,7 @@
|
||||
/// \brief The sky map is 256*128*4 maps.
|
||||
#define ANGLETOSKYSHIFT 22
|
||||
|
||||
extern INT32 skytexture, skytexturemid;
|
||||
extern INT32 skytexture, skytexturemid, skytextureoffset;
|
||||
extern fixed_t skyscale;
|
||||
|
||||
extern INT32 skyflatnum;
|
||||
@@ -38,4 +42,8 @@ void R_SetupSkyDraw(void);
|
||||
|
||||
void R_SetSkyScale(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user