Example #1
0
        public static __WebGLProgram createAndLinkProgram(this gl gl, __WebGLShader vertexShaderHandle, __WebGLShader fragmentShaderHandle, params string[] attributes)
        {
            var programHandle = gl.createProgram();


            // Bind the vertex shader to the program.
            gl.attachShader(programHandle, vertexShaderHandle);

            // Bind the fragment shader to the program.
            gl.attachShader(programHandle, fragmentShaderHandle);

            // Bind attributes
            if (attributes != null)
            {
                int size = attributes.Length;
                for (int i = 0; i < size; i++)
                {
                    GLES20.glBindAttribLocation(programHandle.value, i, attributes[i]);
                }
            }

            // Link the two shaders together into a program.
            gl.linkProgram(programHandle);

            // Get the link status.
            int[] linkStatus = new int[1];
            GLES20.glGetProgramiv(programHandle.value, GLES20.GL_LINK_STATUS, linkStatus, 0);

            // If the link failed, delete the program.
            if (linkStatus[0] == 0)
            {
                Log.e("createAndLinkProgram", GLES20.glGetProgramInfoLog(programHandle.value));
                gl.deleteProgram(programHandle);
                programHandle = null;
            }

            //if (programHandle == 0)
            //{
            //    throw null;
            //    //throw new RuntimeException("Error creating program.");
            //}

            return(programHandle);
        }
 internal void attachShader(__WebGLProgram program, __WebGLShader vertexShader)
 {
     GLES20.glAttachShader(program, vertexShader);
 }
 internal void deleteShader(__WebGLShader shaderHandle)
 {
     GLES20.glDeleteShader(shaderHandle);
 }
 internal void compileShader(__WebGLShader shaderHandle)
 {
     GLES20.glCompileShader(shaderHandle);
 }
 internal void shaderSource(__WebGLShader shaderHandle, string shaderSource)
 {
     GLES20.glShaderSource(shaderHandle, shaderSource);
 }
Example #6
0
 internal void attachShader(__WebGLProgram program, __WebGLShader vertexShader)
 {
     GLES20.glAttachShader(program, vertexShader);
 }
Example #7
0
 internal void deleteShader(__WebGLShader shaderHandle)
 {
     GLES20.glDeleteShader(shaderHandle);
 }
Example #8
0
 internal void compileShader(__WebGLShader shaderHandle)
 {
     GLES20.glCompileShader(shaderHandle);
 }
Example #9
0
 internal void shaderSource(__WebGLShader shaderHandle, string shaderSource)
 {
     GLES20.glShaderSource(shaderHandle, shaderSource);
 }
Example #10
0
        public static __WebGLProgram createAndLinkProgram(this gl gl, __WebGLShader vertexShaderHandle, __WebGLShader fragmentShaderHandle, params string[] attributes)
        {
            var programHandle = gl.createProgram();


            // Bind the vertex shader to the program.
            gl.attachShader(programHandle, vertexShaderHandle);

            // Bind the fragment shader to the program.
            gl.attachShader(programHandle, fragmentShaderHandle);

            // Bind attributes
            if (attributes != null)
            {
                int size = attributes.Length;
                for (int i = 0; i < size; i++)
                {
                    GLES20.glBindAttribLocation(programHandle.value, i, attributes[i]);
                }
            }

            // Link the two shaders together into a program.
            gl.linkProgram(programHandle);

            // Get the link status.
            int[] linkStatus = new int[1];
            GLES20.glGetProgramiv(programHandle.value, GLES20.GL_LINK_STATUS, linkStatus, 0);

            // If the link failed, delete the program.
            if (linkStatus[0] == 0)
            {
                Log.e("createAndLinkProgram", GLES20.glGetProgramInfoLog(programHandle.value));
                gl.deleteProgram(programHandle);
                programHandle = null;
            }

            //if (programHandle == 0)
            //{
            //    throw null;
            //    //throw new RuntimeException("Error creating program.");
            //}

            return programHandle;
        }