Beispiel #1
0
            /// <summary>
            /// Create the texture, using this technique.
            /// </summary>
            /// <param name="ctx">
            /// A <see cref="GraphicsContext"/> used for allocating resources.
            /// </param>
            public override void Create(GraphicsContext ctx)
            {
                int         internalFormat = Pixel.GetGlInternalFormat(_PixelFormat, ctx);
                PixelFormat format         = Pixel.GetGlFormat(_PixelFormat);

                // Define empty texture
                Gl.TexImage1D(TextureTarget.Texture1d, (int)_Level, internalFormat, (int)_Width, 0, format, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero);
                // Define texture properties
                _Texture1d.DefineExtents(_PixelFormat, _Width, 1, 1, _Level);
            }
Beispiel #2
0
            /// <summary>
            /// Create the texture, using this technique.
            /// </summary>
            /// <param name="ctx">
            /// A <see cref="GraphicsContext"/> used for allocating resources.
            /// </param>
            public override void Create(GraphicsContext ctx)
            {
                int         internalFormat = Pixel.GetGlInternalFormat(_PixelFormat, ctx);
                PixelFormat format         = Pixel.GetGlFormat(_Image.PixelLayout);
                PixelType   type           = Pixel.GetPixelType(_Image.PixelLayout);

                // Set pixel transfer
                foreach (int alignment in new int[] { 8, 4, 2, 1 })
                {
                    if ((_Image.Stride % alignment) != 0)
                    {
                        continue;
                    }
                    Gl.PixelStore(PixelStoreParameter.UnpackAlignment, alignment);
                    break;
                }

                // Upload texture contents
                Gl.TexImage1D(TextureTarget.Texture1d, (int)_Level, internalFormat, (int)_Image.Width, 0, format, type, _Image.ImageBuffer);
                // Define texture properties
                _Texture1d.DefineExtents(_PixelFormat, _Image.Width, 1, 1, _Level);
            }