예제 #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 = _PixelFormat.GetGlInternalFormat();
                PixelFormat format         = _PixelFormat.GetGlFormat();
                PixelType   type           = _PixelFormat.GetPixelType();

                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
            /// <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();
                uint width = _Images[0].Width, height = _Images[0].Height;

                Gl.TexImage3D(_Target, 0, internalFormat, (int)width, (int)height, _Images.Length, 0, /* Unused */ OpenGL.PixelFormat.Red, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero);

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

                    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.TexSubImage3D(_Target, 0, 0, 0, i, (int)width, (int)height, 1, format, type, image.ImageBuffer);
                }

                // Define texture properties
                _Texture3d.DefineExtents(_PixelFormat, width, height, (uint)_Images.Length, 0);
            }
예제 #3
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)
            {
                PixelFormat format         = _PixelFormat.GetGlFormat();
                int         internalFormat = _PixelFormat.GetGlInternalFormat();

                // Define empty texture
                Gl.TexImage3D(_Target, (int)_Level, internalFormat, (int)_Width, (int)_Height, (int)_Depth, 0, format, /* Unused */ PixelType.UnsignedByte, null);
                // Define texture properties
                _Texture3d.DefineExtents(_PixelFormat, _Width, _Height, _Depth, _Level);
            }
예제 #4
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)
            {
                InternalFormat internalFormat = _PixelFormat.GetGlInternalFormat();
                PixelFormat    format         = _PixelFormat.GetGlFormat();

                // Define empty texture
                Gl.TexImage3D(_Target, (int)_Level, internalFormat, (int)_Width, (int)_Height, (int)_Layers, 0, format, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero);
                // Define texture properties
                _TextureArray2d.SetMipmap(_PixelFormat, _Width, _Height, _Layers, _Level);
            }
예제 #5
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 = _PixelFormat.GetGlInternalFormat();
                PixelFormat format         = _PixelFormat.GetGlFormat();

                // 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);
            }
예제 #6
0
        /// <summary>
        /// Actually create this GraphicsResource resources.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="GraphicsContext"/> used for allocating resources.
        /// </param>
        protected override void CreateObject(GraphicsContext ctx)
        {
            int currentBinding;

            Gl.Get(Gl.RENDERBUFFER_BINDING, out currentBinding);
            Gl.BindRenderbuffer(RenderbufferTarget.Renderbuffer, ObjectName);

            // Define buffer storage
            Gl.RenderbufferStorage(RenderbufferTarget.Renderbuffer, _InternalFormat.GetGlInternalFormat(), (int)_Width, (int)_Height);
            // Restore previous RenderBuffer binding
            Gl.BindRenderbuffer(RenderbufferTarget.Renderbuffer, (uint)currentBinding);
        }
예제 #7
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)
            {
                InternalFormat internalFormat = _PixelFormat.GetGlInternalFormat();

                // 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.SetMipmap(_PixelFormat, _Size, _Size, 1, 0);
            }
예제 #8
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)
            {
                InternalFormat internalFormat = _PixelFormat.GetGlInternalFormat();
                PixelFormat    format         = _Image.PixelLayout.GetGlFormat();
                PixelType      type           = _Image.PixelLayout.GetPixelType();

                // Set pixel alignment
                State.PixelAlignmentState.Unpack(_Image.Stride).Apply(ctx, null);

                // Upload texture contents
                Gl.TexImage1D(TextureTarget.Texture1d, (int)_Level, internalFormat, (int)_Image.Width, 0, format, type, _Image.ImageBuffer);
                // Define texture properties
                _Texture1d.SetMipmap(_PixelFormat, _Image.Width, 1, 1, _Level);
            }
예제 #9
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 = _PixelFormat.GetGlInternalFormat();

                // Define texture storage, if required
                if (_ResetLayers)
                {
                    Gl.TexImage3D(_Target, 0, internalFormat, (int)_Images[0].Width, (int)_Images[0].Height, _Images.Length, 0, /* Unused */ OpenGL.PixelFormat.Rgb, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero);
                }
                // Define array layers
                uint width = 0, height = 0;

                for (int layer = 0; layer < _Images.Length; layer++)
                {
                    // Allow partial definition
                    if (_Images[layer] == null)
                    {
                        continue;
                    }

                    PixelFormat format = _Images[layer].PixelLayout.GetGlFormat();
                    PixelType   type   = _Images[layer].PixelLayout.GetPixelType();

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

                    width  = _Images[layer].Width;
                    height = _Images[layer].Height;
                    // Upload texture contents
                    Gl.TexSubImage3D(_Target, 0, 0, 0, layer, (int)_Images[layer].Width, (int)_Images[layer].Height, 1, format, type, _Images[layer].ImageBuffer);
                }

                // Define texture properties
                if (_ResetLayers)
                {
                    _TextureArray2d.DefineExtents(_PixelFormat, _Images[0].Width, _Images[0].Height, 1, 0);
                }
            }
예제 #10
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 = (int)_PixelFormat.GetGlInternalFormat();

                // Define array layers
                uint width = 0, height = 0;

                PixelFormat format = _Image.PixelLayout.GetGlFormat();
                PixelType   type   = _Image.PixelLayout.GetPixelType();

                // Set pixel alignment
                State.PixelAlignmentState.Unpack(_Image.Stride).Apply(ctx, null);

                width  = _Image.Width;
                height = _Image.Height;

                // Upload texture contents
                Gl.TexSubImage3D(_Target, 0, 0, 0, (int)_ImageLayer, (int)_Image.Width, (int)_Image.Height, 1, format, type, _Image.ImageBuffer);
            }
예제 #11
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)
            {
                InternalFormat internalFormat = _PixelFormat.GetGlInternalFormat();
                PixelFormat    format         = _PixelFormat.GetGlFormat();
                PixelType      type           = _PixelFormat.GetPixelType();

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

                    // Set pixel alignment
                    State.PixelAlignmentState.Unpack(image.Stride).Apply(ctx, null);

                    // Upload texture contents
                    Gl.TexImage2D(_CubeTargets[i], 0, internalFormat, (int)image.Width, (int)image.Height, 0, format, type, image.ImageBuffer);
                }

                // Define texture properties
                _TextureCube.SetMipmap(_PixelFormat, _Images[0].Width, _Images[0].Height, 1, 0);
            }
예제 #12
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 = _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.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);
            }
예제 #13
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)
            {
                InternalFormat internalFormat = _PixelFormat.GetGlInternalFormat();
                uint           width = _Images[0].Width, height = _Images[0].Height;

                Gl.TexImage3D(_Target, 0, internalFormat, (int)width, (int)height, _Images.Length, 0, /* Unused */ OpenGL.PixelFormat.Red, /* Unused */ PixelType.UnsignedByte, IntPtr.Zero);

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

                    PixelFormat format = image.PixelLayout.GetGlFormat();
                    PixelType   type   = image.PixelLayout.GetPixelType();

                    // Set pixel alignment
                    State.PixelAlignmentState.Unpack(image.Stride).Apply(ctx, null);

                    // Upload texture contents
                    Gl.TexSubImage3D(_Target, 0, 0, 0, i, (int)width, (int)height, 1, format, type, image.ImageBuffer);
                }

                // Define texture properties
                _Texture3d.SetMipmap(_PixelFormat, width, height, (uint)_Images.Length, 0);
            }