示例#1
0
        public void MakeTexture()
        {
            if ( Tile.PrepDevice != null)
            {
                //     PrepDevice.pixelStorei(GL.UNPACK_FLIP_Y_WEBGL, 1);

                try
                {
                    Texture2d = Tile.PrepDevice.createTexture();

                    Tile.PrepDevice.bindTexture(GL.TEXTURE_2D, Texture2d);

                    ImageElement image = ImageElement;

                    // Before we bind resize to a power of two if nessesary so we can MIPMAP
                    if (!IsPowerOfTwo(ImageElement.Height) | !IsPowerOfTwo(ImageElement.Width))
                    {
                        CanvasElement temp = (CanvasElement)Document.CreateElement("canvas");
                        temp.Height = FitPowerOfTwo(image.Height);
                        temp.Width = FitPowerOfTwo(image.Width);
                        CanvasContext2D ctx = (CanvasContext2D)temp.GetContext(Rendering.Render2D);
                        ctx.DrawImage(image, 0, 0, image.Width, image.Height);
                        //Substitute the resized image
                        image = (ImageElement)(Element)temp;
                    }

                    Tile.PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE);
                    Tile.PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE);
                    Tile.PrepDevice.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA, GL.RGBA, GL.UNSIGNED_BYTE, image);
                    Tile.PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR_MIPMAP_NEAREST);
                    Tile.PrepDevice.generateMipmap(GL.TEXTURE_2D);

                    Tile.PrepDevice.bindTexture(GL.TEXTURE_2D, null);
                }
                catch
                {
                    Errored = true;

                }
            }
        }
示例#2
0
 public bool isTexture(WebGLTexture texture)
 {
     return false; ;
 }
示例#3
0
 public void deleteTexture(WebGLTexture texture)
 {
     return;
 }
示例#4
0
 public void framebufferTexture2D(int target, int attachment, int textarget, WebGLTexture texture, int level)
 {
     return;
 }
示例#5
0
 public void bindTexture(int target, WebGLTexture texture)
 {
     return;
 }
示例#6
0
        public void MakeTexture()
        {
            if (PrepDevice != null)
            {
               //     PrepDevice.pixelStorei(GL.UNPACK_FLIP_Y_WEBGL, 1);

                try
                {
                    texture2d = PrepDevice.createTexture();

                    PrepDevice.bindTexture(GL.TEXTURE_2D, texture2d);
                    PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE);
                    PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE);
                    PrepDevice.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA, GL.RGBA, GL.UNSIGNED_BYTE, texture);
                    PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR_MIPMAP_NEAREST);
                    PrepDevice.generateMipmap(GL.TEXTURE_2D);

                    PrepDevice.bindTexture(GL.TEXTURE_2D, null);
                }
                catch
                {
                    errored = true;

                }
            }
        }
示例#7
0
        public virtual void CleanUp(bool removeFromParent)
        {
            ReadyToRender = false;
            DemData = null;
            demFile = null;
            demDownloading = false;
            texReady = false;
            DemReady = false;
            errored = false;
            if (this.texture != null)
            {
                this.texture = null;

            }

            RenderTriangleLists = new List<RenderTriangle>[4];
            GeometryCreated = false;
            if (removeFromParent && Parent != null )
            {
                Parent.RemoveChild(this);
                Parent = null;
            }

            if (PrepDevice != null)
            {
                foreach (WebGLBuffer buf in IndexBuffers)
                {
                    PrepDevice.deleteBuffer(buf);
                }
                IndexBuffers = new WebGLBuffer[4];

                if (VertexBuffer != null)
                {
                    PrepDevice.deleteBuffer(VertexBuffer);
                    VertexBuffer = null;
                }

                if (texture2d != null)
                {
                    PrepDevice.deleteTexture(texture2d);

                    texture2d = null;
                }
            }
        }
