Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Problem with Opengl extensions?

  1. #1
    Intern Newbie
    Join Date
    Oct 2016
    Posts
    30

    Problem with Opengl extensions?

    I want to compile the vertex shader:
    Code :
    #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
    Code :
    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
    Code :
    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

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,140
    Quote Originally Posted by stimulate View Post
    Code :
    	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.

  3. #3
    Intern Newbie
    Join Date
    Oct 2016
    Posts
    30
    Thanks for the answer, that was the solution!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •