Пример #1
0
        public OpenGLFramebuffer(OpenGLTexture2D colorTexture, OpenGLTexture2D depthTexture)
            : this()
        {
            _depthTexture = depthTexture;

            Bind();
            AttachColorTexture(0, colorTexture);
            AttachDepthTexture();
            Unbind();
        }
Пример #2
0
        public override Framebuffer CreateFramebuffer(int width, int height)
        {
            OpenGLTexture2D colorTexture = new OpenGLTexture2D(
                width, height,
                PixelFormat.R32_G32_B32_A32_Float,
                PixelInternalFormat.Rgba32f,
                OpenTK.Graphics.OpenGL.PixelFormat.Rgba,
                PixelType.Float);
            OpenGLTexture2D depthTexture = new OpenGLTexture2D(
                width,
                height,
                PixelFormat.Alpha_UInt16,
                PixelInternalFormat.DepthComponent16,
                OpenTK.Graphics.OpenGL.PixelFormat.DepthComponent,
                PixelType.UnsignedShort);

            return(new OpenGLFramebuffer(colorTexture, depthTexture));
        }
Пример #3
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();
        }
Пример #4
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();
        }
Пример #5
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);
        }
Пример #6
0
 public override DeviceTexture2D CreateTexture <T>(T[] pixelData, int width, int height, int pixelSizeInBytes, PixelFormat format)
 {
     return(OpenGLTexture2D.Create(pixelData, width, height, pixelSizeInBytes, format));
 }