public ShaderProgramGL3x( string vertexShaderSource, string geometryShaderSource, string fragmentShaderSource) { _vertexShader = new ShaderObjectGL3x(ShaderType.VertexShader, vertexShaderSource); if (geometryShaderSource.Length > 0) { _geometryShader = new ShaderObjectGL3x(ShaderType.GeometryShaderExt, geometryShaderSource); } _fragmentShader = new ShaderObjectGL3x(ShaderType.FragmentShader, fragmentShaderSource); _program = new ShaderProgramNameGL3x(); int programHandle = _program.Value; GL.AttachShader(programHandle, _vertexShader.Handle); if (geometryShaderSource.Length > 0) { GL.AttachShader(programHandle, _geometryShader.Handle); } GL.AttachShader(programHandle, _fragmentShader.Handle); GL.LinkProgram(programHandle); int linkStatus; GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out linkStatus); if (linkStatus == 0) { throw new CouldNotCreateVideoCardResourceException("Could not link shader program. Link Log: \n\n" + ProgramInfoLog); } _fragmentOutputs = new FragmentOutputsGL3x(_program); _vertexAttributes = FindVertexAttributes(_program); _dirtyUniforms = new List <ICleanable>(); _uniforms = FindUniforms(_program); _uniformBlocks = FindUniformBlocks(_program); InitializeAutomaticUniforms(_uniforms); }
public ShaderProgramGL3x( string vertexShaderSource, string geometryShaderSource, string fragmentShaderSource) { _vertexShader = new ShaderObjectGL3x(ShaderType.VertexShader, vertexShaderSource); if (geometryShaderSource.Length > 0) { _geometryShader = new ShaderObjectGL3x(ShaderType.GeometryShaderExt, geometryShaderSource); } _fragmentShader = new ShaderObjectGL3x(ShaderType.FragmentShader, fragmentShaderSource); _program = new ShaderProgramNameGL3x(); int programHandle = _program.Value; GL.AttachShader(programHandle, _vertexShader.Handle); if (geometryShaderSource.Length > 0) { GL.AttachShader(programHandle, _geometryShader.Handle); } GL.AttachShader(programHandle, _fragmentShader.Handle); GL.LinkProgram(programHandle); int linkStatus; GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out linkStatus); if (linkStatus == 0) { throw new CouldNotCreateVideoCardResourceException("Could not link shader program. Link Log: \n\n" + ProgramInfoLog); } _fragmentOutputs = new FragmentOutputsGL3x(_program); _vertexAttributes = FindVertexAttributes(_program); _dirtyUniforms = new List<ICleanable>(); _uniforms = FindUniforms(_program); _uniformBlocks = FindUniformBlocks(_program); InitializeAutomaticUniforms(_uniforms); }