public BasicParticleRenderTarget(int width, int height) : base(false, false, width, height)
 {
     SetOutput(0,
               new TextureSlotParam(TextureTarget.Texture2D, PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float, false,
                                    TextureParameter.Create(TextureParameterName.TextureMagFilter, TextureMagFilter.Nearest),
                                    TextureParameter.Create(TextureParameterName.TextureMinFilter, TextureMinFilter.Nearest),
                                    TextureParameter.Create(TextureParameterName.TextureWrapS, TextureWrapMode.Repeat),
                                    TextureParameter.Create(TextureParameterName.TextureWrapT, TextureWrapMode.Repeat)
                                    ));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="TexturedMaterial"/> class.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        public TexturedMaterial(Root root) : base(root)
        {
            mAmbientColorParam      = new ColorParameter(root, "ambientColor", Color.Black);
            mDiffuseTextureParam    = new TextureParameter(Root, "txDiffuse", null);
            mSpecularIntensityParam = new FloatParameter(root, "specularIntensity", 0.0f);
            mShininessParam         = new FloatParameter(root, "shininess", 1.0f);
            mReceiveShadowsParam    = new FloatParameter(root, "receiveShadows", 1.0f);

            Setup();
        }
Esempio n. 3
0
        public static void Convert(this BIRPRendering.TextureParameter birpSource, TextureParameter target)
        {
            if (target == null)
            {
                return;
            }

            target.value         = birpSource.value;
            target.overrideState = birpSource.overrideState;
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new material with no textures. Textures must be set before rendering any
        /// object with the material.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        public NormalMappedMaterial(Root root) : base(root)
        {
            mAmbientColorParam    = new ColorParameter(Root, "ambientColor", Color.Black);
            mDiffuseTextureParam  = new TextureParameter(Root, "txDiffuse", null);
            mNormalTextureParam   = new TextureParameter(Root, "txNormal", null);
            mSpecularTextureParam = new TextureParameter(Root, "txSpecular", null);
            mBumpinessParam       = new FloatParameter(Root, "bumpiness", 1.0f);
            mReceiveShadowsParam  = new FloatParameter(root, "receiveShadows", 1.0f);

            Setup();
        }
Esempio n. 5
0
        public ParticleNode() : base(false, true)
        {
            ChildComponent = new ParticleRenderer();
            SetOutput(0, new TextureSlotParam(TextureTarget.Texture2D, PixelInternalFormat.Rgba16f, PixelFormat.Rgba, PixelType.HalfFloat, false,
                                              TextureParameter.Create(TextureParameterName.TextureMagFilter, TextureMagFilter.Linear),
                                              TextureParameter.Create(TextureParameterName.TextureMinFilter, TextureMinFilter.Linear),
                                              TextureParameter.Create(TextureParameterName.TextureWrapS, TextureWrapMode.ClampToEdge),
                                              TextureParameter.Create(TextureParameterName.TextureWrapT, TextureWrapMode.ClampToEdge)
                                              ));

            _output.Add("tex", new GraphNodeTexturePort()
            {
                Target = TextureTarget.Texture2D,
                Format = PixelFormat.Rgba,
                Name   = "tex"
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TexturedMaterial"/> class.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        /// <param name="diffuse">Diffuse texture of the material.</param>
        /// <param name="specularIntensity">Specular intensity of the new material.</param>
        /// <param name="shininess">Shininess of the new material.</param>
        /// <param name="ambient">Ambient color of the new material.</param>
        /// <param name="ambientIntensity">
        /// Intensity of the ambient color. Each component of the ambient color will be multiplied
        /// by this factor.
        /// </param>
        /// <param name="receiveShadows">if set to <c>true</c> [receive shadows].</param>
        public TexturedMaterial(Root root, Texture2D diffuse, float specularIntensity,
                                float shininess, Color ambient, float ambientIntensity = 0.2f,
                                bool receiveShadows = true)
            : base(root)
        {
            mAmbientIntensity = ambientIntensity;
            Color multipliedAmbient = Color.Multiply(ambient, ambientIntensity);

            mAmbientColorParam      = new ColorParameter(Root, "ambientColor", multipliedAmbient);
            mDiffuseTextureParam    = new TextureParameter(Root, "txDiffuse", diffuse);
            mSpecularIntensityParam = new FloatParameter(Root, "specularIntensity", specularIntensity);
            mShininessParam         = new FloatParameter(root, "shininess", shininess);
            mReceiveShadowsParam    = new FloatParameter(root, "receiveShadows", BoolToFloat(receiveShadows));
            mReceiveShadows         = receiveShadows;

            Setup();
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a new material with all the textures set.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        /// <param name="diffuse">Diffuse texture of the new material.</param>
        /// <param name="normal">Normal map of the new material.</param>
        /// <param name="specular">Specular map of the new material.</param>
        /// <param name="ambient">Ambient color of the new material.</param>
        /// <param name="ambientIntensity">Intensity of the ambient light.</param>
        /// <param name="bumpiness">Bumpiness of the material.</param>
        /// <param name="receiveShadows">
        /// Whether objects drawn with this material receive shadows.
        /// </param>
        public NormalMappedMaterial(Root root, Texture2D diffuse, Texture2D normal,
                                    Texture2D specular, Color ambient, float ambientIntensity = 0.2f,
                                    float bumpiness = 1.0f, bool receiveShadows = true)
            : base(root)
        {
            mAmbientIntensity = ambientIntensity;
            Color multipliedAmbient = Color.Multiply(ambient, ambientIntensity);

            mAmbientColorParam    = new ColorParameter(Root, "ambientColor", multipliedAmbient);
            mDiffuseTextureParam  = new TextureParameter(Root, "txDiffuse", diffuse);
            mNormalTextureParam   = new TextureParameter(Root, "txNormal", normal);
            mSpecularTextureParam = new TextureParameter(Root, "txSpecular", specular);
            mBumpinessParam       = new FloatParameter(Root, "bumpiness", bumpiness);
            mReceiveShadowsParam  = new FloatParameter(root, "receiveShadows", BoolToFloat(receiveShadows));
            mReceiveShadows       = receiveShadows;

            Setup();
        }
Esempio n. 8
0
 public void AddParameter(TextureParameter ParameterName, Texture2D Value, bool IsPing)
 {
     if (IsPing)
     {
         if (TextureParametersPing.ContainsKey(ParameterName))
         {
             TextureParametersPing.Remove(ParameterName);
         }
         TextureParametersPing.Add(ParameterName, Value);
     }
     else
     {
         if (TextureParametersPong.ContainsKey(ParameterName))
         {
             TextureParametersPong.Remove(ParameterName);
         }
         TextureParametersPong.Add(ParameterName, Value);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Creates a new material by loading the required textures.
        /// </summary>
        /// <param name="root">Root object to which the material belongs.</param>
        /// <param name="diffuseFile">File with the diffuse texture of the material.</param>
        /// <param name="normalFile">File with the normal map of the material.</param>
        /// <param name="specularFile">File with the specular map of the material.</param>
        /// <param name="ambient">Ambient color of the material.</param>
        /// <param name="ambientIntensity">Intensity of the ambient light.</param>
        /// /// <param name="bumpiness">Bumpiness of the material.</param>
        public NormalMappedMaterial(Root root, string diffuseFile, string normalFile,
                                    string specularFile, Color ambient, float ambientIntensity = 0.2f,
                                    float bumpiness = 1.0f)
            : base(root)
        {
            mAmbientIntensity = ambientIntensity;
            Color multipliedAmbient = Color.Multiply(ambient, ambientIntensity);

            mAmbientColorParam = new ColorParameter(Root, "ambientColor", multipliedAmbient);

            //Load the textures of the material.
            Texture2D diffuse  = Root.ContentManager.Load <Texture2D>(diffuseFile);
            Texture2D normal   = Root.ContentManager.Load <Texture2D>(normalFile);
            Texture2D specular = Root.ContentManager.Load <Texture2D>(specularFile);

            mDiffuseTextureParam  = new TextureParameter(Root, "txDiffuse", diffuse);
            mNormalTextureParam   = new TextureParameter(Root, "txNormal", normal);
            mSpecularTextureParam = new TextureParameter(Root, "txSpecular", specular);
            mBumpinessParam       = new FloatParameter(Root, "bumpiness", bumpiness);

            Setup();
        }
Esempio n. 10
0
        ShaderResourceViewDimension GetTextureDimension(TextureParameter param)
        {
            switch (param.Dim)
            {
            case 2:
                return(ShaderResourceViewDimension.Texture2D);

            case 3:
                return(ShaderResourceViewDimension.Texture3D);

            case 4:
                return(ShaderResourceViewDimension.TextureCube);

            case 5:
                return(ShaderResourceViewDimension.Texture2DArray);

            case 6:
                return(ShaderResourceViewDimension.TextureCubeArray);

            default:
                return(ShaderResourceViewDimension.Texture2D);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a framebuffer object and its associated resources (depth and frame buffers).
        /// </summary>
        /// <param name="size">Specifies the size (in pixels) of the framebuffer and its associated buffers.</param>
        /// <param name="attachments">Specifies the attachments to use for the frame buffer.</param>
        /// <param name="format">Specifies the internal pixel format for the frame buffer.</param>
        /// <param name="mipmaps">Specifies whether to build mipmaps after the frame buffer is unbound.</param>
        /// <param name="filterType">Specifies the type of filtering to apply to the frame buffer when bound as a texture.</param>
        /// <param name="pixelType">Specifies the pixel type to use for the underlying format of the frame buffer.</param>
        public FBO(Size size, FramebufferAttachment[] attachments, PixelInternalFormat format, bool mipmaps = false, TextureParameter filterType = TextureParameter.Linear, PixelType pixelType = PixelType.UnsignedByte)
        {
            this.Size        = size;
            this.Attachments = attachments;
            this.Format      = format;
            this.MipMaps     = mipmaps;

            // First create the framebuffer
            BufferID = Gl.GenFramebuffer();
            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, BufferID);

            if (Attachments.Length == 1 && Attachments[0] == FramebufferAttachment.DepthAttachment)
            {
                // if this is a depth attachment only
                TextureID = new uint[] { Gl.GenTexture() };
                Gl.BindTexture(TextureTarget.Texture2D, TextureID[0]);

                Gl.TexImage2D(TextureTarget.Texture2D, 0, Format, Size.Width, Size.Height, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, TextureParameter.ClampToEdge);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, TextureParameter.ClampToEdge);

                Gl.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureID[0], 0);
                Gl.DrawBuffer(DrawBufferMode.None);
                Gl.ReadBuffer(ReadBufferMode.None);
            }
            else
            {
                // Create n texture buffers (known by the number of attachments)
                TextureID = new uint[Attachments.Length];
                Gl.GenTextures(Attachments.Length, TextureID);

                // Bind the n texture buffers to the framebuffer
                for (int i = 0; i < Attachments.Length; i++)
                {
                    Gl.BindTexture(TextureTarget.Texture2D, TextureID[i]);
                    Gl.TexImage2D(TextureTarget.Texture2D, 0, Format, Size.Width, Size.Height, 0, PixelFormat.Rgba, pixelType, IntPtr.Zero);
                    if (MipMaps)
                    {
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, TextureParameter.Linear);
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, TextureParameter.LinearMipMapLinear);
                        Gl.GenerateMipmap(GenerateMipmapTarget.Texture2D);
                    }
                    else
                    {
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, filterType);
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, filterType);
                    }
                    Gl.FramebufferTexture(FramebufferTarget.Framebuffer, Attachments[i], TextureID[i], 0);
                }

                // Create and attach a 24-bit depth buffer to the framebuffer
                DepthID = Gl.GenTexture();
                Gl.BindTexture(TextureTarget.Texture2D, DepthID);

                Gl.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Depth24Stencil8, Size.Width, Size.Height, 0, PixelFormat.DepthStencil, PixelType.UnsignedInt248, IntPtr.Zero);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, TextureParameter.ClampToEdge);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, TextureParameter.ClampToEdge);

                Gl.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, DepthID, 0);
                Gl.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.StencilAttachment, DepthID, 0);
            }

            // Build the framebuffer and check for errors
            FramebufferErrorCode status = Gl.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

            if (status != FramebufferErrorCode.FramebufferComplete)
            {
                Console.WriteLine("Frame buffer did not compile correctly.  Returned {0}, glError: {1}", status.ToString(), Gl.GetError().ToString());
            }

            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
