PDA

View Full Version : Problem with Opengl extensions?



stimulate
12-31-2016, 06:10 AM
I want to compile the vertex shader:


#version 430

layout(location = 0)in vec3 vertexPosition;
layout(location = 1)in vec3 vertexNormal;
layout(location = 2)in vec2 vertexUV;

out Vertex{
vec2 uv;
vec4 normal;
}vertexOut;

void main(){
gl_Position = vec4(
vertexPosition.x,
vertexPosition.y,
vertexPosition.z,
1.0f);
vertexOut.uv = vertexUV;
vertexOut.normal = vec4(vertexNormal, 0.0f);
}

like this


pShader.ID = glCreateShader(GL_VERTEX_SHADER);
std::ifstream shaderFile;
shaderFile.open(pShader.path);

if (shaderFile.fail()) {
printf("!!!\nCannot open Shader File %s ! Shader compilation cancelled!", pShader.path.c_str());
}
else {
std::string line;
while (getline(shaderFile, line)) {
pShader.content += line + '\n';
++pShader.lines;
}
const char* shaderContent = pShader.content.c_str();
glShaderSource(pShader.ID, 1, &shaderContent, &pShader.lines);
glCompileShader(pShader.ID);
GLint success = 0;
glGetShaderiv(pShader.ID, GL_COMPILE_STATUS, &success);
if (success == GL_FALSE) {
//errror checking
}

but i am getting the compilation error


Vertex Shader failed to compile with the following errors:
ERROR: 0:3: error(#132) Syntax error "layou" parse error
ERROR: errror(#273) 1 compilation errors. No code generated


In my fragment shader i am also getting a "/" parse error, but i can find it.

I am using glew for extension loading and glfw for input and context.
When i run the glewinfo.exe there are some extensions marked as missing, but my AMD Radeon HD 7800 Drivers are up to date.. What is the problem and what am i supposed to do?

these are the glewinfo.exe results: http://m.uploadedit.com/ba3s/148318971635.txt

GClements
12-31-2016, 07:17 AM
glShaderSource(pShader.ID, 1, &shaderContent, &pShader.lines);


The last parameter (length) is the length of each string in bytes. If all of the strings are null-terminated, you can just pass a null pointer as the length parameter; if a specific string is null-terminated, you can pass a negative value for its length.

stimulate
12-31-2016, 04:41 PM
Thanks for the answer, that was the solution!