예제 #1
0
        display::scoped_state::scoped_state(display & parent, const gsgl::flags_t & flags)
            : parent(parent)
        {
            parent.bind();

            glPushAttrib(GL_ALL_ATTRIB_BITS);                                                                       CHECK_GL_ERRORS();
            glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);                                                          CHECK_GL_ERRORS();

            enable(flags);
        } // display::scoped_state::scoped_state()
예제 #2
0
        display::scoped_ortho::scoped_ortho(display & parent)
            : parent(parent)
        {
            parent.bind();

            glMatrixMode(GL_PROJECTION);
            glPushMatrix();                                                                                     CHECK_GL_ERRORS();
            glLoadIdentity();                                                                                   CHECK_GL_ERRORS();
            
            glOrtho(0, static_cast<float>(parent.get_width()), 0, static_cast<float>(parent.get_height()), -1, 1);
        } // display::scoped_orth::scoped_orth()
예제 #3
0
        display::scoped_perspective::scoped_perspective(display & parent, const gsgl::real_t & field_of_view, const gsgl::real_t & aspect_ratio, const gsgl::real_t & near_distance, const gsgl::real_t & far_distance)
            : parent(parent)
        {
            parent.bind();

            glMatrixMode(GL_PROJECTION);                                                                        CHECK_GL_ERRORS();
            glPushMatrix();                                                                                     CHECK_GL_ERRORS();
            glLoadIdentity();                                                                                   CHECK_GL_ERRORS();

            gluPerspective(field_of_view, aspect_ratio, near_distance, far_distance);                           CHECK_GL_ERRORS();
        } // display::scoped_perspective::scoped_perspective()
예제 #4
0
        display::scoped_modelview::scoped_modelview(display & parent, const transform *mv)
            : parent(parent), mv(mv)
        {
            parent.bind();

            glMatrixMode(GL_MODELVIEW);                                                                                 CHECK_GL_ERRORS();
            glPushMatrix();                                                                                             CHECK_GL_ERRORS();

            if (mv) 
            {
                glLoadMatrixf(mv->ptr());                                                                               CHECK_GL_ERRORS();
            }
        } // display::scoped_modelview::scoped_modelview()
예제 #5
0
        display::scoped_text::scoped_text(display & parent)
            : parent(parent)
        {
            parent.bind();

            // record 3d info
            glGetIntegerv(GL_VIEWPORT, text_draw_viewport);                                                         CHECK_GL_ERRORS();
            glGetFloatv(GL_MODELVIEW_MATRIX, text_draw_modelview.ptr());                                            CHECK_GL_ERRORS();
            glGetFloatv(GL_PROJECTION_MATRIX, text_draw_projection.ptr());                                          CHECK_GL_ERRORS();
            text_draw_pm = text_draw_projection * text_draw_modelview;                                              CHECK_GL_ERRORS();

            // set up projection and modelview for drawing text
            glPushAttrib(GL_ALL_ATTRIB_BITS);                                                                       CHECK_GL_ERRORS();
            glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS);                                                          CHECK_GL_ERRORS();
            
            glMatrixMode(GL_PROJECTION);                                                                            CHECK_GL_ERRORS();
            glPushMatrix();                                                                                         CHECK_GL_ERRORS();
            glLoadIdentity();                                                                                       CHECK_GL_ERRORS();
            glOrtho(0.0, parent.surface->w, 0.0, parent.surface->h, -1, 1);                                         CHECK_GL_ERRORS();

            glMatrixMode(GL_MODELVIEW);                                                                             CHECK_GL_ERRORS();
            glPushMatrix();                                                                                         CHECK_GL_ERRORS();
            glLoadIdentity();                                                                                       CHECK_GL_ERRORS();
        } // display::scoped_text::scoped_text()
예제 #6
0
 display::scoped_viewport::scoped_viewport(display & parent)
     : parent(parent)
 {
     parent.bind();
     glViewport(0, 0, parent.get_width(), parent.get_height());
 } // display::scoped_viewport::scoped_viewport()