Esempio n. 12
0
        /// <summary>
        /// Creates a framebuffer object and its associated resources (depth and pbuffers).
        /// </summary>
        /// <param name="Size">Specifies the size (in pixels) of the framebuffer and it's associated buffers.</param>
        /// <param name="Attachments">Specifies the attachments to use for the frame buffer.</param>
        /// <param name="Format">Specifies the internal pixel format for the frame buffer.</param>
        /// <param name="Mipmaps">Specified whether to build mipmaps after the frame buffer is unbound.</param>
        public FBO(Size Size, FramebufferAttachment[] Attachments, PixelInternalFormat Format, bool Mipmaps, TextureParameter filterType = TextureParameter.Linear)
        {
            this.Size = Size;
            this.Attachments = Attachments;
            this.Format = Format;
            this.mipmaps = Mipmaps;

            // First create the framebuffer
            BufferID = Gl.GenFramebuffer();
            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, BufferID);

            if (Attachments.Length == 1 && Attachments[0] == FramebufferAttachment.DepthAttachment)
            {
                // if this is a depth attachment only
                TextureID = new uint[] { Gl.GenTexture() };
                Gl.BindTexture(TextureTarget.Texture2D, TextureID[0]);

                Gl.TexImage2D(TextureTarget.Texture2D, 0, Format, Size.Width, Size.Height, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, TextureParameter.ClampToEdge);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, TextureParameter.ClampToEdge);

                Gl.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureID[0], 0);
                Gl.DrawBuffer(DrawBufferMode.None);
                Gl.ReadBuffer(ReadBufferMode.None);
            }
            else
            {
                // Create n texture buffers (known by the number of attachments)
                TextureID = new uint[Attachments.Length];
                Gl.GenTextures(Attachments.Length, TextureID);

                // Bind the n texture buffers to the framebuffer
                for (int i = 0; i < Attachments.Length; i++)
                {
                    Gl.BindTexture(TextureTarget.Texture2D, TextureID[i]);
                    Gl.TexImage2D(TextureTarget.Texture2D, 0, Format, Size.Width, Size.Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
                    if (Mipmaps)
                    {
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, TextureParameter.Linear);
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, TextureParameter.LinearMipMapLinear);
                        Gl.GenerateMipmap(GenerateMipmapTarget.Texture2D);
                    }
                    else
                    {
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, filterType);
                        Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, filterType);
                    }
                    Gl.FramebufferTexture(FramebufferTarget.Framebuffer, Attachments[i], TextureID[i], 0);
                }

                // Create and attach a 24-bit depth buffer to the framebuffer
                DepthID = Gl.GenTexture();
                Gl.BindTexture(TextureTarget.Texture2D, DepthID);

                Gl.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Depth24Stencil8, Size.Width, Size.Height, 0, PixelFormat.DepthStencil, PixelType.UnsignedInt248, IntPtr.Zero);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, TextureParameter.Nearest);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, TextureParameter.ClampToEdge);
                Gl.TexParameteri(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, TextureParameter.ClampToEdge);

                Gl.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, DepthID, 0);
                Gl.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.StencilAttachment, DepthID, 0);
            }

            // Build the framebuffer and check for errors
            FramebufferErrorCode status = Gl.CheckFramebufferStatus(FramebufferTarget.Framebuffer);
            if (status != FramebufferErrorCode.FramebufferComplete)
            {
                Console.WriteLine("Frame buffer did not compile correctly.  Returned {0}, glError: {1}", status.ToString(), Gl.GetError().ToString());
            }

            Gl.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
        }
