Update with current status
[gnash.git] / gui / qt / Qt4GlueOgl.cpp
blob6cf375b8e1b00162550e03ffab0e0e833f032bb1
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 // 2011 Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifdef HAVE_CONFIG_H
21 #include "gnashconfig.h"
22 #endif
24 #include <QWidget>
25 #include <QGLWidget>
26 #include <QRect>
28 #include "Qt4GlueOgl.h"
29 #include "Qt4Gui.h"
30 #include "Renderer.h"
31 #include "opengl/Renderer_ogl.h"
32 #include "GnashException.h"
34 namespace gnash
37 Qt4OglGlue::Qt4OglGlue()
38 : _renderer(nullptr)
42 Qt4OglGlue::~Qt4OglGlue()
46 bool
47 Qt4OglGlue::init(int /* argc */, char *** /* argv */)
49 return true;
53 void
54 Qt4OglGlue::prepDrawingArea(DrawingWidget *drawing_area)
56 assert(drawing_area);
57 _drawing_area = drawing_area;
58 _drawing_area->_glWidget = new QGLWidget(drawing_area);
59 _drawing_area->_glWidget->setVisible(drawing_area->isVisible());
60 _drawing_area->_glWidget->setMinimumSize(drawing_area->minimumSize());
61 _drawing_area->_glWidget->setSizePolicy(QSizePolicy::Expanding,
62 QSizePolicy::Expanding);
63 _drawing_area->_glWidget->makeCurrent();
67 void
68 Qt4OglGlue::render()
70 assert(_drawing_area);
71 _drawing_area->_glWidget->swapBuffers();
75 void
76 Qt4OglGlue::render(const QRect& /*updateRect*/)
78 render();
82 Renderer*
83 Qt4OglGlue::createRenderHandler()
85 _renderer = renderer::opengl::create_handler();
87 if ( ! _renderer ) {
88 throw GnashException("Could not create OpenGL renderer");
90 return _renderer;
93 // end of namespace gnash