static void RenderDome(FTextureID texno, FMaterial * tex, float x_offset, float y_offset, bool mirror, int CM_Index) { int texh = 0; bool texscale = false; // 57 worls units roughly represent one sky texel for the glTranslate call. const float skyoffsetfactor = 57; if (tex) { glPushMatrix(); tex->Bind(CM_Index, 0, 0); texw = tex->TextureWidth(GLUSE_TEXTURE); texh = tex->TextureHeight(GLUSE_TEXTURE); glRotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); yAdd = y_offset/texh; if (texh < 128) { // smaller sky textures must be tiled. We restrict it to 128 sky pixels, though glTranslatef(0.f, -1250.f, 0.f); glScalef(1.f, 128/230.f, 1.f); glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); glScalef(1.f, 128 / texh, 1.f); // intentionally left as integer. glMatrixMode(GL_MODELVIEW); texscale = true; } else if (texh < 200) { glTranslatef(0.f, -1250.f, 0.f); glScalef(1.f, texh/230.f, 1.f); } else if (texh <= 240) { glTranslatef(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); glScalef(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); } else { glTranslatef(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); glScalef(1.f, 1.2f * 1.17f, 1.f); glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); glScalef(1.f, 240.f / texh, 1.f); glMatrixMode(GL_MODELVIEW); texscale = true; } } if (tex && !secondlayer) { PalEntry pe = tex->tex->GetSkyCapColor(false); if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); R=pe.r/255.0f; G=pe.g/255.0f; B=pe.b/255.0f; if (gl_fixedcolormap) { float rr, gg, bb; gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); R*=rr; G*=gg; B*=bb; } } RenderSkyHemisphere(SKYHEMI_UPPER, mirror); if (tex && !secondlayer) { PalEntry pe = tex->tex->GetSkyCapColor(true); if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); R=pe.r/255.0f; G=pe.g/255.0f; B=pe.b/255.0f; if (gl_fixedcolormap != CM_DEFAULT) { float rr,gg,bb; gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); R*=rr; G*=gg; B*=bb; } } RenderSkyHemisphere(SKYHEMI_LOWER, mirror); if (texscale) { glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } if (tex) glPopMatrix(); }
static void RenderDome(int texno, FGLTexture * tex, float x_offset, float y_offset, int CM_Index) { int texh; bool skystretch = (r_stretchsky && !(level.flags & LEVEL_FORCENOSKYSTRETCH)); if (tex) { tex->Bind(CM_Index); texw = tex->TextureWidth(); texh = tex->TextureHeight(); if (texh>190 && skystretch) texh=190; gl.Rotatef(-180.0f+x_offset, 0.f, 1.f, 0.f); yAdd = y_offset/texh; // The non-stretched skies still need some work if (texh<=180) // && skystretch) { yMult=1.0f; } else { yMult= 180.0f/texh; /* if (texh<=180) { yAdd-=(180-texh)/(float)texh; } */ } } if (tex && !secondlayer) { PalEntry pe = SkyCapColor(texno, false); if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); R=pe.r/255.0f; G=pe.g/255.0f; B=pe.b/255.0f; if (gl_fixedcolormap) { float rr, gg, bb; gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); R*=rr; G*=gg; B*=bb; } } RenderSkyHemisphere(SKYHEMI_UPPER); if(tex) { yAdd = y_offset/texh; if (texh<=180) { yMult=1.0f; } else { yAdd+=180.0f/texh; } } if (tex && !secondlayer) { PalEntry pe = SkyCapColor(texno, true); if (CM_Index!=CM_DEFAULT) ModifyPalette(&pe, &pe, CM_Index, 1); R=pe.r/255.0f; G=pe.g/255.0f; B=pe.b/255.0f; if (fixedcolormap) { float rr,gg,bb; gl_GetLightColor(255, 0, NULL, &rr, &gg, &bb); R*=rr; G*=gg; B*=bb; } } RenderSkyHemisphere(SKYHEMI_LOWER); if (tex) { gl.Rotatef(180.0f-x_offset, 0.f, 1.f, 0.f); } }