コード例 #1
0
ファイル: TextureCube.cs プロジェクト: lwansbrough/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 = Pixel.GetGlInternalFormat(_PixelFormat, ctx);
                PixelFormat format         = Pixel.GetGlFormat(_PixelFormat);
                PixelType   type           = Pixel.GetPixelType(_PixelFormat);

                for (int i = 0; i < 6; i++)
                {
                    Image image = _Images[i];

                    // 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(_CubeTargets[i], 0, internalFormat, (int)image.Width, (int)image.Height, 0, format, type, image.ImageBuffer);
                }

                // Define texture properties
                _TextureCube.DefineExtents(_PixelFormat, _Images[0].Width, _Images[0].Height, 1, 0);
            }
コード例 #2
0
ファイル: TextureCube.cs プロジェクト: lwansbrough/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 = Pixel.GetGlInternalFormat(_PixelFormat, ctx);

                // Define empty texture
                for (int i = 0; i < 6; i++)
                {
                    Gl.TexImage2D(_CubeTargets[i], 0, internalFormat, (int)_Size, (int)_Size, 0, /* Unused */ PixelFormat.Rgb, /* Unused */ PixelType.UnsignedByte, null);
                }
                // Define texture properties
                _TextureCube.DefineExtents(_PixelFormat, _Size, _Size, 1, 0);
            }