dwmkerr / sharpgl

Use OpenGL in .NET applications. SharpGL wraps all modern OpenGL features and offers a powerful scene graph to aid development.
MIT License
753 stars 300 forks source link

pass data from vertex shader to fragment shader crash #133

Closed tn88test closed 7 years ago

tn88test commented 7 years ago

Whenever I try to pass data data from vertex shader to fragment shader, my computer will crash. I tried other computer and the same crash happens.

Example: Vertex Shader

#version 330 core

layout(location = 0) in vec3 position;

out vec4 ourColor; 

void main(){    
    gl_Position =  vec4(position ,1);
    ourColor = vec4(1.0f, 0.0f, 0.0f, 1.0f);
}

Fragment Shader

#version 330 core

in vec4 ourColor;
out vec4 color;

void main()
{
    color =  ourColor;
} 
bitzhuwei commented 7 years ago

I don't see anything wrong in your shader. Maybe it's somewhere else causing crash.

tn88test commented 7 years ago

I found the problem. I forgot to use gl.UseProgram(0); after drawing. Thanks for your help.