Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • STJr/SRB2
  • Sryder/SRB2
  • wolfy852/SRB2
  • Alpha2244/SRB2
  • Inuyasha/SRB2
  • yoshibot/SRB2
  • TehRealSalt/SRB2
  • PrisimaTF/SRB2
  • Hatninja/SRB2
  • SteelT/SRB2
  • james/SRB2
  • ShaderWraith/SRB2
  • SinnamonLat/SRB2
  • mazmazz_/SRB2
  • filpAM/SRB2
  • chaoloveicemdboy/SRB2
  • Whooa21/SRB2
  • Machturne/SRB2
  • Golden/SRB2
  • Tatsuru/SRB2
  • Snu/SRB2
  • Zwip-Zwap_Zapony/SRB2
  • fickleheart/SRB2
  • alphaRexJames/SRB2
  • JJK/SRB2
  • diskpoppy/SRB2
  • Hannu_Hanhi/SRB2
  • ZipperQR/SRB2
  • kays/SRB2
  • spherallic/SRB2
  • Zippy_Zolton/SRB2
  • namiishere/SRB2
  • Ors/SRB2
  • SMS_Alfredo/SRB2
  • sonic_edge/SRB2
  • lavla/SRB2
  • ashi/SRB2
  • X.organic/SRB2
  • Fafabis/SRB2
  • Meziu/SRB2
  • v-rob/SRB2
  • tertu/SRB2
  • bitten2up/SRB2
  • flarn2006/SRB2
  • Krabs/SRB2
  • clairebun/SRB2
  • Lactozilla/SRB2
  • thehackstack/SRB2
  • Spice/SRB2
  • win8linux/SRB2
  • JohnFrostFox/SRB2
  • talktoneon726/SRB2
  • Wane/SRB2
  • Lamibe/SRB2
  • spectrumuk2/srb-2
  • nerdyminer18/srb-2
  • 256nil/SRB2
  • ARJr/SRB2
  • Alam/SRB2
  • Zenya/srb-2-marathon-demos
  • Acelite/srb-2-archivedmodifications
  • MIDIMan/SRB2
  • Lach/SRB2
  • Frostiikin/bounce-tweaks
  • Jaden/SRB2
  • Tyron/SRB2
  • Astronight/SRB2
  • Mari0shi06/SRB2
  • aiire/SRB2
  • Galactice/SRB2
  • srb2-ports/srb2-dreamcast
  • sdasdas/SRB2
  • chreas/srb-2-vr
  • StarManiaKG/the-story-of-sinically-rocketing-and-botching-the-2nd
  • LoganAir/SRB2
  • NepDisk/srb-2
  • alufolie91/SRB2
  • Felicia.iso/SRB2
  • twi/SRB2
  • BarrelsOFun/SRB2
  • Speed2411/SRB2
  • Leather_Realms/SRB2
  • Ayemar/SRB2
  • Acelite/SRB2
  • VladDoc/SRB2
  • kaldrum/model-features
  • strawberryfox417/SRB2
  • Lugent/SRB2
  • Rem/SRB2
  • Refrag/SRB2
  • Henry_3230/srb-3230
  • TehPuertoRicanSpartan2/tprs-srb2
  • Leminn/srb-2-marathon-stuff
  • chromaticpipe2/SRB2
  • MiguelGustavo15/SRB2
  • Maru/srb-2-tests
  • SilicDev/SRB2
  • UnmatchedBracket/SRB2
  • HybridDog/SRB2
  • xordspar0/SRB2
  • jsjhbewfhh/SRB2
  • Fancy2209/SRB2
  • Lorsoen/SRB2
  • shindoukin/SRB2
  • GamerOfDays/SRB2
  • Craftyawesome/SRB2
  • tenshi-tensai-tennoji/SRB2
  • Scarfdudebalder/SRB2
  • luigi-budd/srb-2-fix-interplag-lockon
  • mskluesner/SRB2
  • johnpetersa19/SRB2
  • Pheazant/SRB2
  • chromaticpipe2/srb2classic
  • romoney5/SRB2
  • PAS/SRB2Classic
  • BlueStaggo/SRB2
  • Jisk/srb-2-beef-jerky
