GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


A Paste by luke
if(GL_EXT_framebuffer_object_supported)
    {
        m_fbo.bind();
        glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        drawShapes();
        GLFramebufferObject::disable();
    }
    else
    {
        glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glViewport(0, 0, m_shapesTexSize, m_shapesTexSize);
        glMatrixMode(GL_PROJECTION); 
        glLoadIdentity();
        gluPerspective(m_screen.getFov(), (GLfloat)m_shapesTexSize/(GLfloat)m_shapesTexSize, m_screen.getZNear(), m_screen.getZFar());

        drawShapes();

        glEnable(GL_TEXTURE_2D);

        glBindTexture(GL_TEXTURE_2D, m_shapesTexId);

        glCopyTexImage2D(    GL_TEXTURE_2D,
                            0,
                            GL_RGB,
                            0,
                            0,
                            m_shapesTexSize,
                            m_shapesTexSize,
                            0);
        
        glViewport(0, 0, m_screen.getWidth(), m_screen.getWidth());
        glMatrixMode(GL_PROJECTION); 
        glLoadIdentity ();
        gluPerspective(    m_screen.getFov(),
                        (GLfloat)m_screen.getWidth()/(GLfloat)m_screen.getWidth(),
                        m_screen.getZNear(),
                        m_screen.getZFar());

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        glDisable(GL_TEXTURE_2D);
    }