示例#8
0
        public static void Use(RenderContext renderContext, WebGLBuffer vertex, WebGLTexture texture, Color lineColor, bool zBuffer, float jNow, float decay)
        {
            GL gl = renderContext.gl;
            if (gl != null)
            {
                if (!initialized)
                {
                    Init(renderContext);
                }

                gl.useProgram(prog);

                Matrix3d mvMat = Matrix3d.MultiplyMatrix(renderContext.World, renderContext.View);

                gl.uniformMatrix4fv(mvMatLoc, false, mvMat.FloatArray());
                gl.uniformMatrix4fv(projMatLoc, false, renderContext.Projection.FloatArray());
                gl.uniform1i(sampLoc, 0);
                gl.uniform1f(jNowLoc, jNow);
                gl.uniform1f(decayLoc, decay);
                gl.uniform4f(lineColorLoc, lineColor.R / 255f, lineColor.G / 255f, lineColor.B / 255f, 1f);

                if (zBuffer)
                {
                    gl.enable(GL.DEPTH_TEST);
                }
                else
                {
                    gl.disable(GL.DEPTH_TEST);
                }
                //gl.enable(0x8642);
                gl.disableVertexAttribArray(0);
                gl.disableVertexAttribArray(1);
                gl.disableVertexAttribArray(2);
                gl.disableVertexAttribArray(3);

                gl.enableVertexAttribArray(vertLoc);
                gl.enableVertexAttribArray(colorLoc);
                gl.enableVertexAttribArray(pointSizeLoc);
                gl.enableVertexAttribArray(timeLoc);

                gl.bindBuffer(GL.ARRAY_BUFFER, vertex);
                gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, null);
                gl.vertexAttribPointer(vertLoc, 3, GL.FLOAT, false, 40, 0);
                gl.vertexAttribPointer(colorLoc, 4, GL.FLOAT, false, 40, 12);
                gl.vertexAttribPointer(pointSizeLoc, 1, GL.FLOAT, false, 40, 36);
                gl.vertexAttribPointer(timeLoc, 2, GL.FLOAT, false, 40, 28);
                gl.activeTexture(GL.TEXTURE0);
                gl.bindTexture(GL.TEXTURE_2D, texture);
                gl.lineWidth(1.0f);
                gl.blendFunc(GL.SRC_ALPHA, GL.ONE);
            }
        }
示例#9
0
        public static void Use(RenderContext renderContext, WebGLBuffer vertex, WebGLBuffer index, WebGLTexture texture)
        {
            GL gl = renderContext.gl;
            if (gl != null)
            {
                if (!initialized)
                {
                    Init(renderContext);
                }

                gl.useProgram(prog);

                Matrix3d mvMat = Matrix3d.MultiplyMatrix(renderContext.World, renderContext.View);

                gl.uniformMatrix4fv(mvMatLoc, false, mvMat.FloatArray());
                gl.uniformMatrix4fv(projMatLoc, false, renderContext.Projection.FloatArray());
                gl.uniform1i(sampLoc, 0);
                if (renderContext.Space)
                {
                    gl.disable(GL.DEPTH_TEST);
                }
                else
                {
                    gl.enable(GL.DEPTH_TEST);
                }

                gl.enableVertexAttribArray(vertLoc);
                gl.enableVertexAttribArray(textureLoc);
                gl.bindBuffer(GL.ARRAY_BUFFER, vertex);
                gl.vertexAttribPointer(vertLoc, 3, GL.FLOAT, false, 20, 0);
                gl.vertexAttribPointer(textureLoc, 2, GL.FLOAT, false, 20, 12);
                gl.activeTexture(GL.TEXTURE0);
                gl.bindTexture(GL.TEXTURE_2D, texture);
                gl.bindBuffer(GL.ELEMENT_ARRAY_BUFFER, index);
                gl.blendFunc(GL.SRC_ALPHA, GL.ONE_MINUS_SRC_ALPHA);
            }
        }