vertex shader does not need header define (#19785)

This commit is contained in:
coulsonwang 2019-06-04 10:43:19 +08:00 committed by minggo
parent bf93892ec9
commit 7c29811c81
1 changed files with 10 additions and 7 deletions

View File

@ -13,15 +13,18 @@ CC_BACKEND_BEGIN
ProgramGL::ProgramGL(const std::string& vertexShader, const std::string& fragmentShader)
: Program(vertexShader, fragmentShader)
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
std::string headersDef("#version 100\n precision highp float;\n precision highp int;\n");
_vertexShader.insert(0, headersDef);
_fragmentShader.insert(0, headersDef);
#endif
_vertexShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newVertexShaderModule(_vertexShader));
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
std::string headersDef("#ifdef GL_FRAGMENT_PRECISION_HIGH\n" \
"precision highp float;\n precision highp int;\n" \
"#else\n" \
"precision mediump float;\n precision mediump int;\n"
"#endif\n");
headersDef.append(fragmentShader);
_fragmentShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newFragmentShaderModule(headersDef));
#else
_fragmentShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newFragmentShaderModule(_fragmentShader));
#endif
CC_SAFE_RETAIN(_vertexShaderModule);
CC_SAFE_RETAIN(_fragmentShaderModule);