示例#1
0
        private void setup(FramebufferTexture color0, bool depth)
        {
            m_width  = color0.width();
            m_height = color0.height();

            /* Create render buffer object for depth buffering */
            if (depth)
            {
                m_depth = new FramebufferTexture();
                m_depth.setFormat(OpenGL.GL_DEPTH_COMPONENT24, m_width, m_height, OpenGL.GL_DEPTH_COMPONENT, false, false);
            }
            else
            {
                m_depth = null;
            }

            /* Create and bind new FBO */
            glGenFramebuffers(1, framebufferId);
            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER_EXT, framebufferId[0]);

            glFramebufferTexture2D(OpenGL.GL_FRAMEBUFFER_EXT,
                                   attachment_id[m_color.Count], OpenGL.GL_TEXTURE_2D, color0.glID(), 0);
            m_color.Add(color0);

            if (m_depth != null)
            {
                glFramebufferTexture2D(OpenGL.GL_FRAMEBUFFER_EXT,
                                       OpenGL.GL_DEPTH_ATTACHMENT_EXT, OpenGL.GL_TEXTURE_2D, m_depth.glID(), 0);
            }

            uint result = glCheckFramebufferStatus(OpenGL.GL_FRAMEBUFFER_EXT);

            if (result != OpenGL.GL_FRAMEBUFFER_COMPLETE_EXT)
            {
                throw new Exception("Failed to create frame buffer object!");
            }

            useAllAttachments();

            /* Uibind FBO */
            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER_EXT, 0);
        }
示例#2
0
        private void setup(FramebufferTexture color0, bool depth)
        {
            m_width = color0.width();
            m_height = color0.height();

            /* Create render buffer object for depth buffering */
            if (depth)
            {
                m_depth = new FramebufferTexture();
                m_depth.setFormat(OpenGL.GL_DEPTH_COMPONENT24, m_width, m_height, OpenGL.GL_DEPTH_COMPONENT, false, false);
            }
            else
            {
                m_depth = null;
            }

            /* Create and bind new FBO */
            glGenFramebuffers(1, framebufferId);
            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER, framebufferId[0]);

            glFramebufferTexture2D(OpenGL.GL_FRAMEBUFFER,
                attachment_id[m_color.Count], OpenGL.GL_TEXTURE_2D, color0.glID(), 0);
            m_color.Add(color0);

            if (m_depth != null)
            {
                glFramebufferTexture2D(OpenGL.GL_FRAMEBUFFER,
                    OpenGL.GL_DEPTH_ATTACHMENT, OpenGL.GL_TEXTURE_2D, m_depth.glID(), 0);
            }

            uint result = glCheckFramebufferStatus(OpenGL.GL_FRAMEBUFFER);

            if (result != OpenGL.GL_FRAMEBUFFER_COMPLETE)
            {
                throw new Exception("Failed to create frame buffer object!");
            }

            useAllAttachments();

            /* Uibind FBO */
            glBindFramebuffer(OpenGL.GL_FRAMEBUFFER, 0);
        }