Пример #1
0
        public void AttachColorTexture(int index, DeviceTexture2D texture)
        {
            Bind();
            Debug.Assert(texture is OpenGLTexture2D);
            OpenGLTexture2D glTex = (OpenGLTexture2D)texture;

            _colorTextures[index] = glTex;
            GL.ActiveTexture(TextureUnit.Texture0);
            glTex.Bind();
            GL.FramebufferTexture2D(
                FramebufferTarget.Framebuffer,
                FramebufferAttachment.ColorAttachment0,
                TextureTarget.Texture2D,
                glTex.ID,
                0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0 + index);
            Unbind();
        }
Пример #2
0
        public void AttachColorTexture(int index, DeviceTexture2D texture)
        {
            Bind();
            Debug.Assert(texture is OpenGLTexture2D);
            OpenGLTexture2D glTex = (OpenGLTexture2D)texture;

            _colorTextures[index] = glTex;
            GL.ActiveTexture(TextureUnit.Texture0);
            glTex.Bind();
            GL.FramebufferTexture2D(
                FramebufferTarget.Framebuffer,
                FramebufferAttachment.ColorAttachment0 + index,
                TextureTarget.Texture2D,
                glTex.ID,
                0);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            // TODO: I'm pretty sure this is supposed to be using glDrawBuffers (plural).
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0 + index);
            Unbind();
        }
Пример #3
0
        public static OpenGLTexture2D Create <T>(T[] pixelData, int width, int height, int pixelSizeInBytes, PixelFormat format) where T : struct
        {
            var internalFormat = OpenGLFormats.MapPixelInternalFormat(format);
            var pixelFormat    = OpenGLFormats.MapPixelFormat(format);
            var pixelType      = OpenGLFormats.MapPixelType(format);

            OpenGLTexture2D texture = new OpenGLTexture2D(
                width,
                height,
                format,
                internalFormat,
                pixelFormat,
                pixelType);

            texture.Bind();
            GL.TexImage2D(TextureTarget.Texture2D, 0, internalFormat, width, height, 0, pixelFormat, pixelType, pixelData);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            return(texture);
        }
Пример #4
0
        private void AttachDepthTexture()
        {
            Bind();
            int depthTextureID;

            if (_depthTexture != null)
            {
                _depthTexture.Bind();
                depthTextureID = _depthTexture.ID;
            }
            else
            {
                depthTextureID = 0;
            }
            GL.FramebufferTexture2D(
                FramebufferTarget.Framebuffer,
                FramebufferAttachment.DepthAttachment,
                TextureTarget.Texture2D,
                depthTextureID,
                0);
            Unbind();
        }