Skip to content

Commit 457de1c

Browse files
gamehelphereminggo
authored andcommitted
Android Emulator Blank Screen 0x501 and 0x502 Problem Bugfix Update (cocos2d#18606)
1 parent c36c982 commit 457de1c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cocos/renderer/CCGLProgram.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ GLProgram::~GLProgram()
235235
GL::deleteProgram(_program);
236236
}
237237

238-
238+
239239
clearHashUniforms();
240240
}
241241

@@ -485,6 +485,9 @@ bool GLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source
485485
if (compileTimeHeaders.empty()) {
486486
#if CC_TARGET_PLATFORM == CC_PLATFORM_WINRT
487487
headersDef = (type == GL_VERTEX_SHADER ? "precision mediump float;\n precision mediump int;\n" : "precision mediump float;\n precision mediump int;\n");
488+
// Bugfix to make shader variables types constant to be understood by the current Android Virtual Devices or Emulators. This will also eliminate the 0x501 and 0x502 OpenGL Errors during emulation.
489+
#elif CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
490+
headersDef = "#version 100\n precision mediump float;\n precision mediump int;\n";
488491
#elif (CC_TARGET_PLATFORM != CC_PLATFORM_WIN32 && CC_TARGET_PLATFORM != CC_PLATFORM_LINUX && CC_TARGET_PLATFORM != CC_PLATFORM_MAC)
489492
headersDef = (type == GL_VERTEX_SHADER ? "precision highp float;\n precision highp int;\n" : "precision mediump float;\n precision mediump int;\n");
490493
#endif
@@ -925,7 +928,7 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV)
925928

926929
if (_flags.usesP)
927930
setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_P_MATRIX], matrixP.m, 1);
928-
931+
929932
if (_flags.usesMultiViewP)
930933
{
931934
Mat4 mats[4];
@@ -944,7 +947,7 @@ void GLProgram::setUniformsForBuiltins(const Mat4 &matrixMV)
944947
Mat4 matrixMVP = matrixP * matrixMV;
945948
setUniformLocationWithMatrix4fv(_builtInUniforms[UNIFORM_MVP_MATRIX], matrixMVP.m, 1);
946949
}
947-
950+
948951
if (_flags.usesMultiViewMVP)
949952
{
950953
Mat4 mats[4];
@@ -1022,4 +1025,3 @@ inline void GLProgram::clearHashUniforms()
10221025
}
10231026

10241027
NS_CC_END
1025-

0 commit comments

Comments
 (0)