public void vertexAttrib4fv(int indx, WebGLFloatArray values) { }
public void uniform4fv(WebGLUniformLocation location, WebGLFloatArray v) { }
public void uniformMatrix4fv(WebGLUniformLocation location, bool transpose, WebGLFloatArray value) { }
private void Initialize() { var gl = this.gl; // http://cs.helsinki.fi/u/ilmarihe/metatunnel.html // http://wakaba.c3.cx/w/puls.html // http://www.ibiblio.org/e-notes/webgl/barkley.html Action<string> alert = Native.window.alert; c.style.border = "1px solid yellow"; this.prog = gl.createProgram(); gl.attachShader(prog, getShader(shader_vs, gl.VERTEX_SHADER)); gl.attachShader(prog, getShader(shader_fs, gl.FRAGMENT_SHADER)); gl.linkProgram(prog); this.prog_show = gl.createProgram(); gl.attachShader(prog_show, getShader(shader_vs, gl.VERTEX_SHADER)); gl.attachShader(prog_show, getShader(shader_fs_show, gl.FRAGMENT_SHADER)); gl.linkProgram(prog_show); var posBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, posBuffer); // todo: jsc promoted float to double? :) let's revert that at the next build var vertices = new WebGLFloatArray(new [] { -1f, -1f, 0f, 1f, -1f, 0f, -1f, 1f, 0f, 1f, 1f, 0f }); var aPosLoc = gl.getAttribLocation(prog, "aPos"); gl.enableVertexAttribArray((uint)aPosLoc); var aTexLoc = gl.getAttribLocation(prog, "aTexCoord"); gl.enableVertexAttribArray((uint)aTexLoc); var texCoords = new WebGLFloatArray(new [] { 0f, 0f, 1f, 0f, 0f, 1f, 1f, 1f }); var texCoordOffset = vertices.byteLength; gl.bufferData(gl.ARRAY_BUFFER, (int)(texCoordOffset + texCoords.byteLength), gl.STATIC_DRAW); gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertices); gl.bufferSubData(gl.ARRAY_BUFFER, (int)texCoordOffset, texCoords); gl.vertexAttribPointer((uint)aPosLoc, 3, gl.FLOAT, false, 0, 0); gl.vertexAttribPointer((uint)aTexLoc, 2, gl.FLOAT, false, 0, (int)texCoordOffset); this.texture = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, texture); gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); var pixels = new List<byte>(); var tSize = 512; #region why is this here below dynamic? :) jsc could optimize? for (var i = 0; i < tSize; i++) for (var j = 0; j < tSize; j++) { pixels.Add(0); pixels.Add(0); pixels.Add(0); pixels.Add(0); } #endregion for (var i = 257; i < 512; i++) { pixels[4 * (256 * tSize + i)] = 250; pixels[4 * (255 * tSize + i) + 1] = 55; } gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, tSize, tSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, new WebGLUnsignedByteArray(pixels.ToArray())); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, (int)gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, (int)gl.CLAMP_TO_EDGE); this.texture2 = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, texture2); gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, tSize, tSize, 0, gl.RGBA, gl.UNSIGNED_BYTE, new WebGLUnsignedByteArray(pixels.ToArray())); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, (int)gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, (int)gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, (int)gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, (int)gl.CLAMP_TO_EDGE); this.FBO = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, FBO); gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0); this.FBO2 = gl.createFramebuffer(); gl.bindFramebuffer(gl.FRAMEBUFFER, FBO2); gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture2, 0); gl.useProgram(prog); gl.uniform1f(gl.getUniformLocation(prog, "a"), a); gl.uniform1f(gl.getUniformLocation(prog, "ba"), b / a); gl.uniform1f(gl.getUniformLocation(prog, "dt"), dt); gl.uniform1f(gl.getUniformLocation(prog, "dte"), dt / eps); gl.uniform1f(gl.getUniformLocation(prog, "dth2"), dt / (h * h)); gl.uniform1i(gl.getUniformLocation(prog, "uTexSamp"), 0); gl.useProgram(prog_show); gl.uniform1i(gl.getUniformLocation(prog_show, "uTexSamp"), 0); Action draw = this.draw; draw.AtInterval(delay); c.style.border = "1px solid green"; }