From 2ff4a3ca75495dd2632235abedc20ac111eb0d8d Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Tue, 30 Apr 2019 20:59:32 -0300 Subject: [PATCH] Match Kart-Public's next since it got merged anyway and fix something else --- src/doomdef.h | 6 ++- src/hardware/hw_bsp.c | 2 +- src/hardware/hw_dll.h | 3 -- src/hardware/r_opengl/r_opengl.c | 76 +++++++++++++++++--------------- src/r_plane.c | 2 +- 5 files changed, 48 insertions(+), 41 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 6289217b..485af878 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -428,13 +428,17 @@ INT32 I_GetKey(void); #define max(x, y) (((x) > (y)) ? (x) : (y)) #endif +#ifndef M_PIl +#define M_PIl 3.1415926535897932384626433832795029L +#endif + // Floating point comparison epsilons from float.h #ifndef FLT_EPSILON #define FLT_EPSILON 1.1920928955078125e-7f #endif #ifndef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 +#define DBL_EPSILON 2.2204460492503131e-16l #endif // An assert-type mechanism. diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 0f4cd1dd..3910da58 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -114,7 +114,7 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, // (do not accept hit with the extensions) num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; frac = num / den; - if (frac < 0.0 || frac > 1.0) + if (frac < 0.0l || frac > 1.0l) return NULL; // now get the frac along the BSP line diff --git a/src/hardware/hw_dll.h b/src/hardware/hw_dll.h index d97d334b..237b068e 100644 --- a/src/hardware/hw_dll.h +++ b/src/hardware/hw_dll.h @@ -59,9 +59,6 @@ // ========================================================================== // Constants -#ifndef M_PIl -#define M_PIl 3.1415926535897932384626433832795029L -#endif #define DEGREE (0.017453292519943295769236907684883l) // 2*PI/360 void GL_DBG_Printf(const char *format, ...) /*FUNCPRINTF*/; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 37c6c74a..63074899 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1894,6 +1894,10 @@ static void CreateModelVBO(mesh_t *mesh, mdlframe_t *frame) pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID); pglBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW); free(buffer); + + // Don't leave the array buffer bound to the model, + // since this is called mid-frame + pglBindBuffer(GL_ARRAY_BUFFER, 0); } static void CreateModelVBOTiny(mesh_t *mesh, tinyframe_t *frame) @@ -1935,6 +1939,10 @@ static void CreateModelVBOTiny(mesh_t *mesh, tinyframe_t *frame) pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID); pglBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW); free(buffer); + + // Don't leave the array buffer bound to the model, + // since this is called mid-frame + pglBindBuffer(GL_ARRAY_BUFFER, 0); } EXPORT void HWRAPI(CreateModelVBOs) (model_t *model) @@ -2181,10 +2189,13 @@ EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, EXPORT void HWRAPI(SetTransform) (FTransform *stransform, angle_t viewaiming) { static boolean special_splitscreen; + GLdouble used_fov; + boolean shearing = false; pglLoadIdentity(); if (stransform) { - boolean fovx90; + used_fov = stransform->fovxangle; + shearing = stransform->shearing; // keep a trace of the transformation for md2 memcpy(&md2_transform, stransform, sizeof (md2_transform)); @@ -2204,46 +2215,41 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform, angle_t viewaiming) pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglTranslatef(-stransform->x, -stransform->z, -stransform->y); - pglMatrixMode(GL_PROJECTION); - 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; - special_splitscreen = (stransform->splitscreen && fovx90); - if (special_splitscreen) - GLPerspective(53.13f, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5) - else - GLPerspective(stransform->fovxangle, ASPECT_RATIO); - pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) - pglMatrixMode(GL_MODELVIEW); + special_splitscreen = (stransform->splitscreen == 1); } else { + //Hurdler: is "fov" correct? + used_fov = fov; pglScalef(1.0f, 1.0f, -1.0f); - - pglMatrixMode(GL_PROJECTION); - pglLoadIdentity(); - if (special_splitscreen) - GLPerspective(53.13f, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5) - else - //Hurdler: is "fov" correct? - GLPerspective(fov, ASPECT_RATIO); - pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) - pglMatrixMode(GL_MODELVIEW); } + pglMatrixMode(GL_PROJECTION); + pglLoadIdentity(); + + // jimita 14042019 + // Simulate Software's y-shearing + // https://zdoom.org/wiki/Y-shearing + if (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); + } + + if (special_splitscreen) + { + used_fov = atan(tan(used_fov*M_PIl/360)*0.8)*360/M_PIl; + GLPerspective((GLfloat)used_fov, 2*ASPECT_RATIO); + } + else + GLPerspective((GLfloat)used_fov, ASPECT_RATIO); + pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) + pglMatrixMode(GL_MODELVIEW); + pglGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer) } diff --git a/src/r_plane.c b/src/r_plane.c index 5cb53a53..ab111f86 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -973,7 +973,7 @@ void R_DrawSinglePlane(visplane_t *pl) temp = P_GetZAt(pl->slope, pl->viewx, pl->viewy); zeroheight = FIXED_TO_FLOAT(temp); -#define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180) +#define ANG2RAD(angle) ((float)((angle)*M_PIl)/ANGLE_180) // p is the texture origin in view space // Don't add in the offsets at this stage, because doing so can result in