More alug's changes

This commit is contained in:
indev committed 2023-06-25 17:34:40 +03:00
1 parent b0ea8cfac9
commit a40facd6f5
16 files changed
+1291 -178

No files matched your search

+2 -2
View File
@@ -149,8 +149,8 @@ extern char logfilename[1024];
#else
#define VERSION 1 // Game version
#define SUBVERSION 6 // more precise version number
#define VERSIONSTRING "Galaxy(v1.2) Alugs Spoon v2 "
#define VERSIONSTRINGW L"Galaxy(v1.2) Alugs Spoon v2"
#define VERSIONSTRING "Galaxy(v1.2) Alugs Spoon v3.1/dev "
#define VERSIONSTRINGW L"Galaxy(v1.2) Alugs Spoon v3.1/dev"
// Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates!
// And change CMakeLists.txt (not src/, but in root), for CMake users!
// AND appveyor.yml, for the build bots!
+19
View File
@@ -44,6 +44,10 @@ typedef struct
float dx, dy;
} fdivline_t;
// when loading the map, this is set to true if portals are found.
// if no portals are found, the portal scanning phase can be skipped while rendering, saving a bit of time.
boolean gr_maphasportals = false;
// ==========================================================================
// FLOOR & CEILING CONVEX POLYS GENERATION
// ==========================================================================
@@ -365,6 +369,18 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly)
{
//x,y,dx,dy (like a divline)
line_t *line = lseg->linedef;
// portal check
if (!gr_maphasportals && line->special == 40 && lseg->side == 0)
{
// Find the other side!
INT32 line2 = P_FindSpecialLineFromTag(40, line->tag, -1);
if (line == &lines[line2])
line2 = P_FindSpecialLineFromTag(40, line->tag, line2);
if (line2 >= 0) // found it!
gr_maphasportals = 1;
}
p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x);
p1.y = FIXED_TO_FLOAT(lseg->side ? line->v2->y : line->v1->y);
p2.x = FIXED_TO_FLOAT(lseg->side ? line->v1->x : line->v2->x);
@@ -880,6 +896,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
I_FinishUpdate(); // page flip or blit buffer
#endif
// reset the portal flag
gr_maphasportals = 0;
// find min/max boundaries of map
//CONS_Debug(DBG_RENDER, "Looking for boundaries of map...\n");
M_ClearBox(rootbbox);
+42 -16
View File
@@ -476,24 +476,50 @@ void HWR_InitTextureCache(void)
gr_textures = NULL;
}
// Callback function for HWR_FreeTextureCache.
static void FreeMipmapColormap(INT32 patchnum, void *patch)
{
GLPatch_t* const grpatch = patch;
GLPatch_t* const pat = patch;
(void)patchnum; //unused
while (grpatch->mipmap->nextcolormap)
// The patch must be valid, obviously
if (!pat)
return;
// The mipmap must be valid, obviously
while (pat->mipmap)
{
GLMipmap_t *grmip = grpatch->mipmap->nextcolormap;
grpatch->mipmap->nextcolormap = grmip->nextcolormap;
if (grmip->grInfo.data) Z_Free(grmip->grInfo.data);
free(grmip);
// Confusing at first, but pat->mipmap->nextcolormap
// at the beginning of the loop is the first colormap
// from the linked list of colormaps.
GLMipmap_t *next = NULL;
// No mipmap in this patch, break out of the loop.
if (!pat->mipmap)
break;
// No colormap mipmap either.
if (!pat->mipmap->nextcolormap)
break;
// Set the first colormap to the one that comes after it.
next = pat->mipmap->nextcolormap;
pat->mipmap->nextcolormap = next->nextcolormap;
// Free image data from memory.
if (next->grInfo.data)
Z_Free(next->grInfo.data);
next->grInfo.data = NULL;
// Free the old colormap mipmap from memory.
free(next);
}
}
void HWR_FreeTextureCache(void)
void HWR_FreeMipmapCache(void)
{
INT32 i;
// free references to the textures
HWD.pfnClearMipMapCache();
@@ -503,10 +529,15 @@ void HWR_FreeTextureCache(void)
Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED);
// Alam: free the Z_Blocks before freeing it's users
// free all skin after each level: must be done after pfnClearMipMapCache!
// free all patch colormaps after each level: must be done after ClearMipMapCache!
for (i = 0; i < numwadfiles; i++)
M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap);
}
void HWR_FreeTextureCache(void)
{
// free references to the textures
HWR_FreeMipmapCache();
// now the heap don't have any 'user' pointing to our
// texturecache info, we can free it
@@ -516,13 +547,8 @@ void HWR_FreeTextureCache(void)
gr_numtextures = 0;
}
void HWR_PrepLevelCache(size_t pnumtextures)
void HWR_LoadTextures(size_t pnumtextures)
{
// problem: the mipmap cache management hold a list of mipmaps.. but they are
// reallocated on each level..
//sub-optimal, but 1) just need re-download stuff in hardware cache VERY fast
// 2) sprite/menu stuff mixed with level textures so can't do anything else
// we must free it since numtextures changed
HWR_FreeTextureCache();
+14
View File
@@ -236,11 +236,25 @@ enum hwdsetspecialstate
HWD_SET_TEXTUREANISOTROPICMODE,
HWD_SET_SCREEN_TEXTURES,
HWD_SET_DEPTH_ONLY_MODE,// for portals
HWD_SET_PORTAL_MODE,// new portal thing
HWD_SET_STENCIL_LEVEL,
HWD_NUMSTATE
};
typedef enum hwdsetspecialstate hwdspecialstate_t;
enum hwdportalstate
{
HWD_PORTAL_NORMAL,
HWD_PORTAL_STENCIL_SEGS,
HWD_PORTAL_STENCIL_REVERSE_SEGS,
HWD_PORTAL_DEPTH_SEGS,
HWD_PORTAL_SKY_STENCIL_SEGS,
};
#define GL_DEFAULTMIX 0x00000000
#define GL_DEFAULTFOG 0xFF000000
+2 -2
View File
@@ -883,7 +883,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
clearColour.green = (float)rgbaColour.s.green / 255;
clearColour.blue = (float)rgbaColour.s.blue / 255;
clearColour.alpha = 1;
HWD.pfnClearBuffer(true, false, &clearColour);
HWD.pfnClearBuffer(true, false, false, &clearColour);
return;
}
@@ -991,7 +991,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
clearColour.green = (float)rgbaColour.s.green / 255;
clearColour.blue = (float)rgbaColour.s.blue / 255;
clearColour.alpha = 1;
HWD.pfnClearBuffer(true, false, &clearColour);
HWD.pfnClearBuffer(true, false, false, &clearColour);
return;
}
+1 -1
View File
@@ -36,7 +36,7 @@ EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl);
EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color);
EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags);
EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat *ClearColor);
EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo);
EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
+1
View File
@@ -58,6 +58,7 @@ extern size_t addsubsector;
// --------
void HWR_InitTextureCache(void);
void HWR_FreeTextureCache(void);
void HWR_FreeMipmapCache(void);
void HWR_FreeExtraSubsectors(void);
void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap);
+973 -95
View File
File diff suppressed because it is too large. Load diff
+8 -2
View File
@@ -64,6 +64,8 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_LoadShaders(UINT16 wadnum, boolean PK3);
void HWR_SetViewSize(void);
void HWR_AddCommands(void);
void HWR_SetTransform(float fpov, player_t *player);
void HWR_ClearClipper(void);
// My original intention was to split hw_main.c
// into files like hw_bsp.c, hw_sprites.c...
@@ -84,7 +86,7 @@ void HWR_MakeScreenFinalTexture(void);
void HWR_DrawScreenFinalTexture(int width, int height);
// hw_main.c: Planes
void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap);
void HWR_RenderPlane(extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap, subsector_t *subsector);
void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap);
#ifdef POLYOBJECTS
@@ -123,9 +125,10 @@ void HWR_DrawSprites(void);
// hw_bsp.c
void HWR_CreatePlanePolygons(INT32 bspnum);
extern boolean gr_maphasportals;
// hw_cache.c
void HWR_PrepLevelCache(size_t pnumtextures);
void HWR_LoadTextures(size_t pnumtextures);
// hw_trick.c
void HWR_CorrectSWTricks(void);
@@ -149,6 +152,9 @@ extern consvar_t cv_grspritebillboarding;
extern consvar_t cv_grfakecontrast;
extern consvar_t cv_grfallbackplayermodel;
extern consvar_t cv_grrenderdistance;
extern consvar_t cv_grportals;
extern consvar_t cv_nostencil;
extern consvar_t cv_grusecustomshaders;
extern CV_PossibleValue_t granisotropicmode_cons_t[];
+185 -31
View File
@@ -28,6 +28,9 @@
#include "../../p_tick.h" // for leveltime (NOTE: THIS IS BAD, FIGURE OUT HOW TO PROPERLY IMPLEMENT gl_leveltime)
// Eeeeh not sure is this right way, but it works
extern consvar_t cv_grusecustomshaders;
extern fixed_t fovtan; // also extremely bad, I'm just too lazy!!!
#if defined (HWRENDER) && !defined (NOROPENGL)
@@ -488,6 +491,12 @@ boolean SetupGLfunc(void)
return true;
}
typedef void (APIENTRY *PFNglStencilFuncSeparate) (GLenum, GLenum, GLint, GLuint);
static PFNglStencilFuncSeparate pglStencilFuncSeparate;
typedef void (APIENTRY *PFNglStencilOpSeparate) (GLenum, GLenum, GLenum, GLenum);
static PFNglStencilOpSeparate pglStencilOpSeparate;
#ifdef GL_SHADERS
typedef GLuint (APIENTRY *PFNglCreateShader) (GLenum);
typedef void (APIENTRY *PFNglShaderSource) (GLuint, GLsizei, const GLchar**, GLint*);
@@ -547,6 +556,10 @@ static boolean gl_batching = false;// are we currently collecting batches?
static INT32 gl_enable_screen_textures = 1;
static GLint gl_portal_stencil_level = 0;
static INT32 gl_portal_mode = HWD_PORTAL_NORMAL;
// 13062019
typedef enum
{
@@ -795,6 +808,9 @@ void SetupGLFunc4(void)
pglBufferData = GetGLFunc("glBufferData");
pglDeleteBuffers = GetGLFunc("glDeleteBuffers");
pglColorPointer = GetGLFunc("glColorPointer");
pglStencilFuncSeparate = GetGLFunc("glStencilFuncSeparate");
pglStencilOpSeparate = GetGLFunc("glStencilOpSeparate");
#ifdef GL_SHADERS
pglCreateShader = GetGLFunc("glCreateShader");
@@ -840,12 +856,12 @@ EXPORT boolean HWRAPI(LoadShaders) (void)
gl_shaderprogram_t *shader;
const GLchar* vert_shader = vertex_shaders[i];
const GLchar* frag_shader = fragment_shaders[i];
boolean custom = ((gl_customvertexshaders[i] || gl_customfragmentshaders[i]) && (i > 0));
boolean custom = cv_grusecustomshaders.value && ((gl_customvertexshaders[i] || gl_customfragmentshaders[i]) && (i > 0));
// 18032019
if (gl_customvertexshaders[i])
if (cv_grusecustomshaders.value && gl_customvertexshaders[i])
vert_shader = gl_customvertexshaders[i];
if (gl_customfragmentshaders[i])
if (cv_grusecustomshaders.value && gl_customfragmentshaders[i])
frag_shader = gl_customfragmentshaders[i];
if (i >= MAXSHADERS)
@@ -1111,6 +1127,8 @@ void SetStates(void)
pglLoadIdentity();
pglScalef(1.0f, 1.0f, -1.0f);
pglGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer)
pglEnable(GL_STENCIL_TEST);
}
// -----------------+
@@ -1263,6 +1281,7 @@ EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, f
// -----------------+
EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask,
FBOOLEAN DepthMask,
FBOOLEAN StencilMask,
FRGBAFloat * ClearColor)
{
//GL_DBG_Printf("ClearBuffer(%d)\n", alpha);
@@ -1286,7 +1305,9 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask,
}
SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude);
if (StencilMask)
ClearMask |= GL_STENCIL_BUFFER_BIT;// looks like sometimes stencil buffer needs clearing? had a problem with random black screens
pglClear(ClearMask);
pglEnableClientState(GL_VERTEX_ARRAY); // We always use this one
pglEnableClientState(GL_TEXTURE_COORD_ARRAY); // And mostly this one, too
@@ -2300,35 +2321,41 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUI
SetBlend(PolyFlags); //TODO: inline (#pragma..)
// PolyColor
if (pSurf)
if (gl_portal_mode == HWD_PORTAL_NORMAL)
{
// If Modulated, mix the surface colour to the texture
if (CurrentPolyFlags & PF_Modulated)
// PolyColor
if (pSurf)
{
// Poly color
poly.red = byte2float[pSurf->PolyColor.s.red];
poly.green = byte2float[pSurf->PolyColor.s.green];
poly.blue = byte2float[pSurf->PolyColor.s.blue];
poly.alpha = byte2float[pSurf->PolyColor.s.alpha];
// If Modulated, mix the surface colour to the texture
if (CurrentPolyFlags & PF_Modulated)
{
// Poly color
poly.red = byte2float[pSurf->PolyColor.s.red];
poly.green = byte2float[pSurf->PolyColor.s.green];
poly.blue = byte2float[pSurf->PolyColor.s.blue];
poly.alpha = byte2float[pSurf->PolyColor.s.alpha];
pglColor4ubv((GLubyte*)&pSurf->PolyColor.s);
pglColor4ubv((GLubyte*)&pSurf->PolyColor.s);
}
// Tint color
tint.red = byte2float[pSurf->TintColor.s.red];
tint.green = byte2float[pSurf->TintColor.s.green];
tint.blue = byte2float[pSurf->TintColor.s.blue];
tint.alpha = byte2float[pSurf->TintColor.s.alpha];
// Fade color
fade.red = byte2float[pSurf->FadeColor.s.red];
fade.green = byte2float[pSurf->FadeColor.s.green];
fade.blue = byte2float[pSurf->FadeColor.s.blue];
fade.alpha = byte2float[pSurf->FadeColor.s.alpha];
}
// Tint color
tint.red = byte2float[pSurf->TintColor.s.red];
tint.green = byte2float[pSurf->TintColor.s.green];
tint.blue = byte2float[pSurf->TintColor.s.blue];
tint.alpha = byte2float[pSurf->TintColor.s.alpha];
// Fade color
fade.red = byte2float[pSurf->FadeColor.s.red];
fade.green = byte2float[pSurf->FadeColor.s.green];
fade.blue = byte2float[pSurf->FadeColor.s.blue];
fade.alpha = byte2float[pSurf->FadeColor.s.alpha];
}
load_shaders(pSurf, &poly, &tint, &fade);
}
else
UnSetShader();
pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x);
pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].s);
@@ -2435,6 +2462,54 @@ static void SkyVertex(vbo_vertex_t *vbo, int r, int c)
vbo->z = z;
}
void RevertStencilBuffer()// TODO need to add OpenGL stencil functions to function importing
{
/*const float screenVerts[12] =
{
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f
};*/
const float screenVerts[12] =
{
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f
};
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
pglDisable(GL_TEXTURE_2D);
pglDisable(GL_DEPTH_TEST);
pglDisable(GL_BLEND);
//pglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);// TEST
//pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_EQUAL, gl_portal_stencil_level + 1, 0xFF);
//pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, gl_portal_stencil_level + 1, 0xFF);// TEST
//pglStencilOpSeparate(GL_FRONT_AND_BACK, GL_KEEP, GL_DECR, GL_DECR);
//pglStencilOpSeparate(GL_FRONT_AND_BACK, GL_KEEP, GL_KEEP, GL_KEEP);// TEST
pglPushMatrix();
pglLoadIdentity();
pglScalef(1.0f, 1.0f, -1.0f);
// glMatrixMode(GL_PROJECTION
pglColor4ubv(white);
pglVertexPointer(3, GL_FLOAT, 0, screenVerts);
pglDrawArrays(GL_TRIANGLE_FAN, 0, 4);
pglPopMatrix();
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
pglEnable(GL_TEXTURE_2D);
pglEnable(GL_DEPTH_TEST);
pglEnable(GL_BLEND);
pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
static GLSkyVBO sky_vbo;
static void gld_BuildSky(int row_count, int col_count)
@@ -2670,6 +2745,86 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value)
case HWD_SET_SCREEN_TEXTURES:
gl_enable_screen_textures = Value;
break;
case HWD_SET_DEPTH_ONLY_MODE:// for portals
if (Value)
{
pglClear(GL_DEPTH_BUFFER_BIT);
pglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
}
else
{
pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
}
break;
case HWD_SET_PORTAL_MODE:
gl_portal_mode = Value;
switch (Value)
{
case HWD_PORTAL_NORMAL:
// regular drawing, only to current level of stencil
pglEnable(GL_TEXTURE_2D);
pglEnable(GL_DEPTH_TEST);
pglEnable(GL_BLEND);
pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_EQUAL, gl_portal_stencil_level, 0xFF);
//pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_GEQUAL, 0, 0xFF);
pglStencilOpSeparate(GL_FRONT_AND_BACK, GL_KEEP, GL_KEEP, GL_KEEP);
pglDepthMask(GL_TRUE);
break;
case HWD_PORTAL_STENCIL_SEGS:
// draw only to stencil, only to current level of stencil, incrementing when drawing
pglDisable(GL_TEXTURE_2D);
pglDisable(GL_DEPTH_TEST);
pglDisable(GL_BLEND);
pglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_EQUAL, gl_portal_stencil_level, 0xFF);
pglStencilOpSeparate(GL_FRONT_AND_BACK, GL_KEEP, GL_INCR, GL_INCR);// dont think z-buffer is used at this point
pglDepthMask(GL_FALSE);
break;
case HWD_PORTAL_STENCIL_REVERSE_SEGS:
// draw only to stencil, only to current level of stencil, incrementing when drawing
pglDisable(GL_TEXTURE_2D);
pglDisable(GL_DEPTH_TEST);
pglDisable(GL_BLEND);
pglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_EQUAL, gl_portal_stencil_level+1, 0xFF);
pglStencilOpSeparate(GL_FRONT_AND_BACK, GL_KEEP, GL_DECR, GL_DECR);// dont think z-buffer is used at this point
pglDepthMask(GL_FALSE);
break;
case HWD_PORTAL_DEPTH_SEGS:
// draw only to depth, only to current level of stencil
// also revert last stencil buffer write at this point
//RevertStencilBuffer();
pglDisable(GL_TEXTURE_2D);
pglEnable(GL_DEPTH_TEST);
pglDisable(GL_BLEND);
pglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_EQUAL, gl_portal_stencil_level, 0xFF);
pglStencilOpSeparate(GL_FRONT_AND_BACK, GL_KEEP, GL_KEEP, GL_KEEP);
pglDepthMask(GL_TRUE);
break;
case HWD_PORTAL_SKY_STENCIL_SEGS:
// draw only to stencil, only to current level of stencil, incrementing when drawing
// same as HWD_PORTAL_STENCIL_SEGS except depth testing is enabled
// this is used to mark all visible skywall pixels to the stencil buffer
pglDisable(GL_TEXTURE_2D);
pglEnable(GL_DEPTH_TEST);
pglDisable(GL_BLEND);
pglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
pglStencilFuncSeparate(GL_FRONT_AND_BACK, GL_EQUAL, gl_portal_stencil_level, 0xFF);
pglStencilOpSeparate(GL_FRONT_AND_BACK, GL_KEEP, GL_KEEP, GL_INCR);
pglDepthMask(GL_TRUE);// not sure about this and does it matter
break;
default:
I_Error("Bad value in HWD_SET_PORTAL_MODE");
}
break;
case HWD_SET_STENCIL_LEVEL:
gl_portal_stencil_level = Value;
break;
default:
break;
@@ -2900,8 +3055,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float
rollradian = 0;
if (pos->rollmodel == true)
rollradian = (pos->rollangle)*radians;
rollradian = (pos->rollangle)*radians;
// Affect input model scaling
@@ -3008,7 +3162,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, float duration, float
pglRotatef(pos->anglex, -1.0f, 0.0f, 0.0f);
pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f);
if (pos->roll && (pos->rollmodel == true))
if (pos->roll)
{
float roll = (1.0f * pos->rollflip);
pglTranslatef(pos->centerx, pos->centery, 0);
@@ -3620,7 +3774,7 @@ EXPORT void HWRAPI(DrawScreenFinalTexture)(int width, int height)
clearColour.red = clearColour.green = clearColour.blue = 0;
clearColour.alpha = 1;
ClearBuffer(true, false, &clearColour);
ClearBuffer(true, false, false, &clearColour);
pglBindTexture(GL_TEXTURE_2D, finalScreenTexture);
pglColor4ubv(white);
+20 -18
View File
@@ -1335,18 +1335,20 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
{IT_STRING | IT_CVAR, NULL, "3D Models", &cv_grmdls, 10},
{IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_grfallbackplayermodel, 20},
{IT_STRING|IT_CVAR, NULL, "Shaders", &cv_grshaders, 30},
{IT_STRING|IT_CVAR, NULL, "Use custom Shaders", &cv_grusecustomshaders, 40},
{IT_STRING|IT_CVAR, NULL, "Texture Quality", &cv_scr_depth, 50},
{IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 60},
{IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 70},
{IT_STRING|IT_CVAR, NULL, "Texture Quality", &cv_scr_depth, 60},
{IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 70},
{IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode, 80},
{IT_STRING|IT_CVAR, NULL, "Visual Portals", &cv_grportals, 90},
{IT_STRING|IT_CVAR, NULL, "Wall Contrast Style", &cv_grfakecontrast, 90},
{IT_STRING|IT_CVAR, NULL, "Sprite Billboarding", &cv_grspritebillboarding, 100},
{IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 110},
{IT_STRING|IT_CVAR, NULL, "Wall Contrast Style", &cv_grfakecontrast, 100},
{IT_STRING|IT_CVAR, NULL, "Sprite Billboarding", &cv_grspritebillboarding, 110},
{IT_STRING|IT_CVAR, NULL, "Software Perspective", &cv_grshearing, 120},
{IT_STRING|IT_CVAR, NULL, "Rendering Distance", &cv_grrenderdistance, 130},
{IT_STRING|IT_CVAR, NULL, "Rendering Distance", &cv_grrenderdistance, 140},
{IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 150},
{IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 160},
};
static menuitem_t OP_OpenGLColorMenu[] =
@@ -1521,7 +1523,7 @@ static menuitem_t OP_HUDOptionsMenu[] =
{IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 135},
{IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 145},
{IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 155},
};
@@ -9215,7 +9217,7 @@ static void M_HandleMasterServerResetChoice(event_t *ev)
CV_Set(&cv_masterserver_nagattempts, cv_masterserver_nagattempts.defaultvalue);
S_StartSound(NULL, sfx_s221);
}
else
else
{
if (firstDismissedNagThisBoot)
{
@@ -9377,7 +9379,7 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
trans = G_GetGametypeColor(cv_newgametype.value);
V_DrawFill(x-1, y-1, w+2, i+2, trans); // variable reuse...
if (cv_nextmap.value && cv_showtrackaddon.value)
{
char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename;
@@ -9631,7 +9633,7 @@ Update the maxplayers label...
if (itemOn == 2 && i == setupm_pselect)
{
static fixed_t cursorframe = 0;
cursorframe += renderdeltatics / 4;
for (; cursorframe > 7 * FRACUNIT; cursorframe -= 7 * FRACUNIT) {}
@@ -9927,7 +9929,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
#undef GETSELECTEDSKINNAME
break;
case SKINMENUTYPE_2D:
skintodisplay = setupm_fakeskin;
if (setupm_skinlockedselect) //show the skin we are trying to select
skintodisplay = skinstats[setupm_skinxpos][setupm_skinypos][setupm_skinselect];
@@ -10037,7 +10039,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
#define DRAWACCEL(x, y) V_DrawThinString((x), (y), V_6WIDTHSPACE | highlightflags, "Turn")
#define DRAWHEAVY(x, y) V_DrawThinString((x), (y), V_6WIDTHSPACE | highlightflags, "Heavy")
#define TEXTVERTSHIFT 10
DRAWSLOW(statx - sltw - 2, staty);
DRAWSLOW(statx - sltw - 2, staty - TEXTVERTSHIFT+ (9 * 18) - 11);
DRAWFAST(statx + (9 * 18), staty);
@@ -10122,7 +10124,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
else
{
UINT8 cursorframe = (I_GetTime() / 4) % 7;
cursor = W_CachePatchName(va("K_CHILI%d", cursorframe + 1), PU_CACHE);
V_DrawFixedPatch((curx << FRACBITS) - (FRACUNIT), (cury << FRACBITS) - (FRACUNIT), FRACUNIT+(FRACUNIT>>3), 0, cursor, NULL);
}
@@ -10302,7 +10304,7 @@ static void M_DrawSetupMultiPlayerMenu(void)
}
// skin 0 is default player sprite
switch (cv_skinselectmenu.value)
{
case SKINMENUTYPE_2D:
@@ -10429,7 +10431,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
case KEY_UPARROW:
if (cv_skinselectmenu.value == SKINMENUTYPE_2D)
{
{
BREAKWHENLOCKED
if (itemOn == 1 && setupm_skinypos > 0)
setupm_skinypos--;
@@ -10476,7 +10478,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
case KEY_LEFTARROW:
if (cv_skinselectmenu.value == SKINMENUTYPE_2D && itemOn == 1)
{
{
if (setupm_skinlockedselect)
{
if (setupm_skinselect > 0)
+8 -9
View File
@@ -3143,8 +3143,15 @@ boolean P_SetupLevel(boolean skipprecip)
P_SpawnPrecipitation();
#ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode != render_soft && rendermode != render_none)
if (rendermode == render_opengl)
{
// Lactozilla (December 8, 2019)
// Level setup used to free EVERY mipmap from memory.
// Even mipmaps that aren't related to level textures.
// Presumably, the hardware render code used to store textures as level data.
// Meaning, they had memory allocated and marked with the PU_LEVEL tag.
// Level textures are only reloaded after R_LoadTextures, which is
// when the texture list is loaded.
// Correct missing sidedefs & deep water trick
HWR_CorrectSWTricks();
HWR_CreatePlanePolygons((INT32)numnodes - 1);
@@ -3358,14 +3365,6 @@ boolean P_SetupLevel(boolean skipprecip)
// Fab : 19-07-98 : start cd music for this level (note: can be remapped)
I_PlayCD((UINT8)(gamemap), false);
// preload graphics
#ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode != render_soft && rendermode != render_none)
{
HWR_PrepLevelCache(numtextures);
}
#endif
P_MapEnd();
// Remove the loading shit from the screen
+9 -1
View File
@@ -30,6 +30,10 @@
#include <malloc.h> // alloca(sizeof)
#endif
#ifdef HWRENDER
#include "hardware/hw_main.h" // HWR_LoadTextures
#endif
#if defined(_MSC_VER)
#pragma pack(1)
#endif
@@ -531,7 +535,11 @@ void R_LoadTextures(void)
textureheight[i] = texture->height << FRACBITS;
i++;
}
}
}
#ifdef HWRENDER
if (rendermode == render_opengl)
HWR_LoadTextures(numtextures);
#endif
}
static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
+1
View File
@@ -1899,6 +1899,7 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_grfakecontrast);
CV_RegisterVar(&cv_grshearing);
CV_RegisterVar(&cv_grshaders);
CV_RegisterVar(&cv_grusecustomshaders);
#endif
#ifdef HWRENDER
+5
View File
@@ -1772,6 +1772,11 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
flags |= SDL_WINDOW_OPENGL;
#endif
// request stencil buffer. If there are problems on weaker hw the bit count could be reduced
// If only something like 1-bit or 2-bit stencil is available on some gpus then should implement limit for maxportals based on that.
// 4 bits would be enough for current limit in maxportals (12)
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 4);
// Create a window
window = SDL_CreateWindow("SRB2Kart "VERSIONSTRING, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
realwidth, realheight, flags);
+1 -1
View File
@@ -198,7 +198,7 @@ boolean OglSdlSurface(INT32 w, INT32 h)
SetModelView(w, h);
SetStates();
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
HWR_Startup();
textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1;