Exemple #1
0
/* Run through all info commands and call them blindly (without arguments) */
static void test_info_commands(void)
{
    char *resp, *info, *info_buf, *endp;

    info_buf = info = hmp("help info");

    while (*info) {
        /* Extract the info command, ignore parameters and description */
        g_assert(strncmp(info, "info ", 5) == 0);
        endp = strchr(&info[5], ' ');
        g_assert(endp != NULL);
        *endp = '\0';
        /* Now run the info command */
        if (verbose) {
            fprintf(stderr, "\t%s\n", info);
        }
        resp = hmp(info);
        g_free(resp);
        /* And move forward to the next line */
        info = strchr(endp + 1, '\n');
        if (!info) {
            break;
        }
        info += 1;
    }

    g_free(info_buf);
}
static void test_one_device(const char *type)
{
    QDict *resp;
    char *help, *qom_tree;

    resp = qmp("{'execute': 'device-list-properties',"
               " 'arguments': {'typename': %s}}",
               type);
    QDECREF(resp);

    help = hmp("device_add \"%s,help\"", type);
    g_free(help);

    /*
     * Some devices leave dangling pointers in QOM behind.
     * "info qom-tree" has a good chance at crashing then
     */
    qom_tree = hmp("info qom-tree");
    g_free(qom_tree);
}
Exemple #3
0
/* Run through the list of pre-defined commands */
static void test_commands(void)
{
    char *response;
    int i;

    for (i = 0; hmp_cmds[i] != NULL; i++) {
        if (verbose) {
            fprintf(stderr, "\t%s\n", hmp_cmds[i]);
        }
        response = hmp(hmp_cmds[i]);
        g_free(response);
    }

}
static void test_device_intro_list(void)
{
    QList *types;
    char *help;

    qtest_start(common_args);

    types = device_type_list(true);
    QDECREF(types);

    help = hmp("device_add help");
    g_free(help);

    qtest_end();
}
void TextureBuilder::createTextureWorkflow(QString prefix, bool bCreateImage , QString backgroundImage , QString destImage, bool last)
{
    QStringList data; data << "Perlin" << "Billow" << "RidgedMulti" << "Voronoi";
    QSharedPointer<ModuleDescriptor> p(new ModuleDescriptor());
    p.data()->setName(prefix+"_Module");
    p.data()->setModuleType(data[SSGX::d1000() % 4]);
    p.data()->setupPropertiesToExport(p.data()->moduleType());
    p.data()->setEnableRandom(true);
    p.data()->setEnabledist(true);

    if (last) {
        p.data()->moduleType() != "Voronoi" ?
                    p.data()->setFreq(1.9*SSGX::floatRand()+1.2) :
                    p.data()->setFreq(5*SSGX::floatRand()+3.2) ;
        p.data()->setLac(1.9*SSGX::floatRand()+1.2);
        p.data()->setPers(0.25*SSGX::floatRand()+0.22);
    } else {
        p.data()->moduleType() != "Voronoi" ?
            p.data()->setFreq(3.2*SSGX::floatRand()+1.2) :
            p.data()->setFreq(10.2*SSGX::floatRand()+5.2);
        p.data()->setLac(3.2*SSGX::floatRand()+1.2);
        p.data()->setPers(0.2*SSGX::floatRand()+0.22);
    }

    _modDesc.insert(p.data()->name(),p);
    QSharedPointer<HeightMapDescriptor> hmp(new HeightMapDescriptor());
    hmp.data()->setName(prefix+"_heightMap");
    _hmDesc.insert(hmp.data()->name(), hmp);

    if (bCreateImage) {
        QSharedPointer<ImageDescriptor> imp(new ImageDescriptor());
        imp.data()->setName(destImage);
        __imDesc.insert(imp.data()->name(),imp);
    }

    QSharedPointer<NoiseMapBuilderDescriptor> nmbd(new NoiseMapBuilderDescriptor());
    nmbd.data()->setName(prefix+"_noiseMapBuilder1");
    nmbd.data()->setSourceModule(p.data()->name());
    nmbd.data()->setSize(1024,512);
    nmbd.data()->setDest(hmp.data()->name());
    _nmbDesc.insert(nmbd.data()->name(),nmbd);
    QSharedPointer<RendererDescriptor> rdp(new RendererDescriptor());
    rdp.data()->setName(prefix+"_renderer");
    rdp.data()->setHeightmap(hmp.data()->name());
    rdp.data()->gradientInfo().clear();
    if (backgroundImage == "") {
        auto rndGradient = ColorOps::randomGradient(12,20, ColorOps::randomHSLColor());
        for (auto i = rndGradient.begin(); i != rndGradient.end(); ++i) {
            rdp.data()->gradientInfo().append(GradientInfo(
                        i.key(),
                        i.value().red(),
                        i.value().green(),
                        i.value().blue(),
                        i.value().alpha())
                        );
        }
        auto c = ColorOps::randomHSLColor();
        rdp.data()->gradientInfo().append(GradientInfo(1.0,c.red(),c.green(),c.blue(),c.alpha()));
    } else {
        auto rndGradient = ColorOps::randomGradient(12,20, ColorOps::randomHSLColor(),true,0,128);
        for (auto i = rndGradient.begin(); i != rndGradient.end(); ++i) {
            rdp.data()->gradientInfo().append(GradientInfo(
                        i.key(),
                        i.value().red(),
                        i.value().green(),
                        i.value().blue(),
                        i.value().alpha())
                        );
        }
        auto c = ColorOps::randomHSLColor();
        rdp.data()->gradientInfo().append(GradientInfo(1.0,c.red(),c.green(),c.blue(),c.alpha()));
    }
    if (last) {
        rdp.data()->setEnabledlight(true);
        rdp.data()->setLightbrightness(2.0);
        rdp.data()->setLightcontrast(1.4);
        auto c =  rdp.data()->gradientInfo().count() / 3;
        auto d = c+ SSGX::dn(c);
        qDebug() << "last enabled. " << c << ", " << d;
        for (auto h = 0; h < rdp.data()->gradientInfo().count(); ++h) {
            if (h < d) {
                auto t = rdp.data()->gradientInfo()[h];
                auto newT = std::tuple<double,int,int,int,int>(
                            std::get<0>(t),
                            std::get<1>(t),
                            std::get<2>(t),
                            std::get<3>(t),
                            255
                            );
                rdp.data()->gradientInfo()[h] = newT;
            } else {
                auto t = rdp.data()->gradientInfo()[h];
                auto newT = std::tuple<double,int,int,int,int>(
                            std::get<0>(t),
                            std::get<1>(t),
                            std::get<2>(t),
                            std::get<3>(t),
                            0
                            );
                rdp.data()->gradientInfo()[h] = newT;

            }
        }
    }
    rdp.data()->setBackgroundImage(backgroundImage);
    rdp.data()->setDestImage(destImage);
    this->addRendererDescriptor(rdp.data()->name(),rdp);
}