mirror of https://github.com/axmolengine/axmol.git
Fix #360
This commit is contained in:
parent
5a9fe68c35
commit
7d0395ee26
|
@ -56,21 +56,23 @@ void ShaderModuleGL::compileShader(ShaderStage stage, const std::string &source)
|
|||
glGetShaderiv(_shader, GL_COMPILE_STATUS, &status);
|
||||
if (!status)
|
||||
{
|
||||
cocos2d::log("cocos2d: ERROR: Failed to compile shader, detail: %s\n%s", getErrorLog(_shader), source.c_str());
|
||||
GLint logLength = 0;
|
||||
glGetShaderiv(_shader, GL_INFO_LOG_LENGTH, &logLength);
|
||||
|
||||
if (logLength > 1) {
|
||||
cocos2d::Data errorLog{};
|
||||
glGetShaderInfoLog(_shader, logLength, nullptr, (char*) errorLog.resize(logLength));
|
||||
cocos2d::log("cocos2d: ERROR: Failed to compile shader, detail: %s\n%s", errorLog.getBytes(), source.c_str());
|
||||
}
|
||||
else {
|
||||
cocos2d::log("cocos2d: ERROR: Failed to compile shader without errors.");
|
||||
}
|
||||
|
||||
deleteShader();
|
||||
CCASSERT(false, "Shader compile failed!");
|
||||
}
|
||||
}
|
||||
|
||||
char* ShaderModuleGL::getErrorLog(GLuint shader) const
|
||||
{
|
||||
GLint logLength = 0;
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLength);
|
||||
char* log = (char*)malloc(sizeof(char) * logLength);
|
||||
glGetShaderInfoLog(shader, logLength, nullptr, log);
|
||||
return log;
|
||||
}
|
||||
|
||||
void ShaderModuleGL::deleteShader()
|
||||
{
|
||||
if (_shader)
|
||||
|
|
|
@ -55,7 +55,6 @@ public:
|
|||
|
||||
private:
|
||||
void compileShader(ShaderStage stage, const std::string& source);
|
||||
char* getErrorLog(GLuint shader) const;
|
||||
void deleteShader();
|
||||
|
||||
GLuint _shader = 0;
|
||||
|
|
Loading…
Reference in New Issue