Esempio n. 13
0
        /// <summary>
        /// Creates a framebuffer object and its associated resources (depth and frame buffers).
        /// </summary>
        /// <param name="size">Specifies the size (in pixels) of the framebuffer and its associated buffers.</param>
        /// <param name="attachments">Specifies the attachments to use for the frame buffer.</param>
        /// <param name="format">Specifies the internal pixel format for the frame buffer.</param>
        /// <param name="mipmaps">Specifies whether to build mipmaps after the frame buffer is unbound.</param>
        /// <param name="filterType">Specifies the type of filtering to apply to the frame buffer when bound as a texture.</param>
        /// <param name="pixelType">Specifies the pixel type to use for the underlying format of the frame buffer.</param>
        public FBO(Sizei size, FramebufferAttachment[] attachments, PixelInternalFormat format, bool mipmaps = false, TextureParameter filterType = TextureParameter.Linear, PixelType pixelType = PixelType.UnsignedByte, bool renderbuffer = true, bool multisampled = false)
        {
            Size         = size;
            Attachments  = attachments;
            Format       = format;
            MipMaps      = mipmaps;
            Multisampled = multisampled;

            // First create the framebuffer
            BufferID = GL.GenFramebuffer();
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, BufferID);

            _attachementMap = new Dictionary <FramebufferAttachment, uint>();
            TextureTarget textureTarget = Multisampled ? TextureTarget.Texture2DMultisample : TextureTarget.Texture2D;

            if (Attachments.Length == 1 && Attachments[0] == FramebufferAttachment.DepthAttachment)
            {
                // if this is a depth attachment only
                TextureID = new uint[] { GL.GenTexture() };
                GL.BindTexture(textureTarget, TextureID[0]);

                if (Multisampled)
                {
                    GL.TexImage2DMultisample(textureTarget, GameSettings.MultisampleLevel, Format, Size.Width, Size.Height, true);
                }
                else
                {
                    GL.TexImage2D(textureTarget, 0, Format, Size.Width, Size.Height, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);
                    GL.TexParameteri(textureTarget, TextureParameterName.TextureMagFilter, TextureParameter.Nearest);
                    GL.TexParameteri(textureTarget, TextureParameterName.TextureMinFilter, TextureParameter.Nearest);
                    GL.TexParameteri(textureTarget, TextureParameterName.TextureWrapS, TextureParameter.ClampToEdge);
                    GL.TexParameteri(textureTarget, TextureParameterName.TextureWrapT, TextureParameter.ClampToEdge);
                }

                GL.BindTexture(textureTarget, 0);
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, textureTarget, TextureID[0], 0);
                GL.DrawBuffer(DrawBufferMode.None);
                GL.ReadBuffer(ReadBufferMode.None);

                _attachementMap.Add(FramebufferAttachment.DepthAttachment, 0);
            }
            else
            {
                // Create n texture buffers (known by the number of attachments)
                TextureID = new uint[Attachments.Length];
                GL.GenTextures(Attachments.Length, TextureID);

                // Bind the n texture buffers to the framebuffer
                for (int i = 0; i < Attachments.Length; i++)
                {
                    GL.BindTexture(textureTarget, TextureID[i]);

                    if (Multisampled)
                    {
                        GL.TexImage2DMultisample(textureTarget, GameSettings.MultisampleLevel, Format, Size.Width, Size.Height, true);
                    }
                    else
                    {
                        GL.TexImage2D(textureTarget, 0, Format, Size.Width, Size.Height, 0, PixelFormat.Rgba, pixelType, IntPtr.Zero);

                        if (MipMaps)
                        {
                            GL.TexParameteri(textureTarget, TextureParameterName.TextureMagFilter, TextureParameter.Linear);
                            GL.TexParameteri(textureTarget, TextureParameterName.TextureMinFilter, TextureParameter.LinearMipMapLinear);
                            GL.GenerateMipmap(Multisampled ? GenerateMipmapTarget.Texture2DMultisample : GenerateMipmapTarget.Texture2D);
                        }
                        else
                        {
                            GL.TexParameteri(textureTarget, TextureParameterName.TextureMagFilter, filterType);
                            GL.TexParameteri(textureTarget, TextureParameterName.TextureMinFilter, filterType);
                        }
                    }

                    GL.BindTexture(textureTarget, 0);
                    GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, Attachments[i], textureTarget, TextureID[i], 0);

                    _attachementMap.Add(Attachments[i], TextureID[i]);
                }

                if (renderbuffer)
                {
                    // Create and attach a 24-bit depth buffer to the framebuffer
                    DepthID = GL.GenRenderbuffer();
                    GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, DepthID);

                    if (Multisampled)
                    {
                        GL.RenderbufferStorageMultisample(RenderbufferTarget.Renderbuffer, GameSettings.MultisampleLevel, PixelInternalFormat.Depth32fStencil8, Size.Width, Size.Height);
                    }
                    else
                    {
                        GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, PixelInternalFormat.Depth24Stencil8, Size.Width, Size.Height);
                    }

                    GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0);
                    GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthStencilAttachment, RenderbufferTarget.Renderbuffer, DepthID);

                    //GL.TexParameteri(textureTarget, TextureParameterName.TextureMagFilter, TextureParameter.Nearest);
                    //GL.TexParameteri(textureTarget, TextureParameterName.TextureMinFilter, TextureParameter.Nearest);
                    //GL.TexParameteri(textureTarget, TextureParameterName.TextureWrapS, TextureParameter.ClampToEdge);
                    //GL.TexParameteri(textureTarget, TextureParameterName.TextureWrapT, TextureParameter.ClampToEdge);

                    //GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, textureTarget, DepthID, 0);
                    //GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.StencilAttachment, textureTarget, DepthID, 0);

                    _attachementMap.Add(FramebufferAttachment.DepthStencilAttachment, DepthID);
                    //_attachementMap.Add(FramebufferAttachment.StencilAttachment, DepthID);
                }
            }

            // Build the framebuffer and check for errors
            FramebufferStatus status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

            if (status != FramebufferStatus.FramebufferComplete)
            {
                Console.WriteLine("Frame buffer did not compile correctly.  Returned {0}, glError: {1}", status.ToString(), GL.GetError().ToString());
            }

            // Make sure this framebuffer is not modified from outside
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

            // Register this framebuffer as a disposable object
            ResourcesManager.AddDisposableResource(this);
        }
