Beispiel #1
0
bool Shader::init(Text*	_vertexShader, Text* _fragmentShader, const StringDict& _parameters)
{
	if (!GL_EXTENSION_GLSL)
    {
        return false;
    }

	if (isError())
    {
        error("opengl", "Real error before GLSL. Flushing");
    }

	vertexShader = _vertexShader;
	fragmentShader = _fragmentShader;
	parameters = _parameters;

	log_msg("opengl glsl", "Compiling " + getShaderDecription());

	programId = glCreateProgramObjectARB();
	if (isError())
    {
        return false;
    }

    vertexShaderId = glCreateShaderObjectARB (GL_VERTEX_SHADER_ARB);
   	if (!loadShader(vertexShaderId, vertexShader, parameters))
	{
		loadLog(programId);
		return false;
	}
    glAttachObjectARB(programId, vertexShaderId);

    fragmentShaderId = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);
   	if (!loadShader(fragmentShaderId, fragmentShader, parameters))
	{
		loadLog(programId);
		return false;
	}
    glAttachObjectARB(programId, fragmentShaderId);

    GLint   linked;
    glLinkProgramARB(programId);

	if (isError())
	{
		return false;
	}

    glGetObjectParameterivARB(programId, GL_OBJECT_LINK_STATUS_ARB, &linked);

    loadLog(programId);

    if (!linked)
	{
        return false;
	}

	return true;
}
Beispiel #2
0
bool    GlslProgram :: loadShaders ( Data * vertexShaderData, Data * fragmentShaderData )
{
    ok = false;
                                // check whether we should create program object
    if ( program == 0 )
        program = glCreateProgramObjectARB();

                                // check for errors
    if ( !checkGlError () )
        return false;
                                // create a vertex shader object and a fragment shader object
    if ( vertexShaderData != NULL )
    {
	    vertexShader = glCreateShaderObjectARB ( GL_VERTEX_SHADER_ARB   );

	    log += "Loading vertex shader\n";

    	if ( !loadShader ( vertexShader, vertexShaderData ) )
        	return false;

                                // attach shaders to program object
	    glAttachObjectARB ( program, vertexShader );
    }

    if ( fragmentShaderData != NULL )
    {
	    fragmentShader = glCreateShaderObjectARB ( GL_FRAGMENT_SHADER_ARB );

	    log += "Loading fragment shader\n";

    	if ( !loadShader ( fragmentShader, fragmentShaderData ) )
        	return false;
                                // attach shaders to program object
	    glAttachObjectARB ( program, fragmentShader );
    }

    GLint   linked;

    log += "Linking programs\n";

                                // link the program object and print out the info log
    glLinkProgramARB ( program );

/**/  if ( !checkGlError () )     // check for errors
/**/      return false;

    glGetObjectParameterivARB ( program, GL_OBJECT_LINK_STATUS_ARB, &linked );

    loadLog ( program );

    if ( !linked )
        return false;

    return ok = true;
}
Beispiel #3
0
/*
*  Constructs a logForm as a child of 'parent', with the
*  name 'name' and widget flags set to 'f'.
*
*  The dialog will by default be modeless, unless you set 'modal' to
*  TRUE to construct a modal dialog.
*/
logForm::logForm( QWidget* parent, bool modal, Qt::WFlags fl )
: QDialog( parent, fl )
{
   setModal( modal );
	setObjectName( "logForm" );

   //setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, 0, 0, sizePolicy().hasHeightForWidth() ) );
   setSizePolicy( QSizePolicy::Preferred , QSizePolicy::Preferred );
   setMinimumSize( QSize( 300, 300 ) );
   setMaximumSize( QSize( 600, 600 ) );
   setBaseSize( QSize( 400, 375 ) );
   logFormLayout = new QGridLayout( this ); //, 1, 1, 11, 6, "logFormLayout"); 

   layout3 = new QHBoxLayout( 0 ); 
   layout3->setSpacing( 6 );	
   spacer1 = new QSpacerItem( 210, 21, QSizePolicy::Expanding, QSizePolicy::Minimum );
   layout3->addItem( spacer1 );

   saveButton = new QPushButton( this );
   layout3->addWidget( saveButton );

   okButton = new QPushButton( this );
   layout3->addWidget( okButton );

   logFormLayout->addLayout( layout3, 1, 0 );

   logViewer = new QTextEdit( this );

   logFormLayout->addWidget( logViewer, 0, 0 );
   languageChange();
   resize( QSize(361, 365).expandedTo(minimumSizeHint()) );

   // signals and slots connections
   connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
   connect( saveButton, SIGNAL( clicked() ), this, SLOT( saveLog() ) );

   // tab order
   setTabOrder( okButton, saveButton );

   if( QFile::exists( logFile ) )
      loadLog();
   else 
      QMessageBox::warning( this, "Error", "MapIMG Log File Not Found." );
}
Beispiel #4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    this->setWindowTitle("");

    /* SETUP ICONS */
    QIcon icon(QDir::currentPath() + "/Pictures/main_icon.jpg");
    this->setWindowIcon(icon);

    QIcon play(QDir::currentPath() + "/Pictures/PlayIcon.png");
    QIcon edit(QDir::currentPath() + "/Pictures/EditIcon.png");
    QIcon save(QDir::currentPath() + "/Pictures/SaveIcon.png");

    index = 0;

    playIcon = play;
    editIcon = edit;
    saveIcon = save;

    project = nullptr;

    loadLog();

    createRollOutMenu();

    QDesktopWidget window;
    QRect screen = window.screenGeometry( window.screenNumber(this));
    move(screen.width()/2 - this->width()/2, screen.height()/2 - this->height()/2);

    record = captureAnimation = false;

    //ui->AnimationsTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);

    ui->CamerasWindows->setWidgetResizable(true);
    scrollWidget = new QWidget;
    scrollWidget->setLayout(new QVBoxLayout);
    ui->CamerasWindows->setWidget(scrollWidget);
}
Beispiel #5
0
bool    GlslProgram :: loadShader ( GLhandleARB shader, Data * data )
{
    const char * body = (const char *) data -> getPtr ( 0 );
    GLint		 len  = data -> getLength ();
    GLint        compileStatus;

    glShaderSourceARB ( shader, 1, &body,  &len );

                                        // compile the particle vertex shader, and print out
    glCompileShaderARB ( shader );

    if ( !checkGlError() )              // check for OpenGL errors
        return false;

    glGetObjectParameterivARB ( shader, GL_OBJECT_COMPILE_STATUS_ARB, &compileStatus );

    loadLog ( shader );

    return compileStatus != 0;

}
Beispiel #6
0
int loadLogs() {
  int logsize = 0;

  QString logdirname = locateLocal("data", "kppp/Log/");
  QDir logdir(logdirname, "*.log");

  kdDebug(5002) << "logdirname: " << logdirname << endl;
  
  // get log file size
  const QFileInfoList_qt3 *list = logdir.entryInfoList_qt3();
  QFileInfoListIterator it( *list );
  QFileInfo *fi;

  while ((fi = it.current()) != 0) {
    logsize += fi->size();
    ++it;
  }

  dlg = new QProgressDialog(i18n("Loading log files"),
			     QString::null,
			     logsize);
  dlg->setProgress(0);

  // load logs
  list = logdir.entryInfoList_qt3();
  QFileInfoListIterator it1( *list );

  int retval = 0;
  while ((fi = it1.current()) != 0) {
    retval += loadLog(fi->absFilePath());
    ++it1;
  }

  delete dlg; 
  return retval;
}
void AdvancedSettings::loadSettings()
{
    qDebug() << "Loading advanced settings";
    reset();

    QXmlStreamReader xml;
    QFile file(Settings::applicationDir() + "/advancedsettings.xml");
    if (!file.exists())
        file.setFileName(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/advancedsettings.xml");

    if (!file.exists())
        return;

    if (!file.open(QIODevice::ReadOnly))
        return;
    xml.addData(file.readAll());
    file.close();

    if (!xml.readNextStartElement() || xml.name().toString() != "advancedsettings")
        return;

    while (xml.readNextStartElement()) {
        if (xml.name() == "log")
            loadLog(xml);
        else if (xml.name() == "gui")
            loadGui(xml);
        else if (xml.name() == "sorttokens")
            loadSortTokens(xml);
        else if (xml.name() == "genres")
            loadGenreMappings(xml);
        else if (xml.name() == "fileFilters")
            loadFilters(xml);
        else if (xml.name() == "audioCodecs")
            loadAudioCodecMappings(xml);
        else if (xml.name() == "videoCodecs")
            loadVideoCodecMappings(xml);
        else if (xml.name() == "certifications")
            loadCertificationMappings(xml);
        else if (xml.name() == "studios")
            loadStudioMappings(xml);
        else if (xml.name() == "countries")
            loadCountryMappings(xml);
        else if (xml.name() == "portableMode")
            m_portableMode = (xml.readElementText() == "true");
        else
            xml.skipCurrentElement();
    }

    qDebug() << "Advanced settings";
    qDebug() << "    debugLog              " << m_debugLog;
    qDebug() << "    logFile               " << m_logFile;
    qDebug() << "    forceCache            " << m_forceCache;
    qDebug() << "    sortTokens            " << m_sortTokens;
    qDebug() << "    genreMappings         " << m_genreMappings;
    qDebug() << "    movieFilters          " << m_movieFilters;
    qDebug() << "    concertFilters        " << m_concertFilters;
    qDebug() << "    tvShowFilters         " << m_tvShowFilters;
    qDebug() << "    subtitleFilters       " << m_subtitleFilters;
    qDebug() << "    audioCodecMappings    " << m_audioCodecMappings;
    qDebug() << "    videoCodecMappings    " << m_videoCodecMappings;
    qDebug() << "    certificationMappings " << m_certificationMappings;
    qDebug() << "    studioMappings        " << m_studioMappings;
    qDebug() << "    useFirstStudioOnly    " << m_useFirstStudioOnly;
    qDebug() << "    countryMappings       " << m_countryMappings;
}
Beispiel #8
0
int synchronize(void) {
    int pidfd;
    char pidpath[PATH_MAX];
    int logfd;
    char logpath[PATH_MAX];
    int newsync = 0;

    // make sure, that there isn't another client process for this resource
    // already running
    snprintf(pidpath, PATH_MAX, "/var/run/syncedfs/client/%s.pid",
            config.resource);
    pidfd = createPidFile(config.ident, pidpath, 0);
    if (pidfd == -1) {
        errMsg(LOG_ERR, "Could not create pid file %s, Exiting sync.", pidpath);
        return -1;
    }

    // if sync log does not exist, switch log
    snprintf(logpath, PATH_MAX, "%s/%s.sync", config.logdir, config.resource);
    errMsg(LOG_INFO, "logpath: %s", logpath);
    logfd = open(logpath, O_RDONLY);
    if (logfd == -1) {
        if (switchLog() != 0) {
            errMsg(LOG_ERR, "Could not switch log file. Stopping.");
            return -1;
        }

        logfd = open(logpath, O_RDONLY);
        if (logfd == -1) {
            errnoMsg(LOG_ERR, "Could not open log file %s", logpath);
            return -1;
        }
        newsync = 1;
    }


    // sync-id
    char id[SYNCID_MAX];
    char idpath[PATH_MAX];
    snprintf(idpath, PATH_MAX, "%s/%s.id", config.logdir, config.resource);

    // second part of the condition covers weird states after crash etc.
    if (newsync == 1 || readSyncId(id, idpath, SYNCID_MAX) != 0) {
        if (generateSyncId(id, SYNCID_MAX) != 0) {
            errMsg(LOG_ERR, "Could not get sync-id. Stopping.");
            return -1;
        }
        if (writeSyncId(id, idpath) != 0) {
            errMsg(LOG_ERR, "Could not write sync-id. Stopping.");
            return -1;
        }
    }

    // create snapshot
    if (newsync || !fileExists(config.snapshot)) {
        if (createSnapshot(config.rootdir, config.snapshot, 1) == -1) {
            errMsg(LOG_ERR, "Could not create snapshot of %s to %s Stopping.",
                    config.rootdir, config.snapshot);
            return -1;
        }
    }

    // load log
    if (loadLog(logfd) != 0) {
        errMsg(LOG_ERR, "Could not load log %s", logpath);
        return -1;
    }

    // transfer changes
    if (transfer(config.host, config.port) == -1) {
        errMsg(LOG_ERR, "Error in transfer. Exiting sync.");

        // in case of failure only delete pid file
        if (deletePidFile(pidfd, pidpath) == -1)
            errExit(LOG_ERR, "Deleting PID file '%s'", pidpath);

        return -1;
    }

    // delete snapshot
    if (deleteSnapshot(config.snapshot) == -1)
        errMsg(LOG_ERR, "Could not delete snapshot %s", config.snapshot);

    // delete syncid
    if (unlink(idpath) == -1)
        errExit(LOG_ERR, "Deleting sync-id file '%s'", idpath);

    // delete sync log
    close(logfd);
    if (unlink(logpath) == -1)
        errExit(LOG_ERR, "Deleting log file '%s'", logpath);

    // delete pid file
    if (deletePidFile(pidfd, pidpath) == -1)
        errExit(LOG_ERR, "Deleting PID file '%s'", pidpath);

    return 0;
}
Beispiel #9
0
void map(std::ostream& report, int mode, int argc, char* argv[], const std::string& url, const std::string& userStyle, const std::string& testFonts, unsigned timeout, std::string result = "")
{
    assert(forkCount < forkMax);
    pid_t pid = fork();
    if (pid == -1) {
        std::cerr << "error: no more process to create\n";
        exit(EXIT_FAILURE);
    }
    if (pid == 0) {
        std::string path(url);
        size_t pos = path.rfind('.');
        if (pos != std::string::npos) {
            path.erase(pos);
            path += ".log";
        }
        std::string evaluation;
        std::string log;
        loadLog(path, evaluation, log);

        pid_t pid = -1;
        std::string output;
        switch (mode) {
        case GENERATE:
            evaluation = result;
            // FALL THROUGH
        case UPDATE:
            if (evaluation[0] == '?')
                break;
            // FALL THROUGH
        default:
            pid = runTest(argc, argv, userStyle, testFonts, url, output, timeout);
            break;
        }

        if (0 < pid && output.empty())
            result = "fatal";
        else {
            switch (mode) {
            case HEADLESS:
                if (evaluation != "?" && output != log)
                    result = "uncertain";
                else
                    result = evaluation;
                break;
            case UPDATE:
            case GENERATE:
                result = evaluation;
                if (result[0] != '?') {
                    if (!saveLog(path, url, result, output)) {
                        std::cerr << "error: failed to open the report file\n";
                        exit(EXIT_FAILURE);
                    }
                }
                break;
            default:
                break;
            }
        }
        if (0 < pid)
            killTest(pid);
        int status = ES_NA;
        if (!result.compare(0, 4, "pass"))
            status = ES_PASS;
        else if (!result.compare(0, 5, "fatal"))
            status = ES_FATAL;
        else if (!result.compare(0, 4, "fail"))
            status = ES_FAIL;
        else if (!result.compare(0, 7, "invalid"))
            status = ES_INVALID;
        else if (!result.compare(0, 4, "skip"))
            status = ES_SKIP;
        else if (!result.compare(0, 9, "uncertain"))
            status = ES_UNCERTAIN;
        exit(status);
    } else {
        auto s = &forkStates[(forkTop + forkCount) % forkMax];
        s->url = url;
        s->pid = pid;
        ++forkCount;
        reduce(report, WNOHANG);
    }
}
Beispiel #10
0
std::string test(int mode, int argc, char* argv[], const std::string& url, const std::string& userStyle, const std::string& testFonts, unsigned timeout)
{
    std::string path(url);
    size_t pos = path.rfind('.');
    if (pos != std::string::npos) {
        path.erase(pos);
        path += ".log";
    }
    std::string evaluation;
    std::string log;
    loadLog(path, evaluation, log);

    pid_t pid = -1;
    std::string output;
    switch (mode) {
    case REPORT:
        break;
    case UPDATE:
        if (evaluation[0] == '?')
            break;
        // FALL THROUGH
    default:
        pid = runTest(argc, argv, userStyle, testFonts, url, output, timeout);
        break;
    }

    std::string result;
    if (0 < pid && output.empty())
        result = "fatal";
    else if (mode == INTERACTIVE) {
        std::cout << "## complete\n" << output;
        std::cout << '[' << url << "] ";
        if (evaluation.empty() || evaluation[0] == '?')
            std::cout << "pass? ";
        else {
            std::cout << evaluation << "? ";
            if (evaluation != "pass")
                std::cout << '\a';
        }
        std::getline(std::cin, result);
        if (result.empty()) {
            if (evaluation.empty() || evaluation[0] == '?')
                result = "pass";
            else
                result = evaluation;
        } else if (result == "p" || result == "\x1b")
            result = "pass";
        else if (result == "f")
            result = "fail";
        else if (result == "i")
            result = "invalid";
        else if (result == "k") // keep
            result = evaluation;
        else if (result == "n")
            result = "na";
        else if (result == "s")
            result = "skip";
        else if (result == "u")
            result = "uncertain";
        else if (result == "q" || result == "quit")
            exit(EXIT_FAILURE);
        else if (result == "z")
            result = "undo";
        if (result != "undo" && !saveLog(path, url, result, output)) {
            std::cerr << "error: failed to open the report file\n";
            exit(EXIT_FAILURE);
        }
    } else if (mode == HEADLESS) {
        if (evaluation != "?" && output != log)
            result = "uncertain";
        else
            result = evaluation;
    } else if (mode == REPORT) {
        result = evaluation;
    } else if (mode == UPDATE) {
        result = evaluation;
        if (result[0] != '?') {
            if (!saveLog(path, url, result, output)) {
                std::cerr << "error: failed to open the report file\n";
                exit(EXIT_FAILURE);
            }
        }
    }

    if (0 < pid)
        killTest(pid);
    if (mode != INTERACTIVE && result[0] != '?')
        std::cout << url << '\t' << result << '\n';
    return result;
}