mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-04-30 17:43:30 +00:00
sigh, another attempt at fixing normal shading for android
This commit is contained in:
@@ -606,7 +606,7 @@ void Gui::renderProgressIndicator( const bool isTouchInterface, const int screen
|
||||
glBlendFunc2(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
|
||||
blit(screenWidth/2 - 8, screenHeight/2 - 8, 0, 0, 16, 16);
|
||||
glDisable(GL_BLEND);
|
||||
} else if(!bowEquipped) {
|
||||
} else if((!bowEquipped) || (!minecraft->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA))) {
|
||||
const float tprogress = minecraft->gameMode->destroyProgress;
|
||||
const float alpha = Mth::clamp(minecraft->inputHolder->alpha, 0.0f, 1.0f);
|
||||
//LOGI("alpha: %f\n", alpha);
|
||||
|
||||
@@ -203,7 +203,7 @@ void ModelPart::compile( float scale )
|
||||
void ModelPart::draw()
|
||||
{
|
||||
#ifdef OPENGL_ES
|
||||
drawArrayVTN_NoState(vboId, cubes.size() * 2 * 3 * 6, 28);
|
||||
drawArrayVTN_NoState(vboId, cubes.size() * 2 * 3 * 6, 36);
|
||||
#else
|
||||
glCallList(list);
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@ Tesselator Tesselator::instance(sizeof(GLfloat) * MAX_FLOATS); // max size in by
|
||||
const int VertexSizeBytes = sizeof(VERTEX);
|
||||
|
||||
Tesselator::Tesselator( int size )
|
||||
: size(size),
|
||||
: size(size),
|
||||
vertices(0),
|
||||
u(0), v(0),
|
||||
_color(0),
|
||||
@@ -20,7 +20,7 @@ Tesselator::Tesselator( int size )
|
||||
_noColor(false),
|
||||
mode(0),
|
||||
xo(0), yo(0), zo(0),
|
||||
_normal(0),
|
||||
_nx(0), _ny(0), _nz(0),
|
||||
_sx(1), _sy(1),
|
||||
|
||||
tesselating(false),
|
||||
@@ -97,9 +97,9 @@ RenderChunk Tesselator::end( bool useMine, int bufferId )
|
||||
int access = GL_STATIC_DRAW;//(accessMode==ACCESS_DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
glBufferData2(GL_ARRAY_BUFFER, bytes, _varray, access); // GL_STREAM_DRAW
|
||||
|
||||
|
||||
totalSize += bytes;
|
||||
|
||||
|
||||
#ifndef USE_VBO
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// x y z u v c
|
||||
@@ -112,7 +112,7 @@ RenderChunk Tesselator::end( bool useMine, int bufferId )
|
||||
glEnableClientState2(GL_COLOR_ARRAY);
|
||||
}
|
||||
if (hasNormal) {
|
||||
glNormalPointer(GL_BYTE, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
glNormalPointer(GL_FLOAT, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
glEnableClientState2(GL_NORMAL_ARRAY);
|
||||
}
|
||||
glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, 0);
|
||||
@@ -279,7 +279,9 @@ void Tesselator::vertex( float x, float y, float z )
|
||||
dst.color = src.color;
|
||||
}
|
||||
if (hasNormal) {
|
||||
dst.normal = src.normal;
|
||||
dst.nx = src.nx;
|
||||
dst.ny = src.ny;
|
||||
dst.nz = src.nz;
|
||||
}
|
||||
|
||||
dst.x = src.x;
|
||||
@@ -302,7 +304,9 @@ void Tesselator::vertex( float x, float y, float z )
|
||||
vertex.color = _color;
|
||||
}
|
||||
if (hasNormal) {
|
||||
vertex.normal = _normal;
|
||||
vertex.nx = _nx;
|
||||
vertex.ny = _ny;
|
||||
vertex.nz = _nz;
|
||||
}
|
||||
|
||||
vertex.x = _sx * (x + xo);
|
||||
@@ -339,11 +343,15 @@ void Tesselator::normal( float x, float y, float z )
|
||||
|
||||
if (!tesselating) printf("But..");
|
||||
hasNormal = true;
|
||||
char xx = (char) (x * 128);
|
||||
char yy = (char) (y * 127);
|
||||
char zz = (char) (z * 127);
|
||||
//char xx = (char) (x * 128);
|
||||
//char yy = (char) (y * 127);
|
||||
//char zz = (char) (z * 127);
|
||||
|
||||
_normal = xx | (yy << 8) | (zz << 16);
|
||||
//_normal = xx | (yy << 8) | (zz << 16);
|
||||
// trying a new thing hopefully works
|
||||
this->_nx = x;
|
||||
this->_ny = y;
|
||||
this->_nz = z;
|
||||
}
|
||||
|
||||
void Tesselator::offset( float xo, float yo, float zo ) {
|
||||
@@ -389,7 +397,7 @@ void Tesselator::draw()
|
||||
vboId = 0;
|
||||
|
||||
int bufferId = vboIds[vboId];
|
||||
|
||||
|
||||
int access = GL_DYNAMIC_DRAW;//(accessMode==ACCESS_DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
glBufferData2(GL_ARRAY_BUFFER, bytes, _varray, access); // GL_STREAM_DRAW
|
||||
@@ -405,7 +413,7 @@ void Tesselator::draw()
|
||||
glEnableClientState2(GL_COLOR_ARRAY);
|
||||
}
|
||||
if (hasNormal) {
|
||||
glNormalPointer(GL_BYTE, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
glNormalPointer(GL_FLOAT, VertexSizeBytes, (GLvoid*) (6 * 4));
|
||||
glEnableClientState2(GL_NORMAL_ARRAY);
|
||||
}
|
||||
//glVertexPointer2(3, GL_FLOAT, VertexSizeBytes, (GLvoid*)&_varray);
|
||||
|
||||
@@ -98,7 +98,9 @@ private:
|
||||
float xo, yo, zo;
|
||||
float u, v;
|
||||
unsigned int _color;
|
||||
int _normal;
|
||||
// int _normal; // trying a new thing
|
||||
float _nx, _ny, _nz;
|
||||
|
||||
float _sx, _sy;
|
||||
|
||||
bool hasColor;
|
||||
|
||||
@@ -14,7 +14,8 @@ typedef struct VertexDeclPTCN
|
||||
GLfloat x, y, z;
|
||||
GLfloat u, v;
|
||||
GLuint color;
|
||||
GLuint normal;
|
||||
// GLuint normal; // trying a new thing
|
||||
GLfloat nx, ny, nz;
|
||||
|
||||
} VertexDeclPTCN;
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ void drawArrayVTN(int bufferId, int vertices, int vertexSize /* = 24 */) {
|
||||
glVertexPointer2( 3, GL_FLOAT, vertexSize, 0);
|
||||
glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4));
|
||||
//glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4));
|
||||
glNormalPointer(GL_BYTE, vertexSize, (GLvoid*) (6 * 4));
|
||||
glNormalPointer(GL_FLOAT, vertexSize, (GLvoid*) (6 * 4));
|
||||
|
||||
glDrawArrays2(GL_TRIANGLES, 0, vertices);
|
||||
|
||||
@@ -145,7 +145,7 @@ void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize /* = 24 */
|
||||
glVertexPointer2( 3, GL_FLOAT, vertexSize, 0);
|
||||
glTexCoordPointer2(2, GL_FLOAT, vertexSize, (GLvoid*) (3 * 4));
|
||||
//glColorPointer2(4, GL_UNSIGNED_BYTE, vertexSize, (GLvoid*) (5*4));
|
||||
glNormalPointer(GL_BYTE, vertexSize, (GLvoid*) (6 * 4));
|
||||
glNormalPointer(GL_FLOAT, vertexSize, (GLvoid*) (6 * 4));
|
||||
|
||||
glDrawArrays2(GL_TRIANGLES, 0, vertices);
|
||||
}
|
||||
|
||||
@@ -60,17 +60,17 @@ void anGenBuffers(GLsizei n, GLuint* buffer);
|
||||
#define drawArrayVT_NoState drawArrayVT
|
||||
#define drawArrayVTC_NoState drawArrayVTC
|
||||
#define drawArrayVTN_NoState drawArrayVTN
|
||||
void drawArrayVT(int bufferId, int vertices, int vertexSize = 28, unsigned int mode = GL_TRIANGLES);
|
||||
void drawArrayVT(int bufferId, int vertices, int vertexSize = 36, unsigned int mode = GL_TRIANGLES);
|
||||
#ifndef drawArrayVT_NoState
|
||||
//void drawArrayVT_NoState(int bufferId, int vertices, int vertexSize = 28);
|
||||
//void drawArrayVT_NoState(int bufferId, int vertices, int vertexSize = 36);
|
||||
#endif
|
||||
void drawArrayVTC(int bufferId, int vertices, int vertexSize = 28);
|
||||
void drawArrayVTC(int bufferId, int vertices, int vertexSize = 36);
|
||||
#ifndef drawArrayVTC_NoState
|
||||
void drawArrayVTC_NoState(int bufferId, int vertices, int vertexSize = 28);
|
||||
void drawArrayVTC_NoState(int bufferId, int vertices, int vertexSize = 36);
|
||||
#endif
|
||||
void drawArrayVTN(int bufferId, int vertices, int vertexSize = 28);
|
||||
void drawArrayVTN(int bufferId, int vertices, int vertexSize = 36);
|
||||
#ifndef drawArrayVTN_NoState
|
||||
void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize = 28);
|
||||
void drawArrayVTCN_NoState(int bufferId, int vertices, int vertexSize = 36);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user