OpenGL에서 버텍스 쉐이더를 컴파일하는 데 문제가 있습니다. 나는 꽤 표준 버텍스 쉐이더를 가지고 :
#version 330
layout(location=0) in vec4 in_Position;
layout(location=1) in vec4 in_Color;
out vec4 ex_Color;
void main(void)
{
gl_Position = in_Position;
ex_Color = in_Color;
}
및처럼 내 쉐이더 로딩 기능은 같습니다
INFO: OpenGL Version: 3.3.0 NVIDIA 310.19
File: vShader.v.glsl
Contents: #version 330
layout(location=0) in vec4 in_Position;
layout(location=1) in vec4 in_Color;
void main(void)
{
gl_Position = in_Position;
ex_Color = in_Color;
}
ERROR: Vertex shader not compiled properly.
compiler log:
(0) : error C0000: syntax error, unexpected $end at token "<EOF>"
: 내 프로그램을 실행할 때, 내가의 출력을 얻을
string temp = LoadFile(vShaderPath);
const char* vShaderString = temp.c_str();
const char* vShaderPathC = vShaderPath.c_str();
fprintf(stderr, "File: %s \nContents: %s\n", vShaderPathC, vShaderString);
temp = LoadFile(fShaderPath);
const char* fShaderString = temp.c_str();
vShaderHandle = glCreateShader(GL_VERTEX_SHADER);
fShaderHandle = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(vShaderHandle, 1, &vShaderString, NULL);
glShaderSource(fShaderHandle, 1, &fShaderString, NULL);
GLint compiled;
glCompileShader(vShaderHandle);
glCompileShader(fShaderHandle);
glGetShaderiv(vShaderHandle, GL_COMPILE_STATUS, &compiled);
if(compiled == false)
{
fprintf(stderr, "ERROR: Vertex shader not compiled properly.\n");
GLint blen = 0;
GLsizei slen = 0;
glGetShaderiv(vShaderHandle, GL_INFO_LOG_LENGTH , &blen);
if (blen > 1)
{
GLchar* compiler_log = new GLchar[blen];
glGetInfoLogARB(vShaderHandle, blen, &slen, compiler_log);
fprintf(stderr, "compiler log:\n %s", compiler_log);
delete [] compiler_log;
}
}
을 로드 파일 정의 :
string ShaderEffect::LoadFile(string path)
{
ifstream in(path.c_str(), ios::in);
if(in.is_open())
{
string contents;
in.seekg(0, ios::end);
contents.resize(in.tellg());
in.seekg(0, ios::beg);
in.read(&contents[0], contents.size());
in.close();
return contents;
}
else
throw "Problem reading file!";
}
나는 GLSL 코드 자체는 내가 열심히에서 문자열 코드 때문에 문제가 아니라는 것을 알고 :
const char * testvShader = {
"#version 330\n"\
"layout(location=0) in vec4 in_Position;\n"\
"layout(location=1) in vec4 in_Color;\n"\
"out vec4 ex_Color;"
"void main()\n"\
"{\n"\
" gl_Position = in_Position;\n"\
" ex_Color = in_Color;\n"\
"}"};
을 내가 프로그램 testvShader &에 & vShaderString을 전환 할 때 잘 실행됩니다. 그러나 프래그먼트 셰이더가 같은 방식으로로드되어 컴파일되고 완벽하게 실행되기 때문에 로딩이 어떻게 문제가되는지 알지 못합니다. 컴파일하기 전에 파일을 콘솔에 인쇄합니다. 나는 현명함 끝에 있고, 나는 그 문제가 무엇인지 알 수 없다.
P. Fedora에서 실행 중입니다.
방금 문제가 발생했습니다. 그건 분명히 순수 ASCII 문자를 기대하는 glsl 컴파일러가 잘못 이해 한 잘못된 숨겨진 문자를 넣는 유니 코드로 인코딩 된 텍스트 사이의 복사 붙여 넣기 작업 때문입니다. –