More Softwarification

This commit is contained in:
Jaime Passos 2019-04-14 19:08:59 -03:00
parent a8165a2ce9
commit d1b1edcf39
10 changed files with 45 additions and 21 deletions

View file

@ -320,12 +320,12 @@ void gld_clipper_Clear(void)
#define RMUL (1.6f/1.333333f) #define RMUL (1.6f/1.333333f)
angle_t gld_FrustumAngle(void) angle_t gld_FrustumAngle(angle_t tiltangle)
{ {
double floatangle; double floatangle;
angle_t a1; angle_t a1;
float tilt = (float)fabs(((double)(int)aimingangle) / ANG1); float tilt = (float)fabs(((double)(int)tiltangle) / ANG1);
// NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function
@ -334,12 +334,10 @@ angle_t gld_FrustumAngle(void)
float render_multiplier = 64.0f / render_fovratio / RMUL; float render_multiplier = 64.0f / render_fovratio / RMUL;
if (tilt > 90.0f) if (tilt > 90.0f)
{
tilt = 90.0f; tilt = 90.0f;
}
// If the pitch is larger than this you can look all around at a FOV of 90 // If the pitch is larger than this you can look all around at a FOV of 90
if (abs((signed)aimingangle) > 46 * ANG1) if (abs((signed)tiltangle) > 46 * ANG1)
return 0xffffffff; return 0xffffffff;
// ok, this is a gross hack that barely works... // ok, this is a gross hack that barely works...

View file

@ -17,7 +17,7 @@
boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle); boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle);
void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle);
void gld_clipper_Clear(void); void gld_clipper_Clear(void);
angle_t gld_FrustumAngle(void); angle_t gld_FrustumAngle(angle_t tiltangle);
#ifdef HAVE_SPHEREFRUSTRUM #ifdef HAVE_SPHEREFRUSTRUM
void gld_FrustrumSetup(void); void gld_FrustrumSetup(void);
boolean gld_SphereInFrustum(float x, float y, float z, float radius); boolean gld_SphereInFrustum(float x, float y, float z, float radius);

View file

@ -157,6 +157,7 @@ typedef struct
#ifdef USE_FTRANSFORM_MIRROR #ifdef USE_FTRANSFORM_MIRROR
boolean mirror; // SRB2Kart: Encore Mode boolean mirror; // SRB2Kart: Encore Mode
#endif #endif
boolean shearing; // 14042019
} FTransform; } FTransform;
// Transformed vector, as passed to HWR API // Transformed vector, as passed to HWR API

View file

@ -48,7 +48,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
//Hurdler: added for new development //Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface); EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model); EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
EXPORT void HWRAPI(SetTransform) (FTransform *ptransform); EXPORT void HWRAPI(SetTransform) (FTransform *ptransform, angle_t viewaiming);
EXPORT INT32 HWRAPI(GetTextureUsed) (void); EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT void HWRAPI(FlushScreenTextures) (void); EXPORT void HWRAPI(FlushScreenTextures) (void);

View file

