將所有着色器移至ES3.0後,我的compileShader在第一行發生故障。移動到ES 3.0後,頂點着色器不會編譯IOS
#version 300
它給出了一個語法錯誤: 錯誤:0:2: '':語法錯誤:的#Version
如果這是錯誤的版本,那麼我本來期望得到不受支持的版本,沒有語法錯誤。所以這令人困惑,爲什麼它不會識別語法。我檢查了傳遞給編譯着色器的源代碼,它以#version 300 \ n \ n \ n清晰地開始。
設置上下文後,我的版本是「OpenGL ES 3.0 Apple A7 GPU-95.16」。
這是我如何編譯:
GLint status;
const GLchar *source;
source = (GLchar *) [ [ NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil ] UTF8String ];
if (!source)
{
DebugLog(@"Failed to load shader %@", file);
return FALSE;
}
*shader = glCreateShader(type);
glShaderSource(*shader, 1, &source, NULL);
glCompileShader(*shader);
請出示完整的着色器,以及如何加載/編譯。 – BDL
我只是設法超越了錯誤。如果我使用#version核心,它能夠處理語法。 – nishant