Example #1
0
void updateAutotar(void)
{
	char name[255];
	int i;
	FILE *out;
  /* Clean out the crap in the old directory.*/
	system("/bin/rm -f ../../release/autotar/source.* ../../release/autotar/binary.*\n");
  /* Now fill it up with new crap.*/
	for (i=0;i<numProgs;i++)
	{
		prog *p=progs[i];
		/* if (!p->isCat) continue; *//*Skip things that aren't categories*/
		strcpy(name,"../../release/autotar/source.");
		strcat(name,p->name);
		out=fopen(name,"w");
		if (!p->isDoc)
			fprintf(out,"include\n");
		addProgram(p,1);
		cleanAndWrite(out);
		fclose(out);

		strcpy(name,"../../release/autotar/binary.");
		strcat(name,p->name);
		out=fopen(name,"w");
		addProgram(p,0);
		cleanAndWrite(out);
		fclose(out);
	}
}
Example #2
0
/*! \param[in] width width (in pixels) of the associated point clouds.
 *  \param[in] height height (in pixels) of the associated point clouds.
 *  \param[in] numPC maximum number of point clouds that the OpenGL buffers will hold.
 */
CLEnvGL::CLEnvGL (int width, int height, int numPC) : 
    CLEnv (), width (width), height (height), numPC (numPC)
{
    addContext (0, true);
    addQueueGL (0);
    addQueueGL (0);
    addProgram (0, kernel_files_gf);
    addProgram (0, kernel_files_rbc);
    addProgram (0, kernel_files_icp);
    addProgram (0, kernel_files_slam);
}
 /*! \brief Initializes the OpenCL environment. */
 CLEnvGL () : CLEnv ()
 {
     addContext (0, true);
     addQueueGL (0);
     addQueueGL (0);
     addProgram (0, kernel_files);
 }