Esempio n. 14
0
 public void TexParameter(TextureType target, TextureParameter pname, int param) => this.CallMethod <object>(TEX_PARAMETER_I, target, pname, param);
Esempio n. 15
0
 public T GetTexParameter <T>(TextureType target, TextureParameter pname) => this.CallMethod <T>(GET_TEX_PARAMETER, target, pname);
Esempio n. 16
0
 public static void TexParameteri(OpenGL.TextureTarget target, OpenGL.TextureParameterName pname, TextureParameter param)
 {
     Delegates.glTexParameteri(target, pname, (int)param);
 }
Esempio n. 17
0
 public void AddParameter(TextureParameter ValueParameter, Texture2D Value)
 {
     AddParameter(ValueParameter, Value, true);
 }
Esempio n. 18
0
 public static void TexParameteri(OpenGL.TextureTarget target, OpenGL.TextureParameterName pname, TextureParameter param)
 {
     Delegates.glTexParameteri(target, pname, (int)param);
 }
Esempio n. 19
0
 /// <summary>
 /// Set a scalar texture parameter.
 /// </summary>
 /// <param name="target">Specificies the target for which the texture is bound.</param>
 /// <param name="pname">Specifies the name of a single-values texture parameter.</param>
 /// <param name="param">Specifies the value of pname.</param>
 public static void TexParameteri(TextureTarget target, TextureParameterName pname, TextureParameter param)
 {
     TexParameteri(target, pname, (int)param);
 }