mirror of https://github.com/axmolengine/axmol.git
fix shader header defines (#20077)
This commit is contained in:
parent
b4d0522116
commit
f97717265b
|
@ -32,21 +32,18 @@
|
|||
#include "renderer/backend/opengl/UtilsGL.h"
|
||||
|
||||
CC_BACKEND_BEGIN
|
||||
|
||||
namespace {
|
||||
std::string vsPreDefine("#version 100\n precision highp float;\n precision highp int;\n");
|
||||
std::string fsPreDefine("precision mediump float;\n precision mediump int;\n");
|
||||
}
|
||||
|
||||
ProgramGL::ProgramGL(const std::string& vertexShader, const std::string& fragmentShader)
|
||||
: Program(vertexShader, fragmentShader)
|
||||
{
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||
//some device required manually specify the precision qualifiers for vertex shader.
|
||||
std::string vsPreDefine("#version 100\n precision highp float;\n precision highp int;\n");
|
||||
std::string fsPreDefine("precision mediump float;\n precision mediump int;\n");
|
||||
vsPreDefine.append(vertexShader);
|
||||
fsPreDefine.append(fragmentShader);
|
||||
_vertexShader = std::move(vsPreDefine);
|
||||
_fragmentShader = std::move(fsPreDefine);
|
||||
_vertexShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newVertexShaderModule(_vertexShader));
|
||||
_fragmentShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newFragmentShaderModule(_fragmentShader));
|
||||
_vertexShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newVertexShaderModule(std::move(vsPreDefine + _vertexShader)));
|
||||
_fragmentShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newFragmentShaderModule(std::move(fsPreDefine + _fragmentShader)));
|
||||
#else
|
||||
_vertexShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newVertexShaderModule(_vertexShader));
|
||||
_fragmentShaderModule = static_cast<ShaderModuleGL*>(ShaderCache::newFragmentShaderModule(_fragmentShader));
|
||||
|
@ -91,8 +88,8 @@ void ProgramGL::reloadProgram()
|
|||
_activeUniformInfos.clear();
|
||||
_mapToCurrentActiveLocation.clear();
|
||||
_mapToOriginalLocation.clear();
|
||||
static_cast<ShaderModuleGL*>(_vertexShaderModule)->compileShader(backend::ShaderStage::VERTEX, _vertexShader);
|
||||
static_cast<ShaderModuleGL*>(_fragmentShaderModule)->compileShader(backend::ShaderStage::FRAGMENT, _fragmentShader);
|
||||
static_cast<ShaderModuleGL*>(_vertexShaderModule)->compileShader(backend::ShaderStage::VERTEX, std::move(vsPreDefine + _vertexShader));
|
||||
static_cast<ShaderModuleGL*>(_fragmentShaderModule)->compileShader(backend::ShaderStage::FRAGMENT, std::move(fsPreDefine + _fragmentShader));
|
||||
compileProgram();
|
||||
computeUniformInfos();
|
||||
|
||||
|
|
Loading…
Reference in New Issue