@ -118,6 +118,7 @@ FTransform atransform;
// Float variants of viewx, viewy, viewz, etc. // Float variants of viewx, viewy, viewz, etc.
static float gr_viewx, gr_viewy, gr_viewz; static float gr_viewx, gr_viewy, gr_viewz;
static float gr_viewsin, gr_viewcos; static float gr_viewsin, gr_viewcos;
static angle_t gr_aimingangle;
static INT32 drawcount = 0; static INT32 drawcount = 0;
@ -3843,9 +3844,10 @@ void HWR_RenderDrawNodes(void)
} //i++ } //i++
} // loop++ } // loop++
HWD.pfnSetTransform(&atransform);
HWD.pfnSetShader(0);
// Okay! Let's draw it all! Woo! // Okay! Let's draw it all! Woo!
HWD.pfnSetTransform(&atransform, aimingangle);
HWD.pfnSetShader(0);
for (i = 0; i < p; i++) for (i = 0; i < p; i++)
{ {
if (sortnode[sortindex[i]].plane) if (sortnode[sortindex[i]].plane)
@ -4464,7 +4466,19 @@ static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
atransform.scaley = (float)vid.width/vid.height; atransform.scaley = (float)vid.width/vid.height;
atransform.scalez = 1; atransform.scalez = 1;
atransform.anglex = (float)(aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); // 14042019
if (!cv_grshearing.value)
{
gr_aimingangle = aimingangle;
atransform.shearing = false;
}
else
{
gr_aimingangle = 0;
atransform.shearing = true;
}
atransform.anglex = (float)(gr_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES);
atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES);
atransform.fovxangle = fpov; // Tails atransform.fovxangle = fpov; // Tails
@ -4492,7 +4506,7 @@ static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
if (skybox) if (skybox)
drewsky = true; drewsky = true;
a1 = gld_FrustumAngle(); a1 = gld_FrustumAngle(gr_aimingangle);
gld_clipper_Clear(); gld_clipper_Clear();
gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1);
#ifdef HAVE_SPHEREFRUSTRUM #ifdef HAVE_SPHEREFRUSTRUM
@ -4500,7 +4514,7 @@ static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
#endif #endif
// Set transform and shader // Set transform and shader
HWD.pfnSetTransform(&atransform); HWD.pfnSetTransform(&atransform, aimingangle);
HWD.pfnSetShader(0); HWD.pfnSetShader(0);
// Check for shaders // Check for shaders
@ -4529,7 +4543,7 @@ static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
HWR_RenderDrawNodes(); HWR_RenderDrawNodes();
// Unset transform and shader // Unset transform and shader
HWD.pfnSetTransform(NULL); HWD.pfnSetTransform(NULL, 0.0f);
HWD.pfnUnSetShader(); HWD.pfnUnSetShader();
// Disable fog // Disable fog

View file

@ -127,6 +127,7 @@ void HWR_CorrectSWTricks(void);
// Console variables // Console variables
extern consvar_t cv_grshaders; extern consvar_t cv_grshaders;
extern consvar_t cv_grshearing;
extern consvar_t cv_grfov; extern consvar_t cv_grfov;
extern consvar_t cv_grmd2; extern consvar_t cv_grmd2;
extern consvar_t cv_grfog; extern consvar_t cv_grfog;

View file

