Jump to content
  • Advertisement
Sign in to follow this  
kibokun

Not all shaders have valid object code.

This topic is 3048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to attach and run the simplest possible shader, and this is the error I get at runtime. ERROR: Not all shaders have valid object code. My shaders SEEM syntctically correct. It may be a problem with how I'm loading them? File loading function I did not write myself:
   FILE *fptr;
    long length;
    char *buf;

    fptr = fopen(filename, "r"); /* Open file for reading */
    if (!fptr) /* Return NULL on failure */
        return NULL;
    fseek(fptr, 0, SEEK_END); /* Seek to the end of the file */
    length = ftell(fptr); /* Find out how many bytes into the file we are */
    buf = (char*)malloc(length+1); /* Allocate a buffer for the entire length of the file and a null terminator */
    fseek(fptr, 0, SEEK_SET); /* Go back to the beginning of the file */
    fread(buf, length, 1, fptr); /* Read the contents of the file in to the buffer */
    fclose(fptr); /* Close the file */
    buf[length] = 0; /* Null terminator */

    return buf; /* Return the buffer */

Calls to set up the shader:
    vertexSource = ReadShaderFile("minimal_shader.vert");
    fragmentSource = ReadShaderFile("minimal_shader.frag");

    vertexShaderHandle = glCreateShader(GL_VERTEX_SHADER);
    fragmentShaderHandle = glCreateShader(GL_FRAGMENT_SHADER);

    glShaderSource(vertexShaderHandle, 1, (const GLchar**)&vertexSource, 0);
    glShaderSource(fragmentShaderHandle, 1, (const GLchar**)&fragmentSource, 0);

    glCompileShader(vertexShaderHandle);
    glCompileShader(fragmentShaderHandle);

    shaderProgramHandle = glCreateProgram();

    glValidateProgram(shaderProgramHandle);

    glAttachShader(shaderProgramHandle, vertexShaderHandle);
    glAttachShader(shaderProgramHandle, fragmentShaderHandle);

    glLinkProgram(shaderProgramHandle);
    glUseProgram(shaderProgramHandle);

Vertex Shader / Fragment Shader
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VERTEX SHADER
void main()
{
	gl_Position = ftransform();
} 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FRAGMENT SHADER
void main()
{
	gl_FragColor = vec4(1.0, 0.1, 0.1, 1.0);
) 

Share this post


Link to post
Share on other sites
Advertisement

void main()
{
...
) <------


Could this be your problem?

Also you should specify the version of GLSL your shaders are using with "#version XXX". And I hope that you're free'ing the buffer that your file loading function returns.

Share this post


Link to post
Share on other sites
Also, check if shader compilation (and program link) is sucessful, and print compilation infologs to aid debugging.

Share this post


Link to post
Share on other sites
Quote:
Original post by Wavarian

void main()
{
...
) <------


Could this be your problem?

Also you should specify the version of GLSL your shaders are using with "#version XXX". And I hope that you're free'ing the buffer that your file loading function returns.


If only that had fixed it. I would have been furious and elated at the same time. :) Thanks for the catch on freeing the buffer. I had that happening somewhere else dangerously far from it's creation. hah.

I'll try writing the infologs to a file. (Can't really see print output since I'm doing this in VS. How annoying.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!