mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-06 16:31:47 +00:00
Merge branch 'next' into udmf-next
This commit is contained in:
commit
3c294b5e3d
4 changed files with 49 additions and 78 deletions
|
@ -234,11 +234,11 @@ static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block,
|
||||||
if (mipmap->colormap)
|
if (mipmap->colormap)
|
||||||
texel = mipmap->colormap[texel];
|
texel = mipmap->colormap[texel];
|
||||||
|
|
||||||
// transparent pixel
|
// If the mipmap is chromakeyed, check if the texel's color
|
||||||
if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)
|
// is equivalent to the chroma key's color index.
|
||||||
alpha = 0x00;
|
|
||||||
else
|
|
||||||
alpha = 0xff;
|
alpha = 0xff;
|
||||||
|
if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX))
|
||||||
|
alpha = 0x00;
|
||||||
|
|
||||||
// hope compiler will get this switch out of the loops (dreams...)
|
// hope compiler will get this switch out of the loops (dreams...)
|
||||||
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
|
// gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?)
|
||||||
|
|
|
@ -49,8 +49,7 @@ static const GLubyte white[4] = { 255, 255, 255, 255 };
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
// With OpenGL 1.1+, the first texture should be 1
|
// With OpenGL 1.1+, the first texture should be 1
|
||||||
#define NOTEXTURE_NUM 1 // small white texture
|
static GLuint NOTEXTURE_NUM = 0;
|
||||||
#define FIRST_TEX_AVAIL (NOTEXTURE_NUM + 1)
|
|
||||||
|
|
||||||
#define N_PI_DEMI (M_PIl/2.0f) //(1.5707963268f)
|
#define N_PI_DEMI (M_PIl/2.0f) //(1.5707963268f)
|
||||||
|
|
||||||
|
@ -63,7 +62,6 @@ static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE;
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
|
|
||||||
static GLuint NextTexAvail = FIRST_TEX_AVAIL;
|
|
||||||
static GLuint tex_downloaded = 0;
|
static GLuint tex_downloaded = 0;
|
||||||
static GLfloat fov = 90.0f;
|
static GLfloat fov = 90.0f;
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -94,16 +92,10 @@ static GLfloat modelMatrix[16];
|
||||||
static GLfloat projMatrix[16];
|
static GLfloat projMatrix[16];
|
||||||
static GLint viewport[4];
|
static GLint viewport[4];
|
||||||
|
|
||||||
// Yay for arbitrary numbers! NextTexAvail is buggy for some reason.
|
|
||||||
// Sryder: NextTexAvail is broken for these because palette changes or changes to the texture filter or antialiasing
|
// Sryder: NextTexAvail is broken for these because palette changes or changes to the texture filter or antialiasing
|
||||||
// flush all of the stored textures, leaving them unavailable at times such as between levels
|
// flush all of the stored textures, leaving them unavailable at times such as between levels
|
||||||
// These need to start at 0 and be set to their number, and be reset to 0 when deleted so that intel GPUs
|
// These need to start at 0 and be set to their number, and be reset to 0 when deleted so that intel GPUs
|
||||||
// can know when the textures aren't there, as textures are always considered resident in their virtual memory
|
// can know when the textures aren't there, as textures are always considered resident in their virtual memory
|
||||||
// TODO: Store them in a more normal way
|
|
||||||
#define SCRTEX_SCREENTEXTURE 4294967295U
|
|
||||||
#define SCRTEX_STARTSCREENWIPE 4294967294U
|
|
||||||
#define SCRTEX_ENDSCREENWIPE 4294967293U
|
|
||||||
#define SCRTEX_FINALSCREENTEXTURE 4294967292U
|
|
||||||
static GLuint screentexture = 0;
|
static GLuint screentexture = 0;
|
||||||
static GLuint startScreenWipe = 0;
|
static GLuint startScreenWipe = 0;
|
||||||
static GLuint endScreenWipe = 0;
|
static GLuint endScreenWipe = 0;
|
||||||
|
@ -243,6 +235,7 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...)
|
||||||
|
|
||||||
/* 1.1 functions */
|
/* 1.1 functions */
|
||||||
/* texture objects */ //GL_EXT_texture_object
|
/* texture objects */ //GL_EXT_texture_object
|
||||||
|
#define pglGenTextures glGenTextures
|
||||||
#define pglDeleteTextures glDeleteTextures
|
#define pglDeleteTextures glDeleteTextures
|
||||||
#define pglBindTexture glBindTexture
|
#define pglBindTexture glBindTexture
|
||||||
/* texture mapping */ //GL_EXT_copy_texture
|
/* texture mapping */ //GL_EXT_copy_texture
|
||||||
|
@ -359,6 +352,8 @@ static PFNglFogfv pglFogfv;
|
||||||
|
|
||||||
/* 1.1 functions */
|
/* 1.1 functions */
|
||||||
/* texture objects */ //GL_EXT_texture_object
|
/* texture objects */ //GL_EXT_texture_object
|
||||||
|
typedef void (APIENTRY * PFNglGenTextures) (GLsizei n, const GLuint *textures);
|
||||||
|
static PFNglGenTextures pglGenTextures;
|
||||||
typedef void (APIENTRY * PFNglDeleteTextures) (GLsizei n, const GLuint *textures);
|
typedef void (APIENTRY * PFNglDeleteTextures) (GLsizei n, const GLuint *textures);
|
||||||
static PFNglDeleteTextures pglDeleteTextures;
|
static PFNglDeleteTextures pglDeleteTextures;
|
||||||
typedef void (APIENTRY * PFNglBindTexture) (GLenum target, GLuint texture);
|
typedef void (APIENTRY * PFNglBindTexture) (GLenum target, GLuint texture);
|
||||||
|
@ -487,6 +482,7 @@ boolean SetupGLfunc(void)
|
||||||
GETOPENGLFUNC(pglFogf , glFogf)
|
GETOPENGLFUNC(pglFogf , glFogf)
|
||||||
GETOPENGLFUNC(pglFogfv , glFogfv)
|
GETOPENGLFUNC(pglFogfv , glFogfv)
|
||||||
|
|
||||||
|
GETOPENGLFUNC(pglGenTextures , glGenTextures)
|
||||||
GETOPENGLFUNC(pglDeleteTextures , glDeleteTextures)
|
GETOPENGLFUNC(pglDeleteTextures , glDeleteTextures)
|
||||||
GETOPENGLFUNC(pglBindTexture , glBindTexture)
|
GETOPENGLFUNC(pglBindTexture , glBindTexture)
|
||||||
|
|
||||||
|
@ -527,6 +523,8 @@ static void SetNoTexture(void)
|
||||||
// Set small white texture.
|
// Set small white texture.
|
||||||
if (tex_downloaded != NOTEXTURE_NUM)
|
if (tex_downloaded != NOTEXTURE_NUM)
|
||||||
{
|
{
|
||||||
|
if (NOTEXTURE_NUM == 0)
|
||||||
|
pglGenTextures(1, &NOTEXTURE_NUM);
|
||||||
pglBindTexture(GL_TEXTURE_2D, NOTEXTURE_NUM);
|
pglBindTexture(GL_TEXTURE_2D, NOTEXTURE_NUM);
|
||||||
tex_downloaded = NOTEXTURE_NUM;
|
tex_downloaded = NOTEXTURE_NUM;
|
||||||
}
|
}
|
||||||
|
@ -641,11 +639,6 @@ void SetModelView(GLint w, GLint h)
|
||||||
// -----------------+
|
// -----------------+
|
||||||
void SetStates(void)
|
void SetStates(void)
|
||||||
{
|
{
|
||||||
// Bind little white RGBA texture to ID NOTEXTURE_NUM.
|
|
||||||
/*
|
|
||||||
FUINT Data[8*8];
|
|
||||||
INT32 i;
|
|
||||||
*/
|
|
||||||
#ifdef GL_LIGHT_MODEL_AMBIENT
|
#ifdef GL_LIGHT_MODEL_AMBIENT
|
||||||
GLfloat LightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
GLfloat LightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||||
#endif
|
#endif
|
||||||
|
@ -679,16 +672,8 @@ void SetStates(void)
|
||||||
CurrentPolyFlags = 0xffffffff;
|
CurrentPolyFlags = 0xffffffff;
|
||||||
SetBlend(0);
|
SetBlend(0);
|
||||||
|
|
||||||
/*
|
tex_downloaded = 0;
|
||||||
for (i = 0; i < 64; i++)
|
|
||||||
Data[i] = 0xffFFffFF; // white pixel
|
|
||||||
*/
|
|
||||||
|
|
||||||
tex_downloaded = (GLuint)-1;
|
|
||||||
SetNoTexture();
|
SetNoTexture();
|
||||||
//pglBindTexture(GL_TEXTURE_2D, NOTEXTURE_NUM);
|
|
||||||
//tex_downloaded = NOTEXTURE_NUM;
|
|
||||||
//pglTexImage2D(GL_TEXTURE_2D, 0, 4, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);
|
|
||||||
|
|
||||||
pglPolygonOffset(-1.0f, -1.0f);
|
pglPolygonOffset(-1.0f, -1.0f);
|
||||||
|
|
||||||
|
@ -723,33 +708,12 @@ void Flush(void)
|
||||||
|
|
||||||
while (gr_cachehead)
|
while (gr_cachehead)
|
||||||
{
|
{
|
||||||
// this is not necessary at all, because you have loaded them normally,
|
if (gr_cachehead->downloaded)
|
||||||
// and so they already are in your list!
|
|
||||||
#if 0
|
|
||||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
|
||||||
FTextureInfo *tmp = gr_cachehead->nextskin;
|
|
||||||
|
|
||||||
// The memory should be freed in the main code
|
|
||||||
while (tmp)
|
|
||||||
{
|
|
||||||
pglDeleteTextures(1, &tmp->downloaded);
|
|
||||||
tmp->downloaded = 0;
|
|
||||||
tmp = tmp->nextcolormap;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded);
|
pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded);
|
||||||
gr_cachehead->downloaded = 0;
|
gr_cachehead->downloaded = 0;
|
||||||
gr_cachehead = gr_cachehead->nextmipmap;
|
gr_cachehead = gr_cachehead->nextmipmap;
|
||||||
}
|
}
|
||||||
gr_cachetail = gr_cachehead = NULL; //Hurdler: well, gr_cachehead is already NULL
|
gr_cachetail = gr_cachehead = NULL; //Hurdler: well, gr_cachehead is already NULL
|
||||||
NextTexAvail = FIRST_TEX_AVAIL;
|
|
||||||
#if 0
|
|
||||||
if (screentexture != FIRST_TEX_AVAIL)
|
|
||||||
{
|
|
||||||
pglDeleteTextures(1, &screentexture);
|
|
||||||
screentexture = FIRST_TEX_AVAIL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tex_downloaded = 0;
|
tex_downloaded = 0;
|
||||||
}
|
}
|
||||||
|
@ -1128,8 +1092,10 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
|
||||||
static RGBA_t tex[2048*2048];
|
static RGBA_t tex[2048*2048];
|
||||||
const GLvoid *ptex = tex;
|
const GLvoid *ptex = tex;
|
||||||
INT32 w, h;
|
INT32 w, h;
|
||||||
|
GLuint texnum = 0;
|
||||||
|
|
||||||
//DBG_Printf ("DownloadMipmap %d %x\n",NextTexAvail,pTexInfo->grInfo.data);
|
pglGenTextures(1, &texnum);
|
||||||
|
//DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->grInfo.data);
|
||||||
|
|
||||||
w = pTexInfo->width;
|
w = pTexInfo->width;
|
||||||
h = pTexInfo->height;
|
h = pTexInfo->height;
|
||||||
|
@ -1217,9 +1183,10 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo)
|
||||||
else
|
else
|
||||||
DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
|
DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format);
|
||||||
|
|
||||||
pTexInfo->downloaded = NextTexAvail++;
|
// the texture number was already generated by pglGenTextures
|
||||||
tex_downloaded = pTexInfo->downloaded;
|
pglBindTexture(GL_TEXTURE_2D, texnum);
|
||||||
pglBindTexture(GL_TEXTURE_2D, pTexInfo->downloaded);
|
pTexInfo->downloaded = texnum;
|
||||||
|
tex_downloaded = texnum;
|
||||||
|
|
||||||
// disable texture filtering on any texture that has holes so there's no dumb borders or blending issues
|
// disable texture filtering on any texture that has holes so there's no dumb borders or blending issues
|
||||||
if (pTexInfo->flags & TF_TRANSPARENT)
|
if (pTexInfo->flags & TF_TRANSPARENT)
|
||||||
|
@ -2419,7 +2386,7 @@ EXPORT void HWRAPI(StartScreenWipe) (void)
|
||||||
|
|
||||||
// Create screen texture
|
// Create screen texture
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
startScreenWipe = SCRTEX_STARTSCREENWIPE;
|
pglGenTextures(1, &startScreenWipe);
|
||||||
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
|
pglBindTexture(GL_TEXTURE_2D, startScreenWipe);
|
||||||
|
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
|
@ -2450,7 +2417,7 @@ EXPORT void HWRAPI(EndScreenWipe)(void)
|
||||||
|
|
||||||
// Create screen texture
|
// Create screen texture
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
endScreenWipe = SCRTEX_ENDSCREENWIPE;
|
pglGenTextures(1, &endScreenWipe);
|
||||||
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
|
pglBindTexture(GL_TEXTURE_2D, endScreenWipe);
|
||||||
|
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
|
@ -2621,7 +2588,7 @@ EXPORT void HWRAPI(MakeScreenTexture) (void)
|
||||||
|
|
||||||
// Create screen texture
|
// Create screen texture
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
screentexture = SCRTEX_SCREENTEXTURE;
|
pglGenTextures(1, &screentexture);
|
||||||
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
pglBindTexture(GL_TEXTURE_2D, screentexture);
|
||||||
|
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
|
@ -2651,7 +2618,7 @@ EXPORT void HWRAPI(MakeScreenFinalTexture) (void)
|
||||||
|
|
||||||
// Create screen texture
|
// Create screen texture
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
finalScreenTexture = SCRTEX_FINALSCREENTEXTURE;
|
pglGenTextures(1, &finalScreenTexture);
|
||||||
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
|
||||||
|
|
||||||
if (firstTime)
|
if (firstTime)
|
||||||
|
|
|
@ -5740,6 +5740,8 @@ static void M_DrawNightsAttackSuperSonic(void)
|
||||||
const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE);
|
const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE);
|
||||||
INT32 timer = (ntsatkdrawtimer/4) % 2;
|
INT32 timer = (ntsatkdrawtimer/4) % 2;
|
||||||
angle_t fa = (FixedAngle(((ntsatkdrawtimer * 4) % 360)<<FRACBITS)>>ANGLETOFINESHIFT) & FINEMASK;
|
angle_t fa = (FixedAngle(((ntsatkdrawtimer * 4) % 360)<<FRACBITS)>>ANGLETOFINESHIFT) & FINEMASK;
|
||||||
|
ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH);
|
||||||
|
ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH);
|
||||||
V_DrawFixedPatch(235<<FRACBITS, (120<<FRACBITS) - (8*FINESINE(fa)), FRACUNIT, 0, ntssupersonic[timer], colormap);
|
V_DrawFixedPatch(235<<FRACBITS, (120<<FRACBITS) - (8*FINESINE(fa)), FRACUNIT, 0, ntssupersonic[timer], colormap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9978,9 +9980,6 @@ static void M_NightsAttack(INT32 choice)
|
||||||
// This is really just to make sure Sonic is the played character, just in case
|
// This is really just to make sure Sonic is the played character, just in case
|
||||||
M_PatchSkinNameTable();
|
M_PatchSkinNameTable();
|
||||||
|
|
||||||
ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH);
|
|
||||||
ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH);
|
|
||||||
|
|
||||||
G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching
|
G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching
|
||||||
titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please
|
titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please
|
||||||
M_SetupNextMenu(&SP_NightsAttackDef);
|
M_SetupNextMenu(&SP_NightsAttackDef);
|
||||||
|
|
25
src/r_data.c
25
src/r_data.c
|
@ -230,25 +230,30 @@ static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, tex
|
||||||
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha)
|
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha)
|
||||||
{
|
{
|
||||||
RGBA_t output;
|
RGBA_t output;
|
||||||
|
INT16 fullalpha = (alpha - (0xFF - foreground.s.alpha));
|
||||||
if (style == AST_TRANSLUCENT)
|
if (style == AST_TRANSLUCENT)
|
||||||
{
|
{
|
||||||
if (alpha == 0)
|
if (fullalpha <= 0)
|
||||||
output.rgba = background.rgba;
|
output.rgba = background.rgba;
|
||||||
else if (alpha == 0xFF)
|
else
|
||||||
output.rgba = foreground.rgba;
|
{
|
||||||
else if (alpha < 0xFF)
|
// don't go too high
|
||||||
|
if (fullalpha >= 0xFF)
|
||||||
|
fullalpha = 0xFF;
|
||||||
|
alpha = (UINT8)fullalpha;
|
||||||
|
|
||||||
|
// if the background pixel is empty, match software and don't blend anything
|
||||||
|
if (!background.s.alpha)
|
||||||
|
output.rgba = 0;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
UINT8 beta = (0xFF - alpha);
|
UINT8 beta = (0xFF - alpha);
|
||||||
output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF;
|
output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF;
|
||||||
output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF;
|
output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF;
|
||||||
output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF;
|
output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF;
|
||||||
}
|
|
||||||
// write foreground pixel alpha
|
|
||||||
// if there's no pixel in here
|
|
||||||
if (!background.rgba)
|
|
||||||
output.s.alpha = foreground.s.alpha;
|
|
||||||
else
|
|
||||||
output.s.alpha = 0xFF;
|
output.s.alpha = 0xFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
return output.rgba;
|
return output.rgba;
|
||||||
}
|
}
|
||||||
#define clamp(c) max(min(c, 0xFF), 0x00);
|
#define clamp(c) max(min(c, 0xFF), 0x00);
|
||||||
|
|
Loading…
Reference in a new issue