Fix sky rendering.

This commit is contained in:
iProgramInCpp 2023-07-31 22:25:58 +03:00
parent 16bfb1359e
commit 65406ef97e
5 changed files with 19 additions and 31 deletions

View file

@ -180,16 +180,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
Random random;
random.setSeed(123456);
for (int i = 0; i < 256; i++)
{
LogMsg("%d: %d", i, random.nextInt(256 - i) + i);
}
SetInstance(hInstance);
g_AppPlatform.initConsts();

View file

@ -434,6 +434,7 @@ void GameRenderer::renderLevel(float f)
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
// glDepthMask(false); -- added in 0.1.1j. Introduces more issues than fixes
// render the alpha layer
m_pMinecraft->m_pTextures->loadAndBindTexture(C_TERRAIN_NAME);

View file

@ -20,34 +20,30 @@ LevelRenderer::LevelRenderer(Minecraft* pMC, Textures* pTexs)
printf("numBuffers: %d\n", m_nBuffers);
xglGenBuffers(1, &field_D8);
generateSky(); // inlined in the 0.1.0 demo
}
void LevelRenderer::generateSky()
{
Tesselator& t = Tesselator::instance;
t.begin();
field_DC = 0;
for (int v7 = -128; ; )
float m = 16.0f;
int n = 4;
int p = 128;
for (int i = n * -p; i <= n * p; i += p)
{
int v8 = v7 + 128;
int v9 = -512;
float v10 = -512.0f;
float v11 = float(v7);
float v12 = float(v7 + 128);
for (; v9 != 640; )
for (int j = n * -p; j <= n * p; j += p)
{
float v13 = v10;
v9 += 128;
t.vertex(float(i + 0.0f), 16.0f, float(j + 0.0f));
t.vertex(float(i + p) , 16.0f, float(j + 0.0f));
t.vertex(float(i + p) , 16.0f, float(j + p) );
t.vertex(float(i + 0.0f), 16.0f, float(j + p) );
t.vertex(v11, 16.0f, v13);
t.vertex(v12, 16.0f, v13);
v10 = float(v9);
t.vertex(v12, 16.0f, float(v9));
t.vertex(v11, 16.0f, float(v9));
field_DC += 4;
}
if (v8 == 640)
break;
v7 = v8;
}
t.end(field_D8);

View file

@ -81,6 +81,7 @@ public:
void addParticle(const std::string&, float, float, float, float, float, float) override;
void playSound(const std::string& a, float b, float c, float d, float e, float f) override;
void skyColorChanged() override;
void generateSky();
void cull(Culler*, float);
void deleteChunks();
void resortChunks(int x, int y, int z);

View file

@ -16,7 +16,7 @@ IceTile::IceTile(int a, int b, Material* c) : HalfTransparentTile(a, b, c)
int IceTile::getRenderLayer()
{
return 1;
return LAYER_ALPHA;
}
int IceTile::getResourceCount(Random* pRandom)