core/vgui/impl/qt/vgui_qt.cxx
Go to the documentation of this file.
00001 #include "vgui_qt.h"
00002 #include <vgui/vgui_gl.h>
00003 #include "vgui_qt_window.h"
00004 #include "vgui_qt_dialog_impl.h"
00005 
00006 #include <qapplication.h>
00007 #include <qgl.h>
00008 
00009 
00010 //-----------------------------------------------------------------------------
00011 vgui_qt* vgui_qt::instance()
00012 {
00013   static vgui_qt* instance_ = new vgui_qt;
00014   return instance_;
00015 }
00016 
00017 
00018 //-----------------------------------------------------------------------------
00019 void vgui_qt::init(int &argc, char **argv)
00020 {
00021    new QApplication(argc, argv);
00022 
00023 #if 0
00024    QGLFormat f;
00025    f = QGLFormat::defaultFormat();
00026    f.setDoubleBuffer(true);
00027    f.setDepth(true);
00028    f.setRgba(true);
00029    f.setOverlay (true);
00030    f.setDirectRendering(true);
00031    QGLFormat::setDefaultFormat(f);
00032 
00033    QGLFormat of = QGLFormat::defaultOverlayFormat();
00034    of.setDoubleBuffer(false);
00035    of.setDepth(false);
00036    of.setRgba(false);
00037    of.setOverlay (false);
00038    of.setDirectRendering(true);
00039    QGLFormat::setDefaultOverlayFormat(of);
00040 
00041 
00042    vcl_cerr << "QGLFormat::hasOpenGL () is " << QGLFormat::hasOpenGL () << vcl_endl
00043             << "QGLFormat::hasOpenGLOverlays () is " << QGLFormat::hasOpenGLOverlays () << vcl_endl;
00044 #endif
00045 }
00046 
00047 
00048 //-----------------------------------------------------------------------------
00049 void vgui_qt::run()
00050 {
00051    qApp->exec();
00052 }
00053 
00054 //-----------------------------------------------------------------------------
00055 void vgui_qt::run_one_event()
00056 {
00057    qApp->processEvents(10);
00058    glFlush();
00059 }
00060 
00061 
00062 //-----------------------------------------------------------------------------
00063 void vgui_qt::run_till_idle()
00064 {
00065    qApp->processEvents(10);
00066    glFlush();
00067 }
00068 
00069 //-----------------------------------------------------------------------------
00070 void vgui_qt::flush()
00071 {
00072   glFlush();
00073   run_till_idle();
00074 }
00075 
00076 //-----------------------------------------------------------------------------
00077 vgui_window* vgui_qt::produce_window(int width, int height,
00078                                      const vgui_menu& menubar,
00079                                      const char* title)
00080 {
00081    return new vgui_qt_window(width, height, menubar, title);
00082 }
00083 
00084 
00085 //-----------------------------------------------------------------------------
00086 vgui_window* vgui_qt::produce_window(int width, int height,
00087                                      const char* title)
00088 {
00089    return new vgui_qt_window(width, height, title);
00090 }
00091 
00092 
00093 //-----------------------------------------------------------------------------
00094 vgui_dialog_impl* vgui_qt::produce_dialog(const char* name)
00095 {
00096    return new vgui_qt_dialog_impl(name);
00097 }