mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +00:00
batch 2.1; entity lightfix
This commit is contained in:
parent
09e8a8f981
commit
e71ff8699a
|
|
@ -358,16 +358,22 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
||||||
|
|
||||||
Tile* tile = Tile::tiles[itemId];
|
Tile* tile = Tile::tiles[itemId];
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
// 4J - original code left here for reference
|
// 4J - original code left here for reference
|
||||||
// 4jcraft: original code reused for proper lighting
|
// 4jcraft: original code reused for proper lighting
|
||||||
|
// force normalize
|
||||||
|
glEnable(GL_NORMALIZE);
|
||||||
|
glDisable(GL_RESCALE_NORMAL);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
glTranslatef((float)(x), (float)(y), 0.0f);
|
// does it work? too lazy to find out
|
||||||
glScalef(fScaleX, fScaleY, 1.0f);
|
glTranslatef((float)(x), (float)(y), 0.0f);
|
||||||
glTranslatef(-2.0f,3.0f, -3.0f + blitOffset);
|
glScalef(fScaleX, fScaleY, 1.0f);
|
||||||
glScalef(10.0f, 10.0f, 10.0f);
|
glTranslatef(-2.0f, 3.0f, -3.0f + blitOffset);
|
||||||
|
glScalef(10.0f, 10.0f, 10.0f);
|
||||||
glTranslatef(1.0f, 0.5f, 8.0f);
|
glTranslatef(1.0f, 0.5f, 8.0f);
|
||||||
glScalef(1.0f, 1.0f, -1.0f);
|
glScalef(1.0f, -1.0f, 1.0f);
|
||||||
glRotatef(180.0f + 30.0f, 1.0f, 0.0f, 0.0f);
|
glRotatef(30.0f, 1.0f, 0.0f, 0.0f);
|
||||||
glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
|
glRotatef(45.0f, 0.0f, 1.0f, 0.0f);
|
||||||
#else
|
#else
|
||||||
glTranslatef(x, y, 0.0f); // Translate to screen coords
|
glTranslatef(x, y, 0.0f); // Translate to screen coords
|
||||||
|
|
@ -385,12 +391,16 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures,
|
||||||
glRotatef(45.0f, 0.0f, 1.0f,
|
glRotatef(45.0f, 0.0f, 1.0f,
|
||||||
0.0f); // Rotate round y axis (centre at origin)
|
0.0f); // Rotate round y axis (centre at origin)
|
||||||
#endif
|
#endif
|
||||||
// 4J-PB - pass the alpha value in - the grass block
|
// 4J-PB - pass the alpha value in - the grass block
|
||||||
// render has the top surface coloured differently to
|
// render has the top surface coloured differently to
|
||||||
// the rest of the block
|
// the rest of the block
|
||||||
glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
|
glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
|
||||||
|
// glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
||||||
|
|
||||||
tileRenderer->renderTile(tile, itemAuxValue, 1, fAlpha, useCompiled);
|
tileRenderer->renderTile(tile, itemAuxValue, 1, fAlpha, useCompiled);
|
||||||
|
|
||||||
|
// glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
|
||||||
|
glDisable(GL_NORMALIZE);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
PIXEndNamedEvent();
|
PIXEndNamedEvent();
|
||||||
} else if (Item::items[itemId]->hasMultipleSpriteLayers()) {
|
} else if (Item::items[itemId]->hasMultipleSpriteLayers()) {
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,27 @@ FloatBuffer* Lighting::getBuffer(float a, float b, float c, float d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lighting::turnOnGui() {
|
void Lighting::turnOnGui() {
|
||||||
glPushMatrix();
|
glEnable(GL_LIGHTING);
|
||||||
glRotatef(-30, 0, 1, 0);
|
glEnable(GL_LIGHT0);
|
||||||
glRotatef(165, 1, 0, 0);
|
glEnable(GL_LIGHT1);
|
||||||
turnOn();
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glPopMatrix();
|
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||||
|
|
||||||
|
float a = 0.4f;
|
||||||
|
float d = 0.6f;
|
||||||
|
float s = 0.0f;
|
||||||
|
// big john machine
|
||||||
|
// (copied from turnon)
|
||||||
|
RenderManager.StateSetLightDirection(0, 0.129f, 0.965f, 0.224f);
|
||||||
|
glLight(GL_LIGHT0, GL_DIFFUSE, getBuffer(d, d, d, 1));
|
||||||
|
glLight(GL_LIGHT0, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
glLight(GL_LIGHT0, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
|
||||||
|
|
||||||
|
RenderManager.StateSetLightDirection(1, -0.129f, 0.965f, -0.224f);
|
||||||
|
glLight(GL_LIGHT1, GL_DIFFUSE, getBuffer(d, d, d, 1));
|
||||||
|
glLight(GL_LIGHT1, GL_AMBIENT, getBuffer(0.0f, 0.0f, 0.0f, 1.0f));
|
||||||
|
glLight(GL_LIGHT1, GL_SPECULAR, getBuffer(s, s, s, 1.0f));
|
||||||
|
|
||||||
|
glShadeModel(GL_FLAT);
|
||||||
|
glLightModel(GL_LIGHT_MODEL_AMBIENT, getBuffer(a, a, a, 1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue