Jump to content
  • Advertisement
Sign in to follow this  
soconne

Help with GSL error

This topic is 4814 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 getting the following errors after creating a shader program. Here are both of my shaders and the simple code that initializes it. vertex shader
void main()
{			
	// get texture unit 0 coords
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

	// get vertex position
	gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;
}



fragment shader

uniform sampler2D MyTexture;
void main()
{
	vec4 color = texture2D(MyTexture, gl_TexCoords[0].st);
	gl_FragColor = color;
}



Initialization code
        // load shader files
        const char *vertexSource = loadShader(vertex);
        const char *fragmentSource = loadShader(fragment);

        // create program
        m_program = glCreateProgramObjectARB();

        // load vertex shader
        if(vertexSource)
        {
                m_vertexShaderLoaded = true;
                m_vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
                glShaderSourceARB(m_vertexShader, 1, &vertexSource, 0);
                glCompileShaderARB(m_vertexShader);
                glAttachObjectARB(m_program, m_vertexShader);

                int infologLength = 0;
                int charsWritten  = 0;
                char *infoLog;

                glGetObjectParameterivARB(m_program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength);

                if (infologLength > 0)
                {
                        infoLog = (char *)malloc(infologLength);
		        glGetInfoLogARB(m_program, infologLength, &charsWritten, infoLog);

                        ShowMessage(infoLog);
		        free(infoLog);
                }
        }
        else m_vertexShaderLoaded = false;
           
        // load fragment shader
        if(fragmentSource)
        {
                m_fragmentShaderLoaded = true;
                m_fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
                glShaderSourceARB(m_fragmentShader, 1, &fragmentSource, 0);
                glCompileShaderARB(m_fragmentShader);
                glAttachObjectARB(m_program, m_fragmentShader);

                int infologLength = 0;
                int charsWritten  = 0;
                char *infoLog;

                glGetObjectParameterivARB(m_program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength);

                if (infologLength > 0)
                {
                        infoLog = (char *)malloc(infologLength);
		        glGetInfoLogARB(m_program, infologLength, &charsWritten, infoLog);

                        ShowMessage(infoLog);
		        free(infoLog);
                }
        }
        else m_fragmentShaderLoaded = false;

        // link program
        glLinkProgramARB(m_program);
        glUseProgramObjectARB(m_program);

        int infologLength = 0;
        int charsWritten  = 0;
        char *infoLog;

        glGetObjectParameterivARB(m_program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength);

        if (infologLength > 0)
        {
                infoLog = (char *)malloc(infologLength);
                glGetInfoLogARB(m_program, infologLength, &charsWritten, infoLog);

                ShowMessage(infoLog);
                free(infoLog);
        }

        // disable shader
        glUseProgramObjectARB(0);



Does anybody know why I'm getting these errors ? The fragment and vertex shader will still run, because if I set the gl_FragColor to be red for instance, it works. But because of these errors, if I try and call glGetUniformLocationARB it ALWAYS returns -1. So I can't pass variables or textures in at all.

Share this post


Link to post
Share on other sites
Advertisement
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!