Graphics: Respect non-default initial window size

This commit is contained in:
Jonas Kulla 2014-07-03 02:48:28 +02:00
parent 843a7bf571
commit 4a0084801e
1 changed files with 14 additions and 11 deletions

View File

@ -404,11 +404,12 @@ struct GraphicsPrivate
Quad screenQuad; Quad screenQuad;
RBOFBO transBuffer; RBOFBO transBuffer;
GraphicsPrivate() GraphicsPrivate(RGSSThreadData *rtData)
: scRes(640, 480), : scRes(640, 480),
scSize(scRes), scSize(scRes),
winSize(scRes), winSize(rtData->config.defScreenW, rtData->config.defScreenH),
screen(scRes.x, scRes.y), screen(scRes.x, scRes.y),
threadData(rtData),
frameRate(40), frameRate(40),
frameCount(0), frameCount(0),
#ifdef RGSS2 #ifdef RGSS2
@ -417,6 +418,9 @@ struct GraphicsPrivate
fpsLimiter(frameRate), fpsLimiter(frameRate),
frozen(false) frozen(false)
{ {
recalculateScreenSize(rtData);
updateScreenResoRatio(rtData);
TEXFBO::init(frozenScene); TEXFBO::init(frozenScene);
TEXFBO::allocEmpty(frozenScene, scRes.x, scRes.y); TEXFBO::allocEmpty(frozenScene, scRes.x, scRes.y);
TEXFBO::linkFBO(frozenScene); TEXFBO::linkFBO(frozenScene);
@ -441,21 +445,21 @@ struct GraphicsPrivate
RBOFBO::fini(transBuffer); RBOFBO::fini(transBuffer);
} }
void updateScreenResoRatio() void updateScreenResoRatio(RGSSThreadData *rtData)
{ {
Vec2 &ratio = shState->rtData().sizeResoRatio; Vec2 &ratio = rtData->sizeResoRatio;
ratio.x = (float) scRes.x / scSize.x; ratio.x = (float) scRes.x / scSize.x;
ratio.y = (float) scRes.y / scSize.y; ratio.y = (float) scRes.y / scSize.y;
shState->rtData().screenOffset = scOffset; rtData->screenOffset = scOffset;
} }
/* Enforces fixed aspect ratio, if desired */ /* Enforces fixed aspect ratio, if desired */
void recalculateScreenSize() void recalculateScreenSize(RGSSThreadData *rtData)
{ {
scSize = winSize; scSize = winSize;
if (!threadData->config.fixedAspectRatio) if (!rtData->config.fixedAspectRatio)
{ {
scOffset = Vec2i(0, 0); scOffset = Vec2i(0, 0);
return; return;
@ -479,8 +483,8 @@ struct GraphicsPrivate
{ {
/* some GL drivers change the viewport on window resize */ /* some GL drivers change the viewport on window resize */
glState.viewport.refresh(); glState.viewport.refresh();
recalculateScreenSize(); recalculateScreenSize(threadData);
updateScreenResoRatio(); updateScreenResoRatio(threadData);
} }
} }
@ -528,8 +532,7 @@ struct GraphicsPrivate
Graphics::Graphics(RGSSThreadData *data) Graphics::Graphics(RGSSThreadData *data)
{ {
p = new GraphicsPrivate; p = new GraphicsPrivate(data);
p->threadData = data;
if (data->config.fixedFramerate > 0) if (data->config.fixedFramerate > 0)
p->fpsLimiter.setDesiredFPS(data->config.fixedFramerate); p->fpsLimiter.setDesiredFPS(data->config.fixedFramerate);