mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
screen size
This commit is contained in:
parent
417ea73050
commit
d9184f1a99
|
|
@ -627,8 +627,13 @@ void GameRenderer::unZoomRegion()
|
||||||
void GameRenderer::getFovAndAspect(float& fov, float& aspect, float a, bool applyEffects)
|
void GameRenderer::getFovAndAspect(float& fov, float& aspect, float a, bool applyEffects)
|
||||||
{
|
{
|
||||||
// 4J - split out aspect ratio and fov here so we can adjust for viewports - we might need to revisit these as
|
// 4J - split out aspect ratio and fov here so we can adjust for viewports - we might need to revisit these as
|
||||||
// they are maybe be too generous for performance.
|
// avoid pixel streching, its UGLEYYY
|
||||||
aspect = mc->width / (float) mc->height;
|
{
|
||||||
|
int fbw = mc->width;
|
||||||
|
int fbh = mc->height;
|
||||||
|
RenderManager.GetFramebufferSize(fbw, fbh);
|
||||||
|
aspect = fbw / (float) fbh;
|
||||||
|
}
|
||||||
fov = getFov(a, applyEffects);
|
fov = getFov(a, applyEffects);
|
||||||
|
|
||||||
if( ( mc->player->m_iScreenSection == C4JRender::VIEWPORT_TYPE_SPLIT_TOP ) ||
|
if( ( mc->player->m_iScreenSection == C4JRender::VIEWPORT_TYPE_SPLIT_TOP ) ||
|
||||||
|
|
@ -1053,12 +1058,15 @@ void GameRenderer::render(float a, bool bFirst)
|
||||||
if (mc->noRender) return;
|
if (mc->noRender) return;
|
||||||
GameRenderer::anaglyph3d = mc->options->anaglyph3d;
|
GameRenderer::anaglyph3d = mc->options->anaglyph3d;
|
||||||
|
|
||||||
glViewport(0, 0, mc->width, mc->height); // 4J - added
|
{
|
||||||
|
int fbw, fbh;
|
||||||
|
RenderManager.GetFramebufferSize(fbw, fbh);
|
||||||
|
glViewport(0, 0, fbw, fbh);
|
||||||
ScreenSizeCalculator ssc(mc->options, mc->width, mc->height);
|
ScreenSizeCalculator ssc(mc->options, mc->width, mc->height);
|
||||||
int screenWidth = ssc.getWidth();
|
int screenWidth = ssc.getWidth();
|
||||||
int screenHeight = ssc.getHeight();
|
int screenHeight = ssc.getHeight();
|
||||||
int xMouse = Mouse::getX() * screenWidth / mc->width;
|
int xMouse = Mouse::getX() * screenWidth / fbw;
|
||||||
int yMouse = screenHeight - Mouse::getY() * screenHeight / mc->height - 1;
|
int yMouse = screenHeight - Mouse::getY() * screenHeight / fbh - 1;
|
||||||
|
|
||||||
int maxFps = getFpsCap(mc->options->framerateLimit);
|
int maxFps = getFpsCap(mc->options->framerateLimit);
|
||||||
|
|
||||||
|
|
@ -1083,7 +1091,11 @@ void GameRenderer::render(float a, bool bFirst)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glViewport(0, 0, mc->width, mc->height);
|
{
|
||||||
|
int fbw, fbh;
|
||||||
|
RenderManager.GetFramebufferSize(fbw, fbh);
|
||||||
|
glViewport(0, 0, fbw, fbh);
|
||||||
|
}
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
@ -1291,7 +1303,11 @@ void GameRenderer::renderLevel(float a, __int64 until)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glViewport(0, 0, mc->width, mc->height);
|
{
|
||||||
|
int fbw, fbh;
|
||||||
|
RenderManager.GetFramebufferSize(fbw, fbh);
|
||||||
|
glViewport(0, 0, fbw, fbh);
|
||||||
|
}
|
||||||
setupClearColor(a);
|
setupClearColor(a);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
|
|
@ -1787,6 +1803,8 @@ void GameRenderer::renderSnowAndRain(float a)
|
||||||
// 4J - added forceScale parameter
|
// 4J - added forceScale parameter
|
||||||
void GameRenderer::setupGuiScreen(int forceScale /*=-1*/)
|
void GameRenderer::setupGuiScreen(int forceScale /*=-1*/)
|
||||||
{
|
{
|
||||||
|
int fbw, fbh;
|
||||||
|
RenderManager.GetFramebufferSize(fbw, fbh);
|
||||||
ScreenSizeCalculator ssc(mc->options, mc->width, mc->height, forceScale);
|
ScreenSizeCalculator ssc(mc->options, mc->width, mc->height, forceScale);
|
||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "ScreenSizeCalculator.h"
|
#include "ScreenSizeCalculator.h"
|
||||||
#include "../GameState/Options.h"
|
#include "../GameState/Options.h"
|
||||||
|
|
||||||
|
// who the fuck thought this was a good idea
|
||||||
ScreenSizeCalculator::ScreenSizeCalculator(Options *options, int width, int height, int forceScale/*=-1*/)
|
ScreenSizeCalculator::ScreenSizeCalculator(Options *options, int width, int height, int forceScale/*=-1*/)
|
||||||
{
|
{
|
||||||
w = width;
|
w = width;
|
||||||
|
|
@ -12,7 +13,7 @@ ScreenSizeCalculator::ScreenSizeCalculator(Options *options, int width, int heig
|
||||||
|
|
||||||
int maxScale = options->guiScale;
|
int maxScale = options->guiScale;
|
||||||
if (maxScale == 0) maxScale = 1000;
|
if (maxScale == 0) maxScale = 1000;
|
||||||
while (scale < maxScale && w / (scale + 1) >= 320 && h / (scale + 1) >= 240)
|
while (scale < maxScale && w / (scale + 1) >= 320 && h / (scale + 1) >= 240) // ughh
|
||||||
{
|
{
|
||||||
scale++;
|
scale++;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,11 @@ void AchievementPopup::permanent(Achievement *ach)
|
||||||
|
|
||||||
void AchievementPopup::prepareWindow()
|
void AchievementPopup::prepareWindow()
|
||||||
{
|
{
|
||||||
glViewport(0, 0, mc->width, mc->height);
|
{
|
||||||
|
int fbw, fbh;
|
||||||
|
RenderManager.GetFramebufferSize(fbw, fbh);
|
||||||
|
glViewport(0, 0, fbw, fbh);
|
||||||
|
} // just future proofing
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue