* Start Menu: Fixes to 3D alpha style title logo.

This commit is contained in:
iProgramInCpp
2023-12-25 18:32:00 +02:00
parent 95556e3ccd
commit 9d5b957339
4 changed files with 31 additions and 19 deletions

BIN
game/assets/gui/black.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

View File

@@ -591,8 +591,7 @@ void StartMenuScreen::draw3dTitle(float f)
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_CULL_FACE);
glCullFace(GL_BACK);
//glDisable(GL_CULL_FACE);
glDepthMask(true);
for (int i = 0; i < 3; i++)
@@ -602,23 +601,24 @@ void StartMenuScreen::draw3dTitle(float f)
if (i == 0)
{
glClear(GL_DEPTH_BUFFER_BIT);
glTranslatef(0.0f, -0.5f, 0.0f);
glTranslatef(0.0f, -0.5f, -0.5f);
glEnable(GL_BLEND);
//force set alpha
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_SRC_COLOR, GL_ZERO);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
}
if (i == 1)
{
glDisable(GL_BLEND);
glClear(GL_DEPTH_BUFFER_BIT);
//revert
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
if (i == 2)
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR, GL_ONE);
//glBlendFunc(GL_SRC_COLOR, GL_ONE);
}
glScalef(1.0f, -1.0f, 1.0f);
@@ -629,7 +629,7 @@ void StartMenuScreen::draw3dTitle(float f)
m_pMinecraft->m_pTextures->loadAndBindTexture("terrain.png");
if (i == 0) {
// No title/black.png so we'll just simulate it in a cheap way
m_pMinecraft->m_pTextures->loadAndBindTexture("gui/black.png");
}
for (int y = 0; y < Height; y++)
@@ -648,7 +648,7 @@ void StartMenuScreen::draw3dTitle(float f)
float z = Lerp(pTTile->lastHeight, pTTile->height, f);
float scale = 1.0f;
float bright = 1.0f;
float rotation = 1.0f;
float rotation = 180.0f;
if (i == 0)
{
@@ -659,11 +659,12 @@ void StartMenuScreen::draw3dTitle(float f)
glTranslatef(float(x), float(y), z);
glScalef(scale, scale, scale);
glRotatef(rotation, 0.0f, 1.0f, 0.0f);
glScalef(-1.0f, 1.0f, 1.0f);
glRotatef(rotation, 0.0f, 0.0f, 1.0f);
// rotate 180 deg on the Z axis to correct lighting
glRotatef(-180.0f, 0.0f, 0.0f, 1.0f);
m_tileRenderer.renderTile(pTile, 0, bright);
// rotate 90 deg on the X axis to correct lighting
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
m_tileRenderer.renderTile(pTile, i == 0 ? 999 : 0, bright);
glPopMatrix();
}
@@ -678,7 +679,7 @@ void StartMenuScreen::draw3dTitle(float f)
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glViewport(0, 0, Minecraft::width, Minecraft::height);
glEnable(GL_CULL_FACE);
//glEnable(GL_CULL_FACE);
}
void StartMenuScreen::drawSplash()
@@ -724,6 +725,7 @@ bool StartMenuScreen::handleBackEvent(bool b)
Tile* TitleTile::_tiles[3];
Random TitleTile::_random;
bool TitleTile::_firstTimeInit = true;
TitleTile::TitleTile(StartMenuScreen* pScreen, int x, int y)
{
@@ -808,6 +810,12 @@ Tile* TitleTile::getRandomTile(Tile* except1, Tile* except2)
void TitleTile::regenerate()
{
if (_firstTimeInit)
{
_firstTimeInit = false;
_random.setSeed(getTimeMs());
}
_tiles[0] = getRandomTile(nullptr, nullptr);
_tiles[1] = getRandomTile(_tiles[0], nullptr);
_tiles[2] = getRandomTile(_tiles[0], _tiles[1]);

View File

@@ -30,7 +30,7 @@ protected:
private:
static Tile* _tiles[3];
static bool _firstTimeInit;
static Random _random;
static Tile* getRandomTile(Tile* except1, Tile* except2);
};

View File

@@ -2407,6 +2407,10 @@ void TileRenderer::renderTile(Tile* tile, int data RENDER_TILE_ARG_PATCH)
case SHAPE_SOLID:
default:
{
// N.B. If caller passes 999, they only want the face-down face.
// This is a hack to accomodate the start menu screen procedurally generated title logo.
#define IF_NEEDED(x) do { if (data != 999) { (x); } } while (0)
glTranslatef(-0.5f, -0.5f, -0.5f);
t.begin();
SHADE_DEFINE;
@@ -2415,13 +2419,13 @@ void TileRenderer::renderTile(Tile* tile, int data RENDER_TILE_ARG_PATCH)
renderFaceDown(tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_YPOS, data));
SHADE_FIXUP_GRASS;
SHADE_IF_NEEDED(0.5f);
renderFaceUp (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_YNEG, data));
IF_NEEDED(renderFaceUp(tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_YNEG, data)));
SHADE_IF_NEEDED(0.8f);
renderNorth (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_ZNEG, data));
renderSouth (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_ZPOS, data));
IF_NEEDED(renderNorth(tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_ZNEG, data)));
IF_NEEDED(renderSouth(tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_ZPOS, data)));
SHADE_IF_NEEDED(0.6f);
renderWest (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_XNEG, data));
renderEast (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_XPOS, data));
IF_NEEDED(renderWest (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_XNEG, data)));
IF_NEEDED(renderEast (tile, 0.0f, 0.0f, 0.0f, tile->getTexture(DIR_XPOS, data)));
SHADE_IF_NEEDED(1.0f);
t.draw();
glTranslatef(0.5f, 0.5f, 0.5f);