Example #4
0
File: PA2.cpp Project: hamt3ch/Cpp
int main (void)
{
    linkedList* memoryMap = new linkedList(); // instantiate linkedList
    memoryMap->create();                // create memory map (add Node)
    
    displayMenu(); // print menu to screen
    
    do {
        input = parseUser(); // make sure user is inputting number
        
        switch (input) {
            case 1:
                addProgram(memoryMap); // add program in MM
                break;
            case 2:
                killProgram(memoryMap); // kill progam in MM
                break;
            case 3:
                getFragments(memoryMap); // get fragements in MM
                break;
            case 4:
                memoryMap -> display();  // display MM
                break;
        }

        while (input != 1 && input != 2 && input != 3 && input != 4 && input != 5) {
            input = parseUser(); // make sure user is inputting numbers
        }
        
    } while (input == 1 || input == 2 || input == 3 || input == 4); // if input = 5 -> exit Program
     
}
Example #5
0
int main(void)
{
	cl::Program addProgram(
        cl::STRING_CLASS(
		"int add(int a, int b) { return a + b; }")
		, false);
	cl::Program vectorWrapper(
        cl::STRING_CLASS(
		"int add(int a, int b); kernel void vectorAdd(global const int *inputA, global const int *inputB, global int *output){output[get_global_id(0)] = add(inputA[get_global_id(0)], inputB[get_global_id(0)]);}")
		, false);
	std::vector<cl::Program> programs;
	addProgram.compile();
	vectorWrapper.compile();		
	
    cl::STRING_CLASS s = addProgram.getInfo<CL_PROGRAM_SOURCE>();
    
	programs.push_back(addProgram);
	programs.push_back(vectorWrapper);
	cl::Program vectorAddProgram = cl::linkProgram(programs);

    auto vectorAddKernel = 
        cl::make_kernel<
            cl::Buffer&,
            cl::Buffer&,
            cl::Buffer&
            >( vectorAddProgram, "vectorAdd" );


    std::vector<int> inputA(numElements, 1);
    std::vector<int> inputB(numElements, 2);
    std::vector<int> output(numElements, 0xdeadbeef);
    cl::Buffer inputABuffer(begin(inputA), end(inputA), true);
    cl::Buffer inputBBuffer(begin(inputB), end(inputB), true);
    cl::Buffer outputBuffer(begin(output), end(output), false);

    vectorAddKernel(
        cl::EnqueueArgs(
            cl::NDRange(numElements),
            cl::NDRange(numElements)),
        inputABuffer,
        inputBBuffer,
        outputBuffer);

    cl::copy(outputBuffer, begin(output), end(output));

    std::cout << "Output:\n";
    for( int i = 1; i < numElements; ++i ) {
        std::cout << "\t" << output[i] << "\n";
    }
    std::cout << "\n\n";

}
Example #6
0
BGAdvancedDialog::BGAdvancedDialog(KBackgroundRenderer *_r,
                                   QWidget *parent,
                                   bool m_multidesktop)
    : KDialogBase(parent, "BGAdvancedDialog",
                  true, i18n("Advanced Background Settings"),
                  Ok | Cancel, Ok, true),
      r(_r)
{
   dlg = new BGAdvancedBase(this);
   setMainWidget(dlg);

   dlg->m_listPrograms->header()->setStretchEnabled ( true, 1 );
   dlg->m_listPrograms->setAllColumnsShowFocus(true);

   connect(dlg->m_listPrograms, SIGNAL(clicked(QListViewItem *)),
         SLOT(slotProgramItemClicked(QListViewItem *)));

   // Load programs
   QStringList lst = KBackgroundProgram::list();
   QStringList::Iterator it;
   for (it=lst.begin(); it != lst.end(); ++it)
      addProgram(*it);

   if (m_multidesktop)
   {
      KConfig cfg(desktopConfigname(), false, false);
      cfg.setGroup( "General" );
      if (!cfg.readBoolEntry( "Enabled", true ))
      {
         dlg->m_groupIconText->hide();
      }

      dlg->m_spinCache->setSteps(512, 1024);
      dlg->m_spinCache->setRange(0, 40960);
      dlg->m_spinCache->setSpecialValueText(i18n("Unlimited"));
      dlg->m_spinCache->setSuffix(i18n(" KB"));

      connect(dlg->m_buttonAdd, SIGNAL(clicked()),
         SLOT(slotAdd()));
      connect(dlg->m_buttonRemove, SIGNAL(clicked()),
         SLOT(slotRemove()));
      connect(dlg->m_buttonModify, SIGNAL(clicked()),
         SLOT(slotModify()));

      connect(dlg->m_listPrograms, SIGNAL(doubleClicked(QListViewItem *)),
         SLOT(slotProgramItemDoubleClicked(QListViewItem *)));
   }
   else
   {
Example #7
0
void addProgram(prog *p,int writeSource)
{
	int i;
	if (p->isOnlyBinary&&writeSource)
		return;
	if (!p->isCat&&!p->isDoc)
		addPathName(writeSource?p->path:"",p->name);
	if (p->isDoc)
		addPathName(p->path,p->name);
	/*Also write out library names.*/
	if (writeSource)
		for (i=0;i<p->numLibs;i++)
			addPathName(p->libs[i]->path,p->libs[i]->name);
	/*Recursively add children's names.*/
	for (i=0;i<p->numProgs;i++)
		addProgram((prog *)p->progs[i],writeSource);
}
Example #8
0
void
MidiDevice::mergeProgramList(const ProgramList &programList)
{
    ProgramList::const_iterator it;
    ProgramList::iterator oIt;
    bool clash = false;

    for (it = programList.begin(); it != programList.end(); ++it)
    {
        for (oIt = m_programList.begin(); oIt != m_programList.end(); ++oIt)
        {
            if (*it == *oIt)
            {
                clash = true;
                break;
            }
        }

        if (clash == false)
            addProgram(*it);
        else
            clash = false;
    }
}
Example #9
0
void Shader::addFragmentShader(const std::string& text)
{
	addProgram(text, GL_FRAGMENT_SHADER);
}
Example #10
0
void Shader::addGeometryShader(const std::string& text)
{
	addProgram(text, GL_GEOMETRY_SHADER);
}
Example #11
0
void Shader::addVertexShader(const std::string& text)
{
	addProgram(text, GL_VERTEX_SHADER);
}
Example #12
0
GLuint XunoGLSLFilter::sharpShader(GLuint pfbotextid)
{
//    qDebug()<<"XunoGLSLFilter::sharpShader";
    ShaderFilterXuno *m_sharpShader = static_cast <ShaderFilterXuno*> (user_shader);
    if (!m_sharpShader)  {
        qDebug()<<"m_sharpShader skipped 0";
        return 0;
    }
//     qDebug()<<"getFilterSharp()"<<m_sharpShader->getFilterSharp();
//    if (!m_sharpShader->needToRun()) {
//        //qDebug()<<"m_sharpShader skipped 1";
//        return 0;
//    }

    int prid=-1;
    prid=addProgram();
    QOpenGLShaderProgram *program=Q_NULLPTR;
    if (prid!=1){
        program=programs.at(prid);
    }else{
        qDebug()<<"programs not is"<<prid;
        return 0;
    }
    QOpenGLFunctions *f=opengl()->openGLContext()->functions();
    if (!f) {
        qDebug()<<"m_sharpShader skipped 2";
        return 0;
    }
    if (program==Q_NULLPTR) {
        qDebug()<<"m_sharpShader skipped 3, prid"<<prid;
        return 0;
    }


    int fboID=addFBO(1,false);

    program->removeAllShaders();

    if (shader_files.size()){
        QString filename;
        filename=QString(shader_files_prefix).append(shader_vertex_files.at(0));
        //qDebug()<<Shader;
        // Compile vertex shader
        if (!program->addShaderFromSourceFile(QOpenGLShader::Vertex, filename)){
            return 0;
        }
    }

    //qDebug()<<"XunoGLSLFilter::sharpShader.userShaderHeader: ";

    m_sharpShader->setCustomProgram(program);
    m_sharpShader->compile();
    //qDebug()<<"getFilterSharp:"<<m_sharpShader->getFilterSharp();

    if (!program->isLinked()) return 0;

    m_fbo[fboID]->bind();
    f->glViewport(0,0,m_fbo[fboID]->width(),m_fbo[fboID]->height());

    program->bind();

    m_sharpShader->setUserUniformValues();

    //    qDebug()<<"ShaderFilterXuno::compile() Sharer vertex:";
    //    qDebug()<<program->shaders().at(0)->sourceCode();
    //    qDebug()<<"ShaderFilterXuno::compile() Sharer fragment:";
    //    qDebug()<<program->shaders().at(1)->sourceCode();


    //qDebug()<<"texture0 is";
    program->setUniformValue("texture0",  0);

    QVector2D textureSize=QVector2D (float(m_fbo[fboID]->width()),float(m_fbo[fboID]->height()));

    //qDebug()<<"texture_size0 is";
    program->setUniformValue("u_textureSize", textureSize);

    //qDebug()<<"pixel_size0 is";
    program->setUniformValue("u_texelSize", QVector2D(1.0f,1.0f)/textureSize);

    //qDebug()<<"texture_rot0 is";
    program->setUniformValue("texture_rot0", QVector2D(0.0f,0.0f));

    QMatrix4x4 matrix;
    matrix.setToIdentity();

    program->setUniformValue("MVPMatrix", matrix);

    f->glActiveTexture(GL_TEXTURE0);
    f->glBindTexture(GL_TEXTURE_2D, pfbotextid);
    f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);//GL_NEAREST GL_LINEAR
    f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

    f->glClearColor(0.0,1.0,0.0,1.0);//GREEN
    f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if ( geometries==Q_NULLPTR) geometries = new GeometryEngine;

    if ( geometries!=Q_NULLPTR) geometries->drawCubeGeometry(program);

    f->glBindTexture(GL_TEXTURE_2D, 0);

    program->release();
    m_fbo[fboID]->release();

    //delete m_sharpShader;

    return  m_fbo[fboID]->texture();
}
void Shader::AddFragmentShader(string text)
{
	addProgram(text, GL_FRAGMENT_SHADER);
}
Example #14
0
void Simulation::configure(const config::Configuration& config)
{
    // Resize world
    {
        auto size = config.get<SizeVector>("world-size");

        if (size.getWidth() == Zero || size.getHeight() == Zero)
            throw config::Exception("Width or height is zero!");

        setWorldSize(size);
    }

    // Time step
    setTimeStep(config.get<units::Time>("dt"));

    if (config.has("length-coefficient"))
    {
        m_converter.setLengthCoefficient(config.get<RealType>("length-coefficient"));
    }

    // Set gravity
    setGravity(config.get("gravity", getGravity()));

    // Number of iterations
    setIterations(config.get("iterations", getIterations()));

    // Background color
    setBackgroundColor(config.get("background", getBackgroundColor()));

#if CONFIG_RENDER_TEXT_ENABLE
    setFontColor(config.get("text-color", getBackgroundColor().inverted()));
#endif

#if CONFIG_RENDER_TEXT_ENABLE
    setFontSize(config.get("text-size", getFontSize()));
#endif

#if CONFIG_RENDER_TEXT_ENABLE
    setSimulationTimeRender(config.get("show-simulation-time", isSimulationTimeRender()));
#endif

#ifdef CECE_ENABLE_RENDER
    setVisualized(config.get("visualized", isVisualized()));
#endif

    // Parse plugins
    for (auto&& pluginConfig : config.getConfigurations("plugin"))
    {
        // Returns valid pointer or throws an exception
        requirePlugin(pluginConfig.get("name"))->configure(*this, pluginConfig);
    }

    // Parse parameters
    for (auto&& parameterConfig : config.getConfigurations("parameter"))
    {
        setParameter(parameterConfig.get("name"), units::parse(parameterConfig.get("value")));
    }

    // Register user types
    for (auto&& typeConfig : config.getConfigurations("type"))
    {
        addObjectType({
            typeConfig.get("name"),
            typeConfig.get("base"),
            typeConfig.toMemory()
        });
    }

    // Parse init
    for (auto&& initConfig : config.getConfigurations("init"))
    {
        const String typeName = initConfig.has("language")
            ? initConfig.get("language")
            : initConfig.get("type");

        auto initializer = getPluginContext().createInitializer(typeName);

        if (initializer)
        {
            // Configure initializer
            initializer->loadConfig(*this, initConfig);

            // Register initializer
            addInitializer(std::move(initializer));
        }
    }

    // Parse modules
    for (auto&& moduleConfig : config.getConfigurations("module"))
    {
        // Get name
        auto name = moduleConfig.get("name");

        if (hasModule(name))
            continue;

        const String typeName = moduleConfig.has("language")
            ? moduleConfig.get("language")
            : moduleConfig.has("type")
                ? moduleConfig.get("type")
                : name
        ;

        auto module = getPluginContext().createModule(typeName, *this);

        if (module)
        {
            module->loadConfig(*this, moduleConfig);

            addModule(std::move(name), std::move(module));
        }
    }

    // Parse programs
    for (auto&& programConfig : config.getConfigurations("program"))
    {
        const String typeName = programConfig.has("language")
            ? programConfig.get("language")
            : programConfig.get("type");

        auto program = getPluginContext().createProgram(typeName);

        if (program)
        {
            // Configure program
            program->loadConfig(*this, programConfig);

            // Register program
            addProgram(programConfig.get("name"), std::move(program));
        }
    }

    // Parse objects
    for (auto&& objectConfig : config.getConfigurations("object"))
    {
        // Create object
        auto object = buildObject(
            objectConfig.get("class"),
            objectConfig.get("type", object::Object::Type::Dynamic)
        );

        if (object)
            object->configure(objectConfig, *this);
    }

    if (config.has("data-out-objects-filename"))
    {
        m_dataOutObjects = makeUnique<OutFileStream>(config.get("data-out-objects-filename"));
        *m_dataOutObjects << "iteration;totalTime;id;typeName;posX;posY;velX;velY\n";
    }
}
Example #15
0
GLuint XunoGLSLFilter::adaptiveSharpen(GLuint pfbotextid)
{
    //qDebug()<<"XunoGLSLFilter::adaptiveSharpen";

    int prid=-1;

    QOpenGLFunctions *f=opengl()->openGLContext()->functions();
    if (!f) {
        qDebug()<<"adaptiveSharpen skipped 2";
        return 0;
    }

    GLuint fbotextid;

    for (pass=0;pass<=maxPass_adaptive_sahrpen;pass++){
        //qDebug()<<"adaptiveSharpen pass"<<pass;

        prid=addProgram();
        QOpenGLShaderProgram *program=Q_NULLPTR;
        if (prid!=-1){
            program=programs.at(prid);
        }else{
            qDebug()<<"programs not is"<<prid;
            return 0;
        }
        if (program==Q_NULLPTR) {
            qDebug()<<"adaptiveSharpen skipped 3, prid"<<prid;
            return 0;
        }


        int fboID;
        if (pass==0) {
            fboID = addFBO(2,false);
        }else{
            fboID = addFBO(1,false);
        }

        //program->removeAllShaders();

        if (shader_files_adaptive_sharpen.size()){
            QString filename;
            filename=QString(shader_files_prefix).append(shader_vertex_files.at(0));
            //qDebug()<<Shader;
            // Compile vertex shader
            if (!program->addShaderFromSourceFile(QOpenGLShader::Vertex, filename)){
                qDebug()<<"Vertex Shader error load"<<filename ;
                return 0;
            }
            filename=QString(shader_files_prefix).append(shader_files_adaptive_sharpen.at(pass));
            //qDebug()<<"Vertex Shader load"<<filename ;
            // Compile vertex shader
            if (!program->addShaderFromSourceFile(QOpenGLShader::Fragment, filename)){
                qDebug()<<"Fragment Shader error load"<<filename ;
                return 0;
            }

            if (!program->link()) {
                qDebug()<<"Fragment Shader error link"<<filename ;
                qDebug()<<program->log();
                qDebug()<<program->shaders().at(0)->sourceCode();
                qDebug()<<program->shaders().at(1)->sourceCode();
                return 0;
            }
        }


//        qDebug()<<program->shaders().at(0)->sourceCode();
//        qDebug()<<program->shaders().at(1)->sourceCode();

        m_fbo[fboID]->bind();
        f->glViewport(0,0,m_fbo[fboID]->width(),m_fbo[fboID]->height());

        program->bind();

        //    qDebug()<<"ShaderFilterXuno::compile() Sharer vertex:";
        //    qDebug()<<program->shaders().at(0)->sourceCode();
        //    qDebug()<<"ShaderFilterXuno::compile() Sharer fragment:";
        //    qDebug()<<program->shaders().at(1)->sourceCode();


        //qDebug()<<"texture0 is";
        program->setUniformValue("texture0",  0);

        QVector2D textureSize=QVector2D (float(m_fbo[fboID]->width()),float(m_fbo[fboID]->height()));

        //qDebug()<<"texture_size0 is";
        program->setUniformValue("u_textureSize", textureSize);

        //qDebug()<<"pixel_size0 is";
        program->setUniformValue("u_texelSize", QVector2D(1.0f,1.0f)/textureSize);

        //qDebug()<<"texture_rot0 is";
        program->setUniformValue("texture_rot0", QVector2D(0.0f,0.0f));

        QMatrix4x4 matrix;
        matrix.setToIdentity();

        program->setUniformValue("MVPMatrix", matrix);

        f->glActiveTexture(GL_TEXTURE0);
        f->glBindTexture(GL_TEXTURE_2D, pfbotextid);
        f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);//GL_NEAREST GL_LINEAR
        f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

        f->glClearColor(0.0,0.0,1.0,1.0);//BLUE
        f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        if ( geometries==Q_NULLPTR) geometries = new GeometryEngine;

        if ( geometries!=Q_NULLPTR) geometries->drawCubeGeometry(program);

        f->glBindTexture(GL_TEXTURE_2D, 0);

        program->release();
        m_fbo[fboID]->release();
        fbotextid=m_fbo[fboID]->texture();
        pfbotextid=fbotextid;
        //qDebug()<<"pfbotextid"<<pfbotextid;
    }

    return  fbotextid;
}
void Shader::AddVertexShader(string text)
{
	addProgram(text, GL_VERTEX_SHADER);
}
int Interpreter::call(const QStringList &argv, bool interactive)
{
    ChirpProc proc;
    ProcInfo info;
    int args[20];
    int i, j, k, n, base, res;
    bool ok;
    uint type;
    ArgList list;

    // not allowed
    if (argv.size()<1)
        return -1;

    // check modules to see if they handle this command, if so, skip to end
    emit enableConsole(false);
    for (i=0; i<m_modules.size(); i++)
    {
        if (m_modules[i]->command(argv))
            return 0;
    }

    // a procedure needs extension info (arg info, etc) in order for us to call...
    if ((proc=m_chirp->getProc(argv[0].toLocal8Bit()))>=0 &&
            m_chirp->getProcInfo(proc, &info)>=0)
    {
        memset(args, 0, sizeof(args)); // zero args
        getArgs(&info, &list);
        n = strlen((char *)info.argTypes);

        // if we have fewer args than required...
        if ((int)list.size()>argv.size()-1)
        {
            // if we're interactive, ask for values
            if (interactive && argv.size()>0)
            {
                QStringList cargv = argv;
                QString pstring, pstring2;
                for (i=cargv.size()-1; i<(int)list.size(); i++)
                {
                    if (info.argTypes[i]==CRP_TYPE_HINT)
                    {
                        if (n>i+4)
                        {
                            type = *(uint *)&info.argTypes[i+1];
                            if (type==FOURCC('R','E','G','1'))
                            {
                                emit videoInput(VideoWidget::REGION);
                                pstring2 = "(select region with mouse)";
                            }
                            if (type==FOURCC('P','N','T','1'))
                            {
                                emit videoInput(VideoWidget::POINT);
                                pstring2 = "(select point with mouse)";
                            }
                        }
                    }
                    k = i;
                    pstring = printArgType(&info.argTypes[i], i) + " " + list[k].first +
                            (list[k].second=="" ? "?" : " (" + list[k].second + ")?") + " " + pstring2;

                    emit enableConsole(true);
                    emit prompt(pstring);
                    m_mutexInput.lock();
                    m_waiting = true;
                    m_waitInput.wait(&m_mutexInput);
                    m_waiting = false;
                    m_mutexInput.unlock();
                    emit prompt(PROMPT);
                    emit enableConsole(false);

                    if (m_key==Qt::Key_Escape)
                        return -1;
                    cargv << m_command.split(QRegExp("\\s+"));
                }
                // call ourselves again, now that we have all the args
                return call(cargv, true);
            }
            else
            {
                emit error("too few arguments.\n");
                return -1;
            }
        }


        augmentProcInfo(&info);
        // if we have all the args we need, parse, put in args array
        for (i=0, j=0; m_argTypes[i]; i++)
        {
            if (argv.size()>i+1)
            {
                if (m_argTypes[i]==CRP_INT8 || m_argTypes[i]==CRP_INT16 || m_argTypes[i]==CRP_INT32)
                {
                    args[j++] = m_argTypes[i];
                    if (argv[i+1].left(2)=="0x")
                        base = 16;
                    else
                        base = 10;
                    args[j++] = argv[i+1].toInt(&ok, base);
                    if (!ok)
                    {
                        emit error("argument didn't parse.\n");
                        return -1;
                    }
                }
#if 0
                else if (m_argTypes[i]==CRP_STRING)
                {
                    args[j++] = m_argTypes[i];
                    // string goes where?  can't cast pointer to int...
                }
#endif
                else
                {
                    // deal with non-integer types
                    return -1;
                }
            }
        }
#if 0
        // print helpful chirp argument string
        if (interactive && argv.size()>1)
        {
            QString callString = "Chirp arguments for " + argv[0] +
                    " (ChirpProc=" + QString::number(proc) + "): ";
            for (i=1; i<argv.size(); i++)
            {
                if (i>1)
                    callString += ", ";
                j = i;
                callString += printArgType(&m_argTypes[i-1], i) + "(" + argv[j] + ")";
            }
            emit textOut(callString + "\n");
        }
#endif

        // make chirp call
        res = m_chirp->callAsync(proc, args[0], args[1], args[2], args[3], args[4], args[5], args[6],
                           args[7], args[8], args[9], args[10], args[11], args[12], args[13], args[14], args[15],
                           args[16], args[17], args[18], args[19], END_OUT_ARGS);

        // check for cable disconnect
        if (res<0 && !m_notified) //res==LIBUSB_ERROR_PIPE)
        {
            m_notified = true;
            emit connected(PIXY, false);
            return res;
        }
        // get response if we're not programming, save text if we are
        if (m_programming)
            addProgram(argv);
        else
            m_chirp->serviceChirp();
    }
    else
    {
        emit error("procedure unsupported.\n");
        return -1;
    }

    return 0;
}
void Shader::AddGeometryShader(string text)
{
	addProgram(text, GL_GEOMETRY_SHADER);
}
Example #19
0
//opt_sharpness [0...2] default 1.0f
//opt_edge_strength [0...1] default 0.6f
void XunoGLSLFilter::superscale(GLfloat opt_sharpness, GLfloat opt_edge_strength)
{

    if ( geometries==Q_NULLPTR) geometries = new GeometryEngine;

    QOpenGLFunctions *f=opengl()->openGLContext()->functions();

    if (!f) return;

    //if (initSize.isEmpty()){
    initSize=outputSize();
    //}

    //qDebug()<<"superscale" << initSize;
    //setOutputSize(initSize*2);
    //qDebug()<<"superscale x2" << outputSize();


    //initTextures();

    frame++;

    // Enable depth buffer
    f->glEnable(GL_DEPTH_TEST);

    // Enable back face culling // QtAV move freeze with it.
    //f->glEnable(GL_CULL_FACE);


    //---------------------------------------------
    //GLuint fbotextid=texture->textureId();
    GLuint fbotextid=fbo()->texture(); //used last fbo of player as source frame

    //qDebug()<<"Texture id start"<<fbotextid<<"texure size:"<<texture->width()<<"x"<<texture->height();

    for (pass=0;pass<=maxPass;pass++){

        bool rotate=false;//(pass>0);
        //qDebug()<<"Programs:"<<
        addProgram();
        if (initShaders_xbr(pass) && !scales.isEmpty()){
            int fboID=addFBO(scales.at(pass),/*rotate*/0);

            QOpenGLShaderProgram *program=Q_NULLPTR;
            if (pass<=programs.size()){
                program=programs.at(pass);
            }

            m_fbo[fboID]->bind();

            f->glViewport(0,0,m_fbo[fboID]->width(),m_fbo[fboID]->height());
            // Use texture unit 0 which contains cube.png

            program->bind();

            //qDebug()<<"texture0 is";
            program->setUniformValue("texture0",  0);


            QVector2D textureSize=QVector2D (float(m_fbo[fboID]->width()),float(m_fbo[fboID]->height()));

            //qDebug()<<"texture_size0 is";
            program->setUniformValue("texture_size0", textureSize);


            //qDebug()<<"pixel_size0 is";
            program->setUniformValue("pixel_size0", QVector2D(1.0f,1.0f)/textureSize);


            //qDebug()<<"texture_rot0 is";
            program->setUniformValue("texture_rot0", QVector2D(0.0f,0.0f));

            //options
            program->setUniformValue("sharpness", opt_sharpness);     // [0...2] default 1.0f
            program->setUniformValue("edge_strength",opt_edge_strength); // [0...1] default 0.6f

            QMatrix4x4 matrix;
            matrix.setToIdentity();

            if (rotate) {
                int sign=(pass==2)?-1:1;
                matrix.rotate(180*sign,0.,0.,1.);
            }

            program->setUniformValue("MVPMatrix", matrix);

            //if (1) {
            //if (0){  //pass==0
            //    f->glActiveTexture(GL_TEXTURE0);
            //    texture->bind();
            //}else{
            f->glActiveTexture(GL_TEXTURE0);
            f->glBindTexture(GL_TEXTURE_2D, fbotextid);
            f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);//GL_NEAREST GL_LINEAR
            f->glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
            //f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);//GL_CLAMP_TO_EDGE
            //f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
            //}

            f->glClearColor(1.0,0.0,0.0,1.0);//RED
            f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

            // Draw cube geometry
            geometries->drawCubeGeometry(program);

            //                if (0){//pass==0
            //                    texture->release();
            //                }else{

            f->glBindTexture(GL_TEXTURE_2D, 0);

            //                }
            //            }
            program->release();
            m_fbo[fboID]->release();
#if (unix)
            //            QString filename=QString("/home/lex/temp/savefbo_pass_%1_%2x%3-%4.bmp").arg(pass).arg(m_fbo[fboID]->width()).arg(m_fbo[fboID]->height()).arg(frame);
#else
            //            QString filename=QString("e:/temp/shader/savefbo_pass_%1_%2x%3-%4.bmp").arg(pass).arg(m_fbo[fboID]->width()).arg(m_fbo[fboID]->height()).arg(frame);
#endif
            // qDebug()<<"Saving:"<<filename;
            // m_fbo[fboID]->toImage(false).save(filename);

            fbotextid=m_fbo[fboID]->texture();
            //qDebug()<<"Texture id"<<fbotextid<<"texure size:"<<m_fbo[fboID]->width()<<"x"<<m_fbo[fboID]->height();
        }else{
            qDebug()<<"initShaders error (pass)"<<pass;
        }
    }

    if (fbotextid) lastSuperscaleTexureId=fbotextid;
}