Results 1 to 3 of 3

Thread: Compile/Link InfoLog is empty

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    20

    Compile/Link InfoLog is empty

    Hello,

    I'm trying to compile and like a very simple shader and to test the InfoLogs I made a syntax-errors (in the vert-shader) on purpose. Problem is, that neither the compile-log nor the link-log are filled properly:
    I'm running a Intel HD4000 and use this two functions in C++:

    Code :
    void ShaderProgram::checkCompilationGL(int handle) {
    	GLint status = 0;
    	glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
    	if(status == GL_FALSE) {
    		GLint infoLogLength = 0;
    		glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &infoLogLength);
    		GLchar* infoLog = new GLchar[infoLogLength + 1];
    		glGetShaderInfoLog(handle, infoLogLength, 0, infoLog);
     
    		std::cout << infoLogLength << std::endl;
    		std::cout << "Error while compiling shader: " << id << std::endl;
    		std::cout << *infoLog << std::endl;
     
    		delete[] infoLog;
    	}
    }
     
    void ShaderProgram::checkValidationGL() {
    	GLint status = 0;
    	glGetProgramiv(programHandle, GL_LINK_STATUS, &status);
    	if(status == GL_FALSE) {
    		GLint infoLogLength;
    		glGetProgramiv(programHandle, GL_INFO_LOG_LENGTH, &infoLogLength);
    		GLchar* infoLog = new GLchar[infoLogLength + 1];
    		glGetProgramInfoLog(programHandle, infoLogLength, 0, infoLog);
     
    		std::cout << infoLogLength << std::endl;
    		std::cout << "Error while linking shader: " << id << std::endl;
    		std::cout << *infoLog << std::endl;
     
    		delete[] infoLog;
    	}
    }

    Output is:
    Code :
    94
    Error while compiling shader: test
    E
     
    1
    Error while linking shader

    Why doesnt the array get filled as it should be?

    Thanks!

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,671
    You're printing the string wrong.

    Code :
    std::cout << *infoLog << std::endl;

    If you have a `char*`, and you dereference it, you have a `char`. Namely, the first character. Which is exactly what you printed.

    If you want to print the string, then pass the whole string:

    Code :
    std::cout << infoLog << std::endl;

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    20
    Stupid me ... thanks!

Similar Threads

  1. GLSlang not catching compile errors, always failing to link
    By imported_JoshKlint in forum OpenGL: GLSL
    Replies: 0
    Last Post: 06-04-2016, 02:08 PM
  2. Replies: 1
    Last Post: 04-13-2016, 10:52 AM
  3. how to compile and link C with Mesa on Linux?
    By tonycq2001 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-07-2004, 02:38 PM
  4. how to compile and link C with Mesa on Linux?
    By tonycq2001 in forum OpenGL: Linux
    Replies: 1
    Last Post: 11-07-2004, 09:03 AM
  5. Can't compile, link or run
    By Trinity in forum OpenGL: Linux
    Replies: 1
    Last Post: 08-03-2001, 07:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean