Exemplo n.º 1
0
        protected ShaderProgram(string shaderName, PrimitiveType renderType)
        {
            this.renderType = renderType;
            var file = "SharpCraft_Data/assets/shaders/" + shaderName;

            VertexShaderID   = loadShader(ShaderType.VertexShader, file);
            FragmentShaderID = loadShader(ShaderType.FragmentShader, file);

            Console.WriteLine($"DEBUG: '{shaderName}' vertex shader: {(VertexShaderID != -1 ? "OK" : "ERROR")}");
            Console.WriteLine($"DEBUG: '{shaderName}' fragment shader: {(FragmentShaderID != -1 ? "OK" : "ERROR")}");

            ProgramID = GL.CreateProgram();

            GL.AttachShader(ProgramID, VertexShaderID);
            GL.AttachShader(ProgramID, FragmentShaderID);

            bindAttributes();

            GL.LinkProgram(ProgramID);
            GL.ValidateProgram(ProgramID);

            getAllUniformLocations();

            ShaderManager.registerShader(this);
        }
Exemplo n.º 2
0
        public static int CreateProgram(int vertexShaderHandle, int fragmentShaderHandle)
        {
            int shaderProgramHandle = GL.CreateProgram();

            GL.AttachShader(shaderProgramHandle, vertexShaderHandle);
            GL.AttachShader(shaderProgramHandle, fragmentShaderHandle);

            GL.LinkProgram(shaderProgramHandle);

            Console.WriteLine(GL.GetProgramInfoLog(shaderProgramHandle));
            return(shaderProgramHandle);
        }
Exemplo n.º 3
0
 public void AttachShader(GLProgramHandle program, GLShaderHandle shader)
 {
     GL.AttachShader((int)program, (int)shader);
 }