@ -185,8 +185,6 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...)
#define pglEnable glEnable #define pglEnable glEnable
#define pglDisable glDisable #define pglDisable glDisable
#define pglGetFloatv glGetFloatv #define pglGetFloatv glGetFloatv
//glGetIntegerv
//glGetString
/* Depth Buffer */ /* Depth Buffer */
#define pglClearDepth glClearDepth #define pglClearDepth glClearDepth
@ -253,7 +251,6 @@ FUNCPRINTF void GL_DBG_Printf(const char *format, ...)
/* Miscellaneous */ /* Miscellaneous */
typedef void (APIENTRY * PFNglClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); typedef void (APIENTRY * PFNglClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
static PFNglClearColor pglClearColor; static PFNglClearColor pglClearColor;
//glClear
typedef void (APIENTRY * PFNglColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); typedef void (APIENTRY * PFNglColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
static PFNglColorMask pglColorMask; static PFNglColorMask pglColorMask;
typedef void (APIENTRY * PFNglAlphaFunc) (GLenum func, GLclampf ref); typedef void (APIENTRY * PFNglAlphaFunc) (GLenum func, GLclampf ref);
@ -272,8 +269,6 @@ typedef void (APIENTRY * PFNglDisable) (GLenum cap);
static PFNglDisable pglDisable; static PFNglDisable pglDisable;
typedef void (APIENTRY * PFNglGetFloatv) (GLenum pname, GLfloat *params); typedef void (APIENTRY * PFNglGetFloatv) (GLenum pname, GLfloat *params);
static PFNglGetFloatv pglGetFloatv; static PFNglGetFloatv pglGetFloatv;
//glGetIntegerv
//glGetString
/* Depth Buffer */ /* Depth Buffer */
typedef void (APIENTRY * PFNglClearDepth) (GLclampd depth); typedef void (APIENTRY * PFNglClearDepth) (GLclampd depth);
@ -2183,7 +2178,7 @@ EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration,
// -----------------+ // -----------------+
// SetTransform : // SetTransform :
// -----------------+ // -----------------+
EXPORT void HWRAPI(SetTransform) (FTransform *stransform) EXPORT void HWRAPI(SetTransform) (FTransform *stransform, angle_t viewaiming)
{ {
static boolean special_splitscreen; static boolean special_splitscreen;
pglLoadIdentity(); pglLoadIdentity();
@ -2204,12 +2199,27 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
else else
pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez); pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez);
pglMatrixMode(GL_MODELVIEW);
pglRotatef(stransform->anglex, 1.0f, 0.0f, 0.0f); pglRotatef(stransform->anglex, 1.0f, 0.0f, 0.0f);
pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f);
pglTranslatef(-stransform->x, -stransform->z, -stransform->y); pglTranslatef(-stransform->x, -stransform->z, -stransform->y);
pglMatrixMode(GL_PROJECTION); pglMatrixMode(GL_PROJECTION);
pglLoadIdentity(); pglLoadIdentity();
// jimita 14042019
// Simulate Software's y-shearing
// https://zdoom.org/wiki/Y-shearing
if (stransform->shearing)
{
float tilt = (float)(viewaiming>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES);
if (tilt >= 270.0f)
tilt = -(90.0f - (tilt - 270.0f));
tilt /= 24.0f; // ?????????
pglTranslatef(0.0f, -tilt, 0.0f);
}
fovx90 = stransform->fovxangle > 0.0f && fabsf(stransform->fovxangle - 90.0f) < 0.5f; fovx90 = stransform->fovxangle > 0.0f && fabsf(stransform->fovxangle - 90.0f) < 0.5f;
special_splitscreen = (stransform->splitscreen && fovx90); special_splitscreen = (stransform->splitscreen && fovx90);
if (special_splitscreen) if (special_splitscreen)

View file

@ -71,7 +71,6 @@ boolean SetupGLfunc(void);
void SetupGLFunc4(void); void SetupGLFunc4(void);
void Flush(void); void Flush(void);
INT32 isExtAvailable(const char *extension, const GLubyte *start); INT32 isExtAvailable(const char *extension, const GLubyte *start);
int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepthBits);
void SetModelView(GLint w, GLint h); void SetModelView(GLint w, GLint h);
void SetStates(void); void SetStates(void);
#ifdef USE_PALETTED_TEXTURE #ifdef USE_PALETTED_TEXTURE

View file

@ -1395,6 +1395,7 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_grsoftwarefog); CV_RegisterVar(&cv_grsoftwarefog);
CV_RegisterVar(&cv_grfogdensity); CV_RegisterVar(&cv_grfogdensity);
CV_RegisterVar(&cv_grmd2); CV_RegisterVar(&cv_grmd2);
CV_RegisterVar(&cv_grshearing);
CV_RegisterVar(&cv_grshaders); CV_RegisterVar(&cv_grshaders);
#endif #endif

View file

@ -72,9 +72,9 @@ consvar_t cv_grgammagreen = {"gr_gammagreen", "127", CV_SAVE|CV_CALL, grgamma_co
consvar_t cv_grgammablue = {"gr_gammablue", "127", CV_SAVE|CV_CALL, grgamma_cons_t, consvar_t cv_grgammablue = {"gr_gammablue", "127", CV_SAVE|CV_CALL, grgamma_cons_t,
CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL}; CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grshearing = {"gr_shearing", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}}; static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}};
// console variables in development
consvar_t cv_grmd2 = {"gr_md2", "Off", CV_SAVE, CV_MD2, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmd2 = {"gr_md2", "Off", CV_SAVE, CV_MD2, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif #endif