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);
|
glGetShaderiv(_shader, GL_COMPILE_STATUS, &status);
|
||||||
if (!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();
|
deleteShader();
|
||||||
CCASSERT(false, "Shader compile failed!");
|
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()
|
void ShaderModuleGL::deleteShader()
|
||||||
{
|
{
|
||||||
if (_shader)
|
if (_shader)
|
||||||
|
|
|
@ -55,7 +55,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void compileShader(ShaderStage stage, const std::string& source);
|
void compileShader(ShaderStage stage, const std::string& source);
|
||||||
char* getErrorLog(GLuint shader) const;
|
|
||||||
void deleteShader();
|
void deleteShader();
|
||||||
|
|
||||||
GLuint _shader = 0;
|
GLuint _shader = 0;
|
||||||
|
|
Loading…
Reference in New Issue