void GraphicsManager::initOpenGL()
{
    setGLVersion();
    updateExtensions();
    initOpenGLFunctions();
    updatePlanformExtensions();
    updateDebugLog();
    createTextureSampler();
    updateLimits();
}
void D3D11DefaultShader::setupClipPlane(u32 Index, const dim::plane3df &Plane, bool Enable)
{
    if (Index < 8)
    {
        SConstantBufferExtension::SClipPlane* ClipPlane = &(ConstBufferExtension_.Planes[Index]);
        
        ClipPlane->Enabled  = Enable;
        ClipPlane->Plane    = Plane;
        
        updateExtensions();
    }
}
void ScreenTab::mediaListSelectedChanded(const QItemSelection &selected, const QItemSelection &deselected)
{
    Q_UNUSED(deselected);
    ui->actionAddMedia->setEnabled(false);
    ui->actionAddExtension->setEnabled(false);
    ui->actionMoveMediaDown->setEnabled(false);
    ui->actionMoveMediaUp->setEnabled(false);
    ui->actionRemoveRow->setEnabled(false);
    ui->addMediaPushButton->setEnabled(false);
    ui->addExtensionPushButton->setEnabled(false);
    ui->removeRowPushButton->setEnabled(false);
    ui->moveRowDownPushButton->setEnabled(false);
    ui->moveRowUpPushButton->setEnabled(false);
    _currentMedia = NULL;

    QAbstractItemModel *mediaModel = ui->mediaListTableView->model();
    if (!mediaModel)
        return;
    ui->actionAddMedia->setEnabled(true);
    ui->addMediaPushButton->setEnabled(true);
    updateExtensions();

    QList<QModelIndex> selectedIndex = selected.indexes();
    if (selectedIndex.count() > 0)
    {
        ui->actionRemoveRow->setEnabled(true);
        ui->removeRowPushButton->setEnabled(true);
        QModelIndex index = selectedIndex[0];
        if (index.row() > 0)
        {
            ui->moveRowUpPushButton->setEnabled(true);
            ui->actionMoveMediaUp->setEnabled(true);
        } else
        {
            ui->moveRowUpPushButton->setEnabled(false);
            ui->actionMoveMediaUp->setEnabled(false);
        }
        if (index.row() < mediaModel->rowCount() - 1)
        {
            ui->moveRowDownPushButton->setEnabled(true);
            ui->actionMoveMediaDown->setEnabled(true);
        } else
        {
            ui->moveRowDownPushButton->setEnabled(false);
            ui->actionMoveMediaDown->setEnabled(false);
        }
        Media * currentObject = mediaModel->data(index, MediaTableModel::MediaPnt).value<Media *>();
        _currentMedia = currentObject;
    }
    emit currentMediaChanged(_currentMedia);

}
ScreenTab::ScreenTab(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ScreenTab),
    _currentMedia(NULL),
    _screen(NULL),
    _desktopMediaPlayer(new DesktopMediaPlayer(this))
{
    ui->setupUi(this);
    setScreen(new Screen(this));

//    ui->currentDisplaySpinBox->setMaximum(QApplication::desktop()->screenCount() - 1);

    ui->splitter->setStretchFactor(0, 1);
    ui->splitter->setSizes(QList<int>() << 10000 << 1);
    setContextMenuPolicy(Qt::PreventContextMenu);

    addAction(ui->actionStartStopPlaying);

    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::FilePatch, QHeaderView::Stretch);
    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::NumberToShow, QHeaderView::ResizeToContents);
    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::RandomWeigth, QHeaderView::ResizeToContents);
    ui->mediaListTableView->addAction(ui->actionAddMedia);
    ui->mediaListTableView->addAction(ui->actionAddExtension);
    ui->mediaListTableView->addAction(ui->actionRemoveRow);
    ui->mediaListTableView->addAction(ui->actionMoveMediaUp);
    ui->mediaListTableView->addAction(ui->actionMoveMediaDown);
    ui->mediaListTableView->setContextMenuPolicy(Qt::ActionsContextMenu);
    connect(ui->actionAddMedia, SIGNAL(triggered()), this, SLOT(addMedia()));
    connect(ui->actionAddExtension, SIGNAL(triggered()), this, SLOT(addExtension()));
    connect(ui->actionRemoveRow, SIGNAL(triggered()), this, SLOT(removeMedia()));
    connect(ui->actionMoveMediaUp, SIGNAL(triggered()), this, SLOT(moveMediaUp()));
    connect(ui->actionMoveMediaDown, SIGNAL(triggered()), this, SLOT(moveMediaDown()));
    connect(ui->actionStartStopPlaying, SIGNAL(triggered()), this, SLOT(startStopPlaying()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(load()));

//    connect(ui->currentDisplaySpinBox, SIGNAL(valueChanged(int)), this, SLOT(onCurrentDisplaySpinBoxChanged(int)));

    connect(_desktopMediaPlayer, SIGNAL(graphicSceneChanged(QGraphicsScene*)), this, SLOT(setSceneToPreview(QGraphicsScene*)));
    connect(_desktopMediaPlayer, SIGNAL(escKeyPressed()), this, SLOT(stopPlaying()));

    mediaListSelectedChanded(QItemSelection(), QItemSelection());

    //Законектим изменение данных в энжайне расширений со слотом обновления расширений
    connect(MDVPlayerApplication::instance(), SIGNAL(extensionEngineDataChanged()), this, SLOT(updateExtensions()));

    onCurrentDisplaySpinBoxChanged(1);
//    onCurrentDisplaySpinBoxChanged(ui->currentDisplaySpinBox->value());
}
void D3D11DefaultShader::setupFogColor(const video::color &Color)
{
    ConstBufferExtension_.Fog.Color = math::convert(Color);
    updateExtensions();
}