예제 #1
0
        public Framebuffer(OpenGLGraphics graphics, Surface surface)
        {
            if (graphics is null)
            {
                throw new ArgumentNullException(nameof(graphics));
            }

            // Get the surface storage
            _storage = surface.Native as FramebufferStorage;
            if (_storage == null)
            {
                throw new InvalidOperationException($"Framebufer storage was unexpectedly null.");
            }

            _surface = surface ?? throw new ArgumentNullException(nameof(surface));

            // Construct target
            TextureFBO = new TextureTarget(graphics, _storage.Texture);

            if (_storage.HasMultisampleTarget)
            {
                // Construct msaa target
                MultisampleFBO = new TextureTarget(graphics, _storage.MultisampleTexture);
                // RenderbufferFBO = new RenderbufferTarget(graphics, _storage.Renderbuffer);
            }
        }
        public PackerAtlasTechnique(OpenGLGraphics graphics)
            : base(graphics)
        {
            _entries = new Dictionary <Image, AtlasEntry>();

            // Create packer - it will be at most 256 megabytes (8192^2 * 4 bytes)
            var pageSize = Calc.Min(8192, graphics.Capabilities.MaxTextureSize);

            _packer = new SkylinePacker <Image>(pageSize, pageSize);

            // Allocate texture (page)
            _texture = Graphics.Invoke(() => new Texture(_packer.Size, TextureSizedFormat.RGBA8));
        }
예제 #3
0
            public TextureTarget(OpenGLGraphics graphics, Texture texture)
            {
                _graphics = graphics;

                Texture = texture;

                // Generate framebuffer
                Handle = GL.GenFramebuffer();
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, Handle);

                // Attach to framebuffer
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.Color0, (TextureImageTarget)texture.Target, Texture.Handle, 0);

                // Ensure framebuffer is valid
                var status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

                if (status != FramebufferStatus.Complete)
                {
                    throw new InvalidOperationException($"Unable to initialize multisample framebuffer. {status}");
                }

                // Unbind framebuffer
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            }
예제 #4
0
            public RenderbufferTarget(OpenGLGraphics graphics, Renderbuffer renderbuffer)
            {
                _graphics = graphics;

                Renderbuffer = renderbuffer;

                // Generate framebuffer
                Handle = GL.GenFramebuffer();
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, Handle);

                // Attach to framebuffer
                GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferAttachment.Color0, Renderbuffer.Handle);

                // Ensure framebuffer is valid
                var status = GL.CheckFramebufferStatus(FramebufferTarget.Framebuffer);

                if (status != FramebufferStatus.Complete)
                {
                    throw new InvalidOperationException($"Unable to initialize multisample framebuffer. {status}");
                }

                // Unbind framebuffer
                GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            }
 public SimpleAtlasTechnique(OpenGLGraphics graphics)
     : base(graphics)
 {
     _textures = new ConditionalWeakTable <Image, Texture>();
 }
예제 #6
0
 protected AtlasTechnique(OpenGLGraphics graphics)
 {
     Graphics = graphics ?? throw new ArgumentNullException(nameof(graphics));
 }