117 results
Select Git revision
Show changes
Commits on Source (1)
......@@ -17,6 +17,7 @@
#define ZCLIP_PLANE 4.0f // Used for the actual game drawing
#define NZCLIP_PLANE 0.9f // Seems to be only used for the HUD and screen textures
#define FAR_ZCLIP_DEFAULT 32768.0f
// The width/height/depth of the palette lookup table used by palette rendering.
// Changing this also requires changing the shader code!
......
......@@ -41,7 +41,7 @@ EXPORT void HWRAPI(SetTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(UpdateTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(DeleteTexture) (GLMipmap_t *TexInfo);
EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip);
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip);
EXPORT void HWRAPI(ClearMipMapCache) (void);
EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
......
......@@ -102,6 +102,15 @@ boolean gl_shadersavailable = false;
// Whether the internal state is set to palette rendering or not.
static boolean gl_palette_rendering_state = false;
// values for the far clipping plane
static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f};
// values for bsp culling
// slightly higher than the far clipping plane to compensate for impreciseness
static INT32 bsp_culling_distances[] = {(1024+512)*FRACUNIT, (2048+512)*FRACUNIT, (4096+512)*FRACUNIT,
(6144+512)*FRACUNIT, (8192+512)*FRACUNIT, (12288+512)*FRACUNIT, (16384+512)*FRACUNIT};
static INT32 current_bsp_culling_distance = 0;
// --------------------------------------------------------------------------
// STUFF FOR THE PROJECTION CODE
// --------------------------------------------------------------------------
......@@ -2110,6 +2119,70 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord)
px2 = bspcoord[checkcoord[boxpos][2]];
py2 = bspcoord[checkcoord[boxpos][3]];
if (current_bsp_culling_distance)
{
//fixed_t midx = (px1 >> 1) + (px2 >> 1);
//fixed_t midy = (py1 >> 1) + (py2 >> 1);
//fixed_t mindist = min(min(R_PointToDist(px1, py1), R_PointToDist(px2, py2)), R_PointToDist(midx, midy));
//fixed_t mindist = ClosestPointOnLineDistance(px1, py1, px2, py2);
//fixed_t mindist1 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXTOP], bspcoord[BOXRIGHT], bspcoord[BOXTOP]); // top line
//fixed_t mindist2 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXTOP], bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]); // left line
//fixed_t mindist3 = ClosestPointOnLineDistance(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM], bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); // bottom line
//fixed_t mindist4 = ClosestPointOnLineDistance(bspcoord[BOXRIGHT], bspcoord[BOXTOP], bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]); // right line
// this one seems too lax.. maybe closestpointonlinedistance is glitchy and returns points that are not on the line segment?
// could try building an if-else structure that determines what point or line is closest
// 1 | 2 | 3
//--------------
// 4 |node| 5
//--------------
// 6 | 7 | 8
// y
// ^
// |
// -----> x
// inside node: always inside draw distance. the above boxpos thing might have returned true already?
// 1. check top left corner 2. check top line 3. check top right corner
// 4. check left line 5. check right line
// 6. check bottom left corner 7. check bottom line 8. check bottom right corner
// one if statement will split the space in two for one coordinate
// for example:
// x < BOXLEFT || BOXLEFT || !(x < BOXLEFT) <-- (same as x >= BOXLEFT)
fixed_t mindist;// = min(min(mindist1, mindist2), min(mindist3, mindist4));
// new thing
// calculate distance to axis aligned bounding box.
if (viewx < bspcoord[BOXLEFT]) // 1,4,6
{
if (viewy > bspcoord[BOXTOP]) // 1
mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXTOP]);
else if (viewy < bspcoord[BOXBOTTOM]) // 6
mindist = R_PointToDist(bspcoord[BOXLEFT], bspcoord[BOXBOTTOM]);
else // 4
mindist = bspcoord[BOXLEFT] - viewx;
}
else if (viewx > bspcoord[BOXRIGHT]) // 3,5,8
{
if (viewy > bspcoord[BOXTOP]) // 3
mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXTOP]);
else if (viewy < bspcoord[BOXBOTTOM]) // 8
mindist = R_PointToDist(bspcoord[BOXRIGHT], bspcoord[BOXBOTTOM]);
else // 5
mindist = viewx - bspcoord[BOXRIGHT];
}
else // 2,node,7
{
if (viewy > bspcoord[BOXTOP]) // 2
mindist = viewy - bspcoord[BOXTOP];
else if (viewy < bspcoord[BOXBOTTOM]) // 7
mindist = bspcoord[BOXBOTTOM] - viewy;
else // node
mindist = 0;
}
if (mindist > current_bsp_culling_distance) return false;
}
angle1 = R_PointToAngle64(px1, py1);
angle2 = R_PointToAngle64(px2, py2);
return gld_clipper_SafeCheckRange(angle2, angle1);
......@@ -4242,7 +4315,7 @@ static void HWR_AddSprites(sector_t *sec)
{
mobj_t *thing;
precipmobj_t *precipthing;
fixed_t limit_dist, hoop_limit_dist;
fixed_t limit_dist, hoop_limit_dist, precip_limit_dist;
// BSP is traversed by subsector.
// A sector might have been split into several
......@@ -4254,13 +4327,28 @@ static void HWR_AddSprites(sector_t *sec)
// Well, now it will be done.
sec->validcount = validcount;
if (current_bsp_culling_distance)
{
// Use the smaller setting
if (cv_drawdist.value)
limit_dist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) << FRACBITS);
else
limit_dist = (fixed_t)current_bsp_culling_distance;
precip_limit_dist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) << FRACBITS);
hoop_limit_dist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_nights.value) << FRACBITS);
}
else
{
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
precip_limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS;
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
}
// sprite lighting
sectorlight = sec->lightlevel & 0xff;
// Handle all things in sector.
// If a limit exists, handle things a tiny bit different.
limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS;
hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS;
// If a limit exists, handle things a tiny bit different
for (thing = sec->thinglist; thing; thing = thing->snext)
{
if (R_ThingWithinDist(thing, limit_dist, hoop_limit_dist))
......@@ -4275,11 +4363,11 @@ static void HWR_AddSprites(sector_t *sec)
}
// no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS))
if (precip_limit_dist)
{
for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext)
{
if (R_PrecipThingVisible(precipthing, limit_dist))
if (R_PrecipThingVisible(precipthing, precip_limit_dist))
HWR_ProjectPrecipitationSprite(precipthing);
}
}
......@@ -5244,7 +5332,7 @@ static inline void HWR_ClearView(void)
(INT32)viewwindowy,
(INT32)(viewwindowx + viewwidth),
(INT32)(viewwindowy + viewheight),
ZCLIP_PLANE);
ZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
HWD.pfnClearBuffer(false, true, 0);
//disable clip window - set to full size
......@@ -5322,6 +5410,18 @@ static void HWR_SetupView(player_t *player, INT32 viewnumber, float fpov, boolea
else
R_SetupFrame(player);
current_bsp_culling_distance = 0;
if (!skybox && cv_glrenderdistance.value)
{
HWD.pfnGClipRect((INT32)viewwindowx,
(INT32)viewwindowy,
(INT32)(viewwindowx + viewwidth),
(INT32)(viewwindowy + viewheight),
ZCLIP_PLANE, clipping_distances[cv_glrenderdistance.value - 1]);
current_bsp_culling_distance = bsp_culling_distances[cv_glrenderdistance.value - 1];
}
gl_viewx = FixedToFloat(viewx);
gl_viewy = FixedToFloat(viewy);
gl_viewz = FixedToFloat(viewz);
......@@ -5417,6 +5517,8 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
HWR_RenderBSPNode((INT32)numnodes-1);
current_bsp_culling_distance = 0;
if (cv_glbatching.value)
HWR_RenderBatches();
......@@ -5454,7 +5556,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
// added by Hurdler for correct splitscreen
// moved here by hurdler so it works with the new near clipping plane
HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE);
HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
}
// ==========================================================================
......@@ -5535,6 +5637,8 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
HWR_RenderBSPNode((INT32)numnodes-1);
current_bsp_culling_distance = 0;
PS_STOP_TIMING(ps_bsptime);
if (cv_glbatching.value)
......@@ -5584,7 +5688,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
// added by Hurdler for correct splitscreen
// moved here by hurdler so it works with the new near clipping plane
HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE);
HWD.pfnGClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
}
// Returns whether palette rendering is "actually enabled."
......@@ -5678,6 +5782,9 @@ static CV_PossibleValue_t glfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA
{HWD_SET_TEXTUREFILTER_MIXED3, "Nearest_Mipmap"},
{0, NULL}};
CV_PossibleValue_t glanisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}};
static CV_PossibleValue_t glrenderdistance_cons_t[] = {
{0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"},
{6, "12288"}, {7, "16384"}, {0, NULL}};
consvar_t cv_glshaders = CVAR_INIT ("gr_shaders", "On", CV_SAVE|CV_CALL, glshaders_cons_t, CV_glshaders_OnChange);
......@@ -5705,6 +5812,8 @@ consvar_t cv_glsolvetjoin = CVAR_INIT ("gr_solvetjoin", "On", 0, CV_OnOff, NULL)
consvar_t cv_glbatching = CVAR_INIT ("gr_batching", "On", 0, CV_OnOff, NULL);
consvar_t cv_glrenderdistance = CVAR_INIT("gr_renderdistance", "Max", CV_SAVE, glrenderdistance_cons_t, NULL);
static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}};
consvar_t cv_glpaletterendering = CVAR_INIT ("gr_paletterendering", "On", CV_SAVE|CV_CALL, CV_OnOff, CV_glpaletterendering_OnChange);
......@@ -5788,6 +5897,8 @@ void HWR_AddCommands(void)
CV_RegisterVar(&cv_glsolvetjoin);
CV_RegisterVar(&cv_glbatching);
CV_RegisterVar(&cv_glrenderdistance);
CV_RegisterVar(&cv_glpaletterendering);
CV_RegisterVar(&cv_glpalettedepth);
......
......@@ -96,6 +96,7 @@ extern consvar_t cv_glslopecontrast;
extern consvar_t cv_glbatching;
extern consvar_t cv_glpaletterendering;
extern consvar_t cv_glpalettedepth;
extern consvar_t cv_glrenderdistance;
extern consvar_t cv_glwireframe;
......
......@@ -57,7 +57,9 @@ static GLuint NOTEXTURE_NUM = 0;
#define N_PI_DEMI (M_PIl/2.0f) //(1.5707963268f)
#define ASPECT_RATIO (1.0f) //(320.0f/200.0f)
#define FAR_CLIPPING_PLANE 32768.0f // Draw further! Tails 01-21-2001
//#define FAR_CLIPPING_PLANE 32768.0f // Draw further! Tails 01-21-2001
//#define FAR_CLIPPING_PLANE (4096.0f - 512.0f)
static float FAR_CLIPPING_PLANE = 32768.0f;
static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE;
// **************************************************************************
......@@ -1187,12 +1189,13 @@ EXPORT void HWRAPI(ReadScreenTexture) (int tex, UINT8 *dst_data)
// -----------------+
// GClipRect : Defines the 2D hardware clipping window
// -----------------+
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip)
EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip, float farclip)
{
// GL_DBG_Printf ("GClipRect(%d, %d, %d, %d)\n", minx, miny, maxx, maxy);
pglViewport(minx, screen_height-maxy, maxx-minx, maxy-miny);
NEAR_CLIPPING_PLANE = nearclip;
FAR_CLIPPING_PLANE = farclip;
//pglScissor(minx, screen_height-maxy, maxx-minx, maxy-miny);
pglMatrixMode(GL_PROJECTION);
......
......@@ -1416,11 +1416,12 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
{IT_STRING|IT_CVAR, NULL, "Bit depth", &cv_scr_depth, 124},
{IT_STRING|IT_CVAR, NULL, "Texture filter", &cv_glfiltermode, 134},
{IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_glanisotropicmode, 144},
{IT_STRING|IT_CVAR, NULL, "Render Distance", &cv_glrenderdistance, 154},
#ifdef ALAM_LIGHTING
{IT_SUBMENU|IT_STRING, NULL, "Lighting...", &OP_OpenGLLightingDef, 154},
{IT_SUBMENU|IT_STRING, NULL, "Lighting...", &OP_OpenGLLightingDef, 164},
#endif
#if defined (_WINDOWS) && (!(defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)))
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 164},
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 174},
#endif
};
......
......@@ -189,7 +189,7 @@ void OglSdlFinishUpdate(boolean waitvbl)
HWR_DrawScreenFinalTexture(sdlw, sdlh);
SDL_GL_SwapWindow(window);
GClipRect(0, 0, realwidth, realheight, NZCLIP_PLANE);
GClipRect(0, 0, realwidth, realheight, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
// Sryder: We need to draw the final screen texture again into the other buffer in the original position so that
// effects that want to take the old screen can do so after this
......