当前位置: 首页>>代码示例>>C++>>正文


C++ FontStyle::dump方法代码示例

本文整理汇总了C++中FontStyle::dump方法的典型用法代码示例。如果您正苦于以下问题:C++ FontStyle::dump方法的具体用法?C++ FontStyle::dump怎么用?C++ FontStyle::dump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FontStyle的用法示例。


在下文中一共展示了FontStyle::dump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

// Initialize GLUT & OpenSG and set up the scene
int main(int argc, char **argv)
{
    // OSG init
    osgInit(argc, argv);

    // GLUT init
    int             winid = setupGLUT(&argc, argv);

    // the connection between GLUT and OpenSG
    GLUTWindowPtr   gwin = GLUTWindow::create();
    gwin->setId(winid);
    gwin->init();

    PathHandler paths;
    paths.push_backPath(".");

    // create the scene
    // build a special txf-font with only a little set of characters
    FontStyle   *fontStyle = FontStyleFactory::the().create(paths, argv[1], 1);
    assert(fontStyle);
    //((TTFontStyle *) fontStyle)->createTXFMap((UChar8 *) ". fps0123456789");
    ((TTFontStyle *) fontStyle)->createTXFMap();

    // write it somewhere
#if 1
    std::ofstream    target;
    target.open("statistics.txf");
    fontStyle->dump(target);
    target.close();
#else
    ostrstream  target;
    fontStyle->dump(target);
#endif
#if 1
    std::ifstream    source;
    source.open("statistics.txf");
#else
#if 0
    // Hack, to get the stuff into memory
    int     bufSize = 100000;
    char    *buffer = new char[bufSize];
    int     numRead;
    FILE    *in = fopen("statistics.txf", "r");

    numRead = fread(buffer, 1, bufSize, in);

    fclose(in);

    istrstream  source(buffer, numRead);
#else
    istrstream  source(target.str(), target.pcount());
#endif
#endif
    TXFFont     *font = new TXFFont("test.txf", source);
    font->initFont();

    fontText.setSize(1);
    font->createInstance(&fontText);

    fontText.setJustifyMajor(MIDDLE_JT);

    lineVec.push_back("0000.00 fps");

    // TXF-Style Texture+Geometry
    n = Node::create();
    txfGeo = Geometry::create();

    ImagePtr  pTxfImg = Image::create();

    if(fontText.fillTXFGeo(*txfGeo, true, lineVec))
    {
        fontText.fillTXFImage(pTxfImg);

        SimpleTexturedMaterialPtr   mat = SimpleTexturedMaterial::create();
        beginEditCP(mat);
        {
            mat->setImage(pTxfImg);
        }

        endEditCP(mat);
        txfGeo->setMaterial(mat);
        beginEditCP(n, Node::CoreFieldMask);
        {
            n->setCore(txfGeo);
        }
    }

    scene = Node::create();

    // add a transformation to make it move
    trans = Transform::create();
    beginEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);
    {
        scene->setCore(trans);
        scene->addChild(n);
    }

    endEditCP(scene, Node::CoreFieldMask | Node::ChildrenFieldMask);

//.........这里部分代码省略.........
开发者ID:mlimper,项目名称:OpenSG1x,代码行数:101,代码来源:testTextStream.cpp


注:本文中的FontStyle::dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。