Adjust projection matrix depending on SCISDIST

git-svn-id: https://svn.eduke32.com/eduke32@7432 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-03-19 17:09:59 +00:00 committed by Christoph Oelckers
parent 42363fd73a
commit dba335c7dd

View file

@ -279,7 +279,7 @@ void gltexapplyprops(void)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
float glox1, gloy1, glox2, gloy2; float glox1, gloy1, glox2, gloy2, gloyxscale, gloxyaspect;
//Use this for both initialization and uninitialization of OpenGL. //Use this for both initialization and uninitialization of OpenGL.
static int32_t gltexcacnum = -1; static int32_t gltexcacnum = -1;
@ -1301,7 +1301,7 @@ static void resizeglcheck(void)
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
#endif #endif
if ((glox1 != windowxy1.x) || (gloy1 != windowxy1.y) || (glox2 != windowxy2.x) || (gloy2 != windowxy2.y)) if ((glox1 != windowxy1.x) || (gloy1 != windowxy1.y) || (glox2 != windowxy2.x) || (gloy2 != windowxy2.y) || (gloxyaspect != gxyaspect) || (gloyxscale != gyxscale))
{ {
const int32_t ourxdimen = (windowxy2.x-windowxy1.x+1); const int32_t ourxdimen = (windowxy2.x-windowxy1.x+1);
float ratio = get_projhack_ratio(); float ratio = get_projhack_ratio();
@ -1320,11 +1320,17 @@ static void resizeglcheck(void)
float m[4][4]; float m[4][4];
Bmemset(m,0,sizeof(m)); Bmemset(m,0,sizeof(m));
float const nearclip = SCISDIST / (gxyaspect * gyxscale * 1024.f);
float const farclip = 64.f;
m[0][0] = fydimen * ratio; m[0][2] = 1.f; gloxyaspect = gxyaspect;
m[1][1] = fxdimen; m[1][2] = 1.f; gloyxscale = gyxscale;
m[2][2] = 1.f; m[2][3] = fydimen * ratio;
m[3][2] =-1.f; m[0][0] = 1.f;
m[1][1] = fxdimen / (fydimen * ratio);
m[2][2] = (farclip + nearclip) / (farclip - nearclip);
m[2][3] = 1.f;
m[3][2] = -(2.f * farclip * nearclip) / (farclip - nearclip);
glLoadMatrixf(&m[0][0]); glLoadMatrixf(&m[0][0]);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
@ -5088,7 +5094,6 @@ void polymost_drawrooms()
videoBeginDrawing(); videoBeginDrawing();
frameoffset = frameplace + windowxy1.y*bytesperline + windowxy1.x; frameoffset = frameplace + windowxy1.y*bytesperline + windowxy1.x;
resizeglcheck();
#ifdef YAX_ENABLE #ifdef YAX_ENABLE
if (numyaxbunches==0) if (numyaxbunches==0)
#endif #endif
@ -5122,6 +5127,8 @@ void polymost_drawrooms()
gvisibility = ((float)globalvisibility)*FOGSCALE; gvisibility = ((float)globalvisibility)*FOGSCALE;
resizeglcheck();
//global cos/sin height angle //global cos/sin height angle
float r = (float)(ydimen>>1) - ghoriz; float r = (float)(ydimen>>1) - ghoriz;
gshang = r/Bsqrtf(r*r+ghalfx*ghalfx); gshang = r/Bsqrtf(r*r+ghalfx*ghalfx);
@ -6349,7 +6356,10 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
tspr.cstat = globalorientation = (dastat&RS_TRANS1) | ((dastat&RS_TRANS2)<<4) | ((dastat&RS_YFLIP)<<1); tspr.cstat = globalorientation = (dastat&RS_TRANS1) | ((dastat&RS_TRANS2)<<4) | ((dastat&RS_YFLIP)<<1);
if ((dastat&(RS_AUTO|RS_NOCLIP)) == RS_AUTO) if ((dastat&(RS_AUTO|RS_NOCLIP)) == RS_AUTO)
{
glViewport(windowxy1.x, ydim-(windowxy2.y+1), windowxy2.x-windowxy1.x+1, windowxy2.y-windowxy1.y+1); glViewport(windowxy1.x, ydim-(windowxy2.y+1), windowxy2.x-windowxy1.x+1, windowxy2.y-windowxy1.y+1);
glox1 = -1;
}
else else
{ {
glViewport(0, 0, xdim, ydim); glViewport(0, 0, xdim, ydim);