Jump to content
  • Advertisement

Recommended Posts

hello I am pretty new to glsl and opengl

I have the 2 shaders attached and they are compiled successfully but the program linking fails like in exception image attachment what wrong i did ?? , forgive about my bad english :(

BasicFS.glsl

BasicVS.glsl

exception.png

Share this post


Link to post
Share on other sites
Advertisement

Please provide some more code. The error you posted shouldn't have anything to do with OpenGL itself. Memory access violations occur if you try to read or write to a memory location that is not reserved for your program. For example, if you access the 3. element of an array which only has 2 members or if you store a reference/pointer to an object which is deleted before you use it.

 

 

Share this post


Link to post
Share on other sites

yes sure, the shader is the parent of all of my shaders it got some common functions to set uniforms and to compile , link program  and the shader info is the place where I hold path and type of shader and the entity shader is the child of shader that I am using to render that uses the attached vertex and fragment shader 

EntityShader.cs

Shader.cs

ShaderInfo.cs

Share this post


Link to post
Share on other sites
24 minutes ago, DerTroll said:

Please provide some more code. The error you posted shouldn't have anything to do with OpenGL itself. Memory access violations occur if you try to read or write to a memory location that is not reserved for your program. For example, if you access the 3. element of an array which only has 2 members or if you store a reference/pointer to an object which is deleted before you use it.

 

 

here is the full project on github      https://github.com/ahmedTohami/opentk

Share this post


Link to post
Share on other sites

Don't know much about c#, but I couldn't detect anything that looks like an obvious error. Try setting a breakpoint in each line of the foreach loop and at the linkProgram command and step through them step by step until the program crashes. Sometimes the wrong line is marked when an error occurs. If your IDE is telling the truth, you should loop through the breakpoints twice before you get to the line which links the program. Also, check the values at each breakpoint. Especially what is inside both lists.

Share this post


Link to post
Share on other sites
9 minutes ago, DerTroll said:

Don't know much about c#, but I couldn't detect anything that looks like an obvious error. Try setting a breakpoint in each line of the foreach loop and at the linkProgram command and step through them step by step until the program crashes. Sometimes the wrong line is marked when an error occurs. If your IDE is telling the truth, you should loop through the breakpoints twice before you get to the line which links the program. Also, check the values at each breakpoint. Especially what is inside both lists.

when I did what you told and I modified the fragment shader code to like in attachment and now as you see it passed sounds the problem comes from the fragment shader code 

BasicFS.glsl

passed.png

Share this post


Link to post
Share on other sites

Okay, well, in your compile function there is this one branch:

            if (!string.IsNullOrEmpty(log))
            {
                Console.WriteLine("failed to comile sahder  " + path + '\n' + log);
            }

 

Have you checked the console output when the program still crashed? As I said, I have no experience with C#, but if your shader did not compile, it does not seem like the program will stop. It just writes something to the output and goes on. In this case the access violation is not the initial error and therefore not relevant. Maybe an exception is the better choice there. Did you also check if this branch even get's triggered if there is a mistake in a shader? Put an obvious mistake into your shader and check the output of the console.

Share this post


Link to post
Share on other sites
1 minute ago, DerTroll said:

Okay, well, in your compile function there is this one branch:


            if (!string.IsNullOrEmpty(log))
            {
                Console.WriteLine("failed to comile sahder  " + path + '\n' + log);
            }

 

Have you checked the console output when the program still crashed? As I said, I have no experience with C#, but if your shader did not compile, it does not seem like the program will stop. It just writes something to the output and goes on. In this case the access violation is not the initial error and therefore not relevant. Maybe an exception is the better choice there. Did you also check if this branch even get's triggered if there is a mistake in a shader? Put an obvious mistake into your shader and check the output of the console.

yes i am working on it 

Share this post


Link to post
Share on other sites
12 minutes ago, mandolinable said:

yes i am working on it 

in the watch window something i can not understand  the compilation status is 1 that means successful how ever GL.getshader returns length = 483 for log and gl.getshaderinfolog returns an empty string how come ?

log.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!