コード例 #1
0
ファイル: Texture2d.cs プロジェクト: vipyami/OpenGL.Net
            /// <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 = _PixelFormat.GetGlInternalFormat();
                PixelFormat format         = _PixelFormat.GetGlFormat();

                // Define empty texture
                Gl.TexImage2D(_Target, (int)_Level, internalFormat, (int)_Width, (int)_Height, 0, format, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero);
                // Define texture properties
                _Texture2d.DefineExtents(_PixelFormat, _Width, _Height, 1, _Level);
            }
コード例 #2
0
ファイル: Texture2d.cs プロジェクト: vipyami/OpenGL.Net
            /// <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 = _PixelFormat.GetGlInternalFormat();
                PixelFormat format         = _Image.PixelLayout.GetGlFormat();
                PixelType   type           = _Image.PixelLayout.GetPixelType();

                // 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.TexImage2D(_Target, (int)_Level, internalFormat, (int)_Image.Width, (int)_Image.Height, 0, format, type, _Image.ImageBuffer);
                // Define texture properties
                _Texture2d.DefineExtents(_PixelFormat, _Image.Width, _Image.Height, 1, _Level);
            }