QWindowCompositor::QWindowCompositor(QOpenGLWindow *window)
    : QWaylandCompositor(window)
    , m_window(window)
    , m_textureBlitter(0)
    , m_renderScheduler(this)
    , m_draggingWindow(0)
    , m_dragKeyIsPressed(false)
    , m_cursorSurface(0)
    , m_cursorHotspotX(0)
    , m_cursorHotspotY(0)
    , m_modifiers(Qt::NoModifier)
{
    enableSubSurfaceExtension();
    m_window->makeCurrent();

    m_textureCache = new QOpenGLTextureCache(m_window->context());
    m_textureBlitter = new TextureBlitter();
    m_backgroundImage = makeBackgroundImage(QLatin1String(":/background.jpg"));
    m_renderScheduler.setSingleShot(true);
    connect(&m_renderScheduler,SIGNAL(timeout()),this,SLOT(render()));

    QOpenGLFunctions *functions = m_window->context()->functions();
    functions->glGenFramebuffers(1, &m_surface_fbo);

    window->installEventFilter(this);

    setRetainedSelectionEnabled(true);

    setOutputGeometry(QRect(QPoint(0, 0), window->size()));
    setOutputRefreshRate(qRound(qGuiApp->primaryScreen()->refreshRate() * 1000.0));
}
Exemple #2
0
void TMap::LoadMap(const QString& map) {
    USettings settings;
    settings.Load("maps/" + map + "/config.ini");
    QString color = settings.GetParameter("color");
    Color = QColor(color);
    Width = settings.GetParameter("width");
    Height = settings.GetParameter("height");
    LoadTiles();
    makeBackgroundImage();
    Loaded = true;
    WHRatio = QPointF(1.0, 1.0);
    if( Width && Height ) {
        // 1.0 means max size, other always less than 1
        WHRatio = QPointF(Width > Height ?  1.0 : (qreal)Width / Height,
                          Width > Height ? (qreal)Height / Width : 1.0);
    }
}