mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Modernize project codebase
This commit is contained in:
parent
3ff616a7b3
commit
d799eb06f0
|
|
@ -954,91 +954,70 @@ float GameRenderer::ComputeGammaFromSlider(float slider0to100)
|
||||||
|
|
||||||
void GameRenderer::CachePlayerGammas()
|
void GameRenderer::CachePlayerGammas()
|
||||||
{
|
{
|
||||||
for (int j = 0; j < XUSER_MAX_COUNT && j < NUM_LIGHT_TEXTURES; ++j)
|
const float slider = app.GetGameSettings(ProfileManager.GetPrimaryPad(), eGameSetting_Gamma);
|
||||||
{
|
const float gamma = ComputeGammaFromSlider(slider);
|
||||||
std::shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->localplayers[j];
|
|
||||||
if (!player)
|
|
||||||
{
|
|
||||||
m_cachedGammaPerPlayer[j] = 1.0f;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const float slider = app.GetGameSettings(j, eGameSetting_Gamma); // 0..100
|
for (int j = 0; j < XUSER_MAX_COUNT && j < NUM_LIGHT_TEXTURES; ++j)
|
||||||
m_cachedGammaPerPlayer[j] = ComputeGammaFromSlider(slider);
|
m_cachedGammaPerPlayer[j] = gamma;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameRenderer::ComputeViewportForPlayer(int j, D3D11_VIEWPORT &outViewport) const
|
bool GameRenderer::ComputeViewportForPlayer(int j, D3D11_VIEWPORT &outViewport) const
|
||||||
{
|
{
|
||||||
// Use the actual backbuffer dimensions so viewports adapt to window resize.
|
|
||||||
extern int g_rScreenWidth;
|
extern int g_rScreenWidth;
|
||||||
extern int g_rScreenHeight;
|
extern int g_rScreenHeight;
|
||||||
|
|
||||||
int active = 0;
|
std::shared_ptr<MultiplayerLocalPlayer> player = Minecraft::GetInstance()->localplayers[j];
|
||||||
int indexMap[NUM_LIGHT_TEXTURES] = {-1, -1, -1, -1};
|
if (!player)
|
||||||
for (int i = 0; i < XUSER_MAX_COUNT && i < NUM_LIGHT_TEXTURES; ++i)
|
|
||||||
{
|
|
||||||
if (Minecraft::GetInstance()->localplayers[i])
|
|
||||||
indexMap[active++] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (active <= 1)
|
|
||||||
{
|
|
||||||
outViewport.TopLeftX = 0.0f;
|
|
||||||
outViewport.TopLeftY = 0.0f;
|
|
||||||
outViewport.Width = static_cast<FLOAT>(g_rScreenWidth);
|
|
||||||
outViewport.Height = static_cast<FLOAT>(g_rScreenHeight);
|
|
||||||
outViewport.MinDepth = 0.0f;
|
|
||||||
outViewport.MaxDepth = 1.0f;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int k = -1;
|
|
||||||
for (int ord = 0; ord < active; ++ord)
|
|
||||||
if (indexMap[ord] == j)
|
|
||||||
{
|
|
||||||
k = ord;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (k < 0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const float width = static_cast<float>(g_rScreenWidth);
|
const float w = static_cast<float>(g_rScreenWidth);
|
||||||
const float height = static_cast<float>(g_rScreenHeight);
|
const float h = static_cast<float>(g_rScreenHeight);
|
||||||
|
const float halfW = w * 0.5f;
|
||||||
|
const float halfH = h * 0.5f;
|
||||||
|
|
||||||
if (active == 2)
|
outViewport.MinDepth = 0.0f;
|
||||||
|
outViewport.MaxDepth = 1.0f;
|
||||||
|
|
||||||
|
switch (static_cast<C4JRender::eViewportType>(player->m_iScreenSection))
|
||||||
{
|
{
|
||||||
const float halfH = height * 0.5f;
|
case C4JRender::VIEWPORT_TYPE_SPLIT_TOP:
|
||||||
outViewport.TopLeftX = 0.0f;
|
outViewport.TopLeftX = 0; outViewport.TopLeftY = 0;
|
||||||
outViewport.Width = width;
|
outViewport.Width = w; outViewport.Height = halfH;
|
||||||
outViewport.MinDepth = 0.0f;
|
break;
|
||||||
outViewport.MaxDepth = 1.0f;
|
case C4JRender::VIEWPORT_TYPE_SPLIT_BOTTOM:
|
||||||
if (k == 0)
|
outViewport.TopLeftX = 0; outViewport.TopLeftY = halfH;
|
||||||
{
|
outViewport.Width = w; outViewport.Height = halfH;
|
||||||
outViewport.TopLeftY = 0.0f;
|
break;
|
||||||
outViewport.Height = halfH;
|
case C4JRender::VIEWPORT_TYPE_SPLIT_LEFT:
|
||||||
}
|
outViewport.TopLeftX = 0; outViewport.TopLeftY = 0;
|
||||||
else
|
outViewport.Width = halfW; outViewport.Height = h;
|
||||||
{
|
break;
|
||||||
outViewport.TopLeftY = halfH;
|
case C4JRender::VIEWPORT_TYPE_SPLIT_RIGHT:
|
||||||
outViewport.Height = halfH;
|
outViewport.TopLeftX = halfW; outViewport.TopLeftY = 0;
|
||||||
}
|
outViewport.Width = halfW; outViewport.Height = h;
|
||||||
return true;
|
break;
|
||||||
}
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_LEFT:
|
||||||
else
|
outViewport.TopLeftX = 0; outViewport.TopLeftY = 0;
|
||||||
{
|
outViewport.Width = halfW; outViewport.Height = halfH;
|
||||||
const float halfW = width * 0.5f;
|
break;
|
||||||
const float halfH = height * 0.5f;
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_TOP_RIGHT:
|
||||||
const int row = (k >= 2) ? 1 : 0;
|
outViewport.TopLeftX = halfW; outViewport.TopLeftY = 0;
|
||||||
const int col = (k % 2);
|
outViewport.Width = halfW; outViewport.Height = halfH;
|
||||||
outViewport.TopLeftX = col ? halfW : 0.0f;
|
break;
|
||||||
outViewport.TopLeftY = row ? halfH : 0.0f;
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_LEFT:
|
||||||
outViewport.Width = halfW;
|
outViewport.TopLeftX = 0; outViewport.TopLeftY = halfH;
|
||||||
outViewport.Height = halfH;
|
outViewport.Width = halfW; outViewport.Height = halfH;
|
||||||
outViewport.MinDepth = 0.0f;
|
break;
|
||||||
outViewport.MaxDepth = 1.0f;
|
case C4JRender::VIEWPORT_TYPE_QUADRANT_BOTTOM_RIGHT:
|
||||||
return true;
|
outViewport.TopLeftX = halfW; outViewport.TopLeftY = halfH;
|
||||||
|
outViewport.Width = halfW; outViewport.Height = halfH;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
outViewport.TopLeftX = 0; outViewport.TopLeftY = 0;
|
||||||
|
outViewport.Width = w; outViewport.Height = h;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GameRenderer::BuildPlayerViewports(D3D11_VIEWPORT *outViewports, float *outGammas, UINT maxCount) const
|
uint32_t GameRenderer::BuildPlayerViewports(D3D11_VIEWPORT *outViewports, float *outGammas, UINT maxCount) const
|
||||||
|
|
@ -1190,11 +1169,19 @@ void GameRenderer::render(float a, bool bFirst)
|
||||||
const int xMouse = Mouse::getX() * screenWidth / mc->width;
|
const int xMouse = Mouse::getX() * screenWidth / mc->width;
|
||||||
const int yMouse = screenHeight - Mouse::getY() * screenHeight / mc->height - 1;
|
const int yMouse = screenHeight - Mouse::getY() * screenHeight / mc->height - 1;
|
||||||
|
|
||||||
const int maxFps = getFpsCap(app.GetGameSettings(0, eGameSetting_FpsCap));
|
const int maxFps = getFpsCap(mc->options->framerateLimit);
|
||||||
|
|
||||||
if (mc->level != nullptr)
|
if (mc->level != nullptr)
|
||||||
{
|
{
|
||||||
renderLevel(a, 0);
|
if (mc->options->framerateLimit == 0)
|
||||||
|
{
|
||||||
|
renderLevel(a, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderLevel(a, lastNsTime + 1000000000 / maxFps);
|
||||||
|
}
|
||||||
|
|
||||||
lastNsTime = System::nanoTime();
|
lastNsTime = System::nanoTime();
|
||||||
|
|
||||||
if (!mc->options->hideGui || mc->screen != nullptr)
|
if (!mc->options->hideGui || mc->screen != nullptr)
|
||||||
|
|
@ -2253,12 +2240,13 @@ FloatBuffer *GameRenderer::getBuffer(float a, float b, float c, float d)
|
||||||
|
|
||||||
int GameRenderer::getFpsCap(int option)
|
int GameRenderer::getFpsCap(int option)
|
||||||
{
|
{
|
||||||
static const int fpsCaps[] = {30, 60, 120, 0};
|
static const int fpsCaps[] = {30, 60, 120, 0};
|
||||||
if (option < 0 || option > 3) return 0;
|
if (option < 0 || option > 3) return 0;
|
||||||
return fpsCaps[option];
|
return fpsCaps[option];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameRenderer::updateAllChunks()
|
void GameRenderer::updateAllChunks()
|
||||||
{
|
{
|
||||||
// mc->levelRenderer->updateDirtyChunks(mc->cameraTargetPlayer, true);
|
// mc->levelRenderer->updateDirtyChunks(mc->cameraTargetPlayer, true);
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue