当前位置: 首页>>代码示例>>C#>>正文


C# Texture.Initialize方法代码示例

本文整理汇总了C#中Texture.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.Initialize方法的具体用法?C# Texture.Initialize怎么用?C# Texture.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture的用法示例。


在下文中一共展示了Texture.Initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DumpBufferTexture

 /// <summary>
 /// Dump a <see cref="Texture"/> filled with this <see cref="Buffer"/>.
 /// </summary>
 /// <param name="internalFormat"></param>
 /// <param name="autoDispose">Dispose this buffer when disposing returned texture.</param>
 /// <returns></returns>
 public Texture DumpBufferTexture(uint internalFormat, bool autoDispose)
 {
     var texture = new Texture(TextureTarget.TextureBuffer,
         new TexBufferImageFiller(internalFormat, this, autoDispose),
         new NullSampler());
     texture.Initialize();
     return texture;
 }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:14,代码来源:Buffer.BufferTexture.cs

示例2: DoInitialize

        protected override void DoInitialize()
        {
            base.DoInitialize();

            var bitmap = new Bitmap(@"Resources\data\KleinBottle.png");
            var texture = new Texture(TextureTarget.Texture1D,
                bitmap, new SamplerParameters());
            texture.Initialize();
            bitmap.Dispose();
            this.SetUniform("tex", texture);
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:11,代码来源:KleinBottleRenderer.cs

示例3: InitFace2DTexture

        private Texture InitFace2DTexture(int width, int height)
        {
            if (this.backface2DTexture != null) { this.backface2DTexture.Dispose(); }

            var texture = new Texture(
                TextureTarget.Texture2D,
                new NullImageFiller(width, height, OpenGL.GL_RGBA16F, OpenGL.GL_RGBA, OpenGL.GL_FLOAT),
                new SamplerParameters(TextureWrapping.Repeat, TextureWrapping.Repeat, TextureWrapping.Repeat, TextureFilter.Nearest, TextureFilter.Nearest));
            texture.Initialize();

            return texture;
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:12,代码来源:RaycastVolumeRenderer.Initialize.cs

示例4: DoInitialize

        protected override void DoInitialize()
        {
            base.DoInitialize();

            lastTime = DateTime.Now;

            var bitmap = new Bitmap(@"Textures\sunColor.png");
            var texture = new Texture(TextureTarget.Texture1D, bitmap, new SamplerParameters());
            texture.Initialize();
            bitmap.Dispose();
            this.SetUniform("sunColor", texture);
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:12,代码来源:SimplexNoiseRenderer.DoInitialize.cs

示例5: UpdateTexture

        internal void UpdateTexture(string filename)
        {
            // This is the texture that the compute program will write into
            var bitmap = new System.Drawing.Bitmap(filename);
            var texture = new Texture(TextureTarget.Texture2D, bitmap, new SamplerParameters());
            texture.Initialize();
            bitmap.Dispose();
            Texture old = this.spriteTexture;
            this.spriteTexture = texture;
            this.SetUniform("sprite_texture", texture);

            old.Dispose();
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:13,代码来源:PointSpriteRenderer.cs

示例6: DoInitialize

 protected override void DoInitialize()
 {
     {
         // This is the texture that the compute program will write into
         var bitmap = new System.Drawing.Bitmap(@"Textures\PointSprite.png");
         var texture = new Texture(TextureTarget.Texture2D, bitmap, new SamplerParameters());
         texture.Initialize();
         bitmap.Dispose();
         this.spriteTexture = texture;
     }
     base.DoInitialize();
     this.SetUniform("spriteTexture", this.spriteTexture);
     this.SetUniform("factor", 50.0f);
 }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:14,代码来源:PointSpriteRenderer.cs

示例7: SetupTexture

        public void SetupTexture(Bitmap bitmap)
        {
            if (this.texture != null)
            {
                this.texture.Dispose();
            }

            var texture = new Texture(TextureTarget.Texture2D,
                bitmap, new SamplerParameters(
                    TextureWrapping.Repeat, TextureWrapping.Repeat, TextureWrapping.Repeat,
                    TextureFilter.Linear, TextureFilter.Linear));
            texture.Initialize();
            this.SetUniform("u_texture", texture);
            this.texture = texture;
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:15,代码来源:GreyFilterRenderer.cs

示例8: GetFontTexture

 /// <summary>
 /// Gets an instance of <see cref="FontTexture"/>.
 /// </summary>
 /// <param name="fontBitmap"></param>
 /// <param name="parameters"></param>
 /// <param name="mipmapFiltering"></param>
 /// <returns></returns>
 public static FontTexture GetFontTexture(this FontBitmap fontBitmap,
     SamplerParameters parameters = null,
     MipmapFilter mipmapFiltering = MipmapFilter.LinearMipmapLinear)
 {
     var texture = new Texture(
         TextureTarget.Texture2D,
         fontBitmap.GlyphBitmap,
         parameters, mipmapFiltering);
     texture.Initialize();
     var result = new FontTexture();
     result.GlyphFont = fontBitmap.GlyphFont;
     result.GlyphHeight = fontBitmap.GlyphHeight;
     result.TextureSize = fontBitmap.GlyphBitmap.Size;
     result.GlyphInfoDictionary = fontBitmap.GlyphInfoDictionary;
     result.TextureObj = texture;
     return result;
 }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:24,代码来源:FontTextureHelper.cs

示例9: DoInitialize

        protected override void DoInitialize()
        {
            base.DoInitialize();

            {
                var texture = new Texture(TextureTarget.Texture2D,
                    new NullImageFiller(TEXTURE_SIZE, TEXTURE_SIZE, OpenGL.GL_RGB, OpenGL.GL_RGB, OpenGL.GL_UNSIGNED_BYTE),
                    new SamplerParameters(
                        TextureWrapping.Repeat,
                        TextureWrapping.Repeat,
                        TextureWrapping.Repeat,
                        TextureFilter.Linear,
                        TextureFilter.Linear));
                texture.ActiveTextureIndex = 1;
                texture.Initialize();
                this.mirrorTexture = texture;
            }
            {
                Renderbuffer depthBuffer = Renderbuffer.CreateDepthbuffer(TEXTURE_SIZE, TEXTURE_SIZE, DepthComponentType.DepthComponent);
                var framebuffer = new Framebuffer();
                framebuffer.Bind();
                framebuffer.Attach(this.mirrorTexture);
                framebuffer.Attach(depthBuffer);
                framebuffer.CheckCompleteness();
                this.framebuffer = framebuffer;
            }

            {
                mat4 view = glm.lookAt(new vec3(0.0f, 0.0f, 5.0f), new vec3(0.0f, 0.0f, 0.0f), new vec3(0.0f, 1.0f, 0.0f));
                this.SetUniform("u_modelViewMatrix", view);
                mat4 projection = glm.ortho(-(float)TEXTURE_SIZE / 2, (float)TEXTURE_SIZE / 2, -(float)TEXTURE_SIZE / 2, (float)TEXTURE_SIZE / 2, 1.0f, 100.0f);
                this.SetUniform("u_projectionMatrix", projection);
                this.SetUniform("u_waterPlaneLength", (float)this.waterPlaneLength);
            }

            this.viewportState = new ViewportState(0, 0, TEXTURE_SIZE, TEXTURE_SIZE);
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:37,代码来源:WaterTextureRenderer.DoInitialize.cs

示例10: initVol3DTex

        private Texture initVol3DTex(string filename, int width, int height, int depth)
        {
            var texture = new Texture(
                TextureTarget.Texture3D,
                new RaycastVolumeImageFiller(filename, width, height, depth),
                new SamplerParameters(TextureWrapping.Repeat, TextureWrapping.Repeat, TextureWrapping.Repeat, TextureFilter.Linear, TextureFilter.Linear));
            texture.Initialize();

            return texture;
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:10,代码来源:RaycastVolumeRenderer.Initialize.cs

示例11: CopyTo

        /// <summary>
        /// Copies the drawing image to a texture image.
        /// </summary>
        /// <param name="textureImage">The texture image.</param>
        public void CopyTo(Texture.TextureImage textureImage)
        {
            if (textureImage == null)
            {
                throw new ArgumentNullException(nameof(textureImage));
            }

            this.image.PinAsReadOnly(data => textureImage.Initialize(this.Width, this.Height, GL.BGRA, data));
        }
开发者ID:vetuomia,项目名称:rocket,代码行数:13,代码来源:Drawing.cs

示例12: DoInitialize

        protected override void DoInitialize()
        {
            {
                // Initialize our compute program
                var shaderCode = new ShaderCode(File.ReadAllText(@"shaders\SimpleComputeRenderer\compute.comp"), ShaderType.ComputeShader);
                this.computeProgram = shaderCode.CreateProgram();
            }
            {
                // Initialize our resetProgram
                var shaderCode = new ShaderCode(File.ReadAllText(@"shaders\SimpleComputeRenderer\computeReset.comp"), ShaderType.ComputeShader);
                this.computeResetProgram = shaderCode.CreateProgram();
            }
            {
                // This is the texture that the compute program will write into
                var texture = new Texture(TextureTarget.Texture2D,
                    new TexStorage2DImageFiller(8, OpenGL.GL_RGBA32F, 256, 256),
                    new NullSampler());
                texture.Initialize();
                this.outputImage = texture;
            }
            {
                this.GroupX = 1;
                this.GroupY = 1;
                this.GroupZ = 1;
            }
            base.DoInitialize();

            this.SetUniform("output_image", this.outputImage);
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:29,代码来源:SimpleComputeRenderer.cs

示例13: DoInitialize

 protected override void DoInitialize()
 {
     this.buildListsRenderer.Initialize();
     this.resolve_lists.Initialize();
     {
         var texture = new Texture(TextureTarget.Texture2D,
             new NullImageFiller(MAX_FRAMEBUFFER_WIDTH, MAX_FRAMEBUFFER_HEIGHT, OpenGL.GL_R32UI, OpenGL.GL_RED_INTEGER, OpenGL.GL_UNSIGNED_BYTE),
             new SamplerParameters(TextureWrapping.Repeat, TextureWrapping.Repeat, TextureWrapping.Repeat, TextureFilter.Nearest, TextureFilter.Nearest));
         texture.Initialize();
         this.headTexture = texture;
         OpenGL.BindImageTexture(0, this.headTexture.Id, 0, true, 0, OpenGL.GL_READ_WRITE, OpenGL.GL_R32UI);
     }
     // Create buffer for clearing the head pointer texture
     {
         const int length = MAX_FRAMEBUFFER_WIDTH * MAX_FRAMEBUFFER_HEIGHT;
         PixelUnpackBuffer buffer = PixelUnpackBuffer.Create(typeof(uint), length, BufferUsage.StaticDraw);
         // NOTE: not all initial values are zero in this unmanged array.
         // initialize buffer's value to 0.
         //unsafe
         //{
         //    IntPtr pointer = ptr.MapBuffer(MapBufferAccess.WriteOnly);
         //    var array = (uint*)pointer.ToPointer();
         //    for (int i = 0; i < MAX_FRAMEBUFFER_WIDTH * MAX_FRAMEBUFFER_HEIGHT; i++)
         //    {
         //        array[i] = 0;
         //    }
         //}
         // another way to initialize buffer's value to 0.
         //using (var data = new UnmanagedArray<uint>(1))
         //{
         //    data[0] = 0;
         //    ptr.ClearBufferData(OpenGL.GL_UNSIGNED_INT, OpenGL.GL_RED, OpenGL.GL_UNSIGNED_INT, data);
         //}
         this.headClearBuffer = buffer;
     }
     // Create the atomic counter buffer
     {
         const int length = 1;
         AtomicCounterBuffer buffer = AtomicCounterBuffer.Create(typeof(uint), length, BufferUsage.DynamicCopy);
         // another way to do this:
         //uint data = 1;
         //AtomicCounterBuffer buffer = data.GenAtomicCounterBuffer(BufferUsage.DynamicCopy);
         this.atomicCountBuffer = buffer;
     }
     // Bind it to a texture (for use as a TBO)
     {
         const int length = MAX_FRAMEBUFFER_WIDTH * MAX_FRAMEBUFFER_HEIGHT * 3;
         TextureBuffer buffer = TextureBuffer.Create(typeof(vec4), length, BufferUsage.DynamicCopy);
         Texture texture = buffer.DumpBufferTexture(OpenGL.GL_RGBA32UI, autoDispose: true);
         texture.Initialize();
         buffer.Dispose();// dispose it ASAP.
         this.linkedListTexture = texture;
     }
     {
         //TextureBuffer buffer = TextureBuffer.Create()
     }
     {
         OpenGL.BindImageTexture(1, this.linkedListTexture.Id, 0, false, 0, OpenGL.GL_WRITE_ONLY, OpenGL.GL_RGBA32UI);
     }
     OpenGL.ClearDepth(1.0f);
 }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:61,代码来源:OrderIndependentTransparencyRenderer.cs

示例14: DoInitialize

        protected override void DoInitialize()
        {
            base.DoInitialize();

            var bitmap = new Bitmap(@"Textures\ExampleBillboard.png");
            var texture = new Texture(TextureTarget.Texture2D, bitmap, new SamplerParameters());
            texture.Initialize();
            bitmap.Dispose();
            this.SetUniform("myTextureSampler", texture);
        }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:10,代码来源:BillboardRenderer.cs

示例15: InitTFF1DTexture

 private Texture InitTFF1DTexture(string filename)
 {
     byte[] tff;
     using (var fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
     using (var br = new BinaryReader(fs))
     {
         tff = br.ReadBytes((int)fs.Length);
     }
     var texture = new Texture(
         TextureTarget.Texture1D,
         new ByteImageFiller(tff, 256),
         new SamplerParameters(TextureWrapping.Repeat, TextureWrapping.Repeat, TextureWrapping.Repeat, TextureFilter.Nearest, TextureFilter.Nearest));
     texture.Initialize();
     return texture;
 }
开发者ID:bitzhuwei,项目名称:CSharpGL,代码行数:15,代码来源:RaycastVolumeRenderer.Initialize.cs


注:本文中的Texture.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。