Exemple #1
0
        public void LoadImage(Rgba32[] data, int width, int height)
        {
            this.textureData = data;
            this.Width       = width;
            this.Height      = height;

            // create opengl texture object
            GL.ActiveTexture(GL.GL_TEXTURE0);
            this.textureObject = GL.CreateTexture();
            GL.BindTexture(GL.GL_TEXTURE_2D, this.textureObject);
            //GL.TexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, this.Width, this.Height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, this.textureData);
            //sampler settings
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, (int)GL.GL_CLAMP);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, (int)GL.GL_CLAMP);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, (int)GL.GL_LINEAR);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, (int)GL.GL_LINEAR);
            Utility.CheckWebGLError();
        }
Exemple #2
0
        /// <summary>
        /// Load an image from a file.
        /// </summary>
        /// <param name="filePath"></param>
        public void LoadImage(string filePath)
        {
            // check file header, save texture data to buffer
            using (Stream stream = Utility.ReadFile(filePath))
            {
                this.image       = Image.Load <Rgba32>(stream);
                this.textureData = this.image.GetPixelSpan().ToArray();
                this.Width       = this.image.Width;
                this.Height      = this.image.Height;
            }

            // create opengl texture object
            GL.ActiveTexture(GL.GL_TEXTURE0);
            this.textureObject = GL.CreateTexture();
            GL.BindTexture(GL.GL_TEXTURE_2D, this.textureObject);
            //GL.TexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, this.Width, this.Height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, this.textureData);
            //sampler settings
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, (int)GL.GL_CLAMP);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, (int)GL.GL_CLAMP);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, (int)GL.GL_LINEAR);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, (int)GL.GL_LINEAR);
            Utility.CheckWebGLError();
        }