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


C++ VideoBuffer::setWindow方法代码示例

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


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

示例1: main

void main()
{
    const CubeID cube(0);
    static VideoBuffer vid;
    vid.attach(cube);

    /*
     * Blank the screen. This also blanks the one-pixel region between
     * the bottom of the fractal and the top of the elapsed time indicator
     * below.
     */

    vid.initMode(SOLID_MODE);
    vid.colormap[0] = RGB565::fromRGB(0xFFFFFF);
    System::paint();

    /*
     * We use STAMP mode in a special way here, to do (slow) true-color
     * rendering: The framebuffer is simply set up as an identity mapping
     * that shows each of the 16 colors in our colormap. Now we can put
     * a row of 16 pixels directly into the colormap, and render the screen
     * using 1024 of these little 16x1 pixel "frames".
     *
     * Clearly this is really slow, and this technique is unlikely to be
     * frequently useful, but it's a fun parlour trick :)
     */

    SystemTime startTime = SystemTime::now();

    vid.initMode(STAMP);
    vid.stamp.disableKey();

    auto &fb = vid.stamp.initFB<16,1>();
    for (unsigned i = 0; i < 16; i++)
        fb.plot(vec(i, 0U), i);

    for (unsigned y = 0; y < LCD_height - 9; y++)
        for (unsigned x = 0; x < LCD_width; x += 16) {

            /*
             * Render 16 pixels at a time, into a buffer in RAM.
             */

            static RGB565 pixels[16];

            for (unsigned i = 0; i < 16; i++)
                pixels[i] = calculateMandelbrot(vec(x+i, y));

            /*
             * Now copy to VRAM and start painting. By waiting until
             * now to call finish(), we're allowing the calculation above
             * to run concurrently with the cube's paint operation.
             *
             * Note that our "frames" are actually just tiny pieces of the
             * screen, so we need to avoid the default frame rate limits
             * in order to render at an at all reasonable rate. This is
             * where paintUnlimited() comes into play.
             */

            System::finish();
            vid.stamp.setBox(vec(x,y), vec(16,1));
            vid.colormap.set(pixels);
            System::paintUnlimited();
        }

    /*
     * Use BG0_ROM mode to draw the elapsed time at the bottom of the screen.
     */

    TimeDelta elapsed = SystemTime::now() - startTime;

    String<16> message;
    message << (elapsed.milliseconds() / 1000) << "."
        << Fixed(elapsed.milliseconds() % 1000, 3) << " sec";
    LOG("Elapsed time: %s\n", message.c_str());

    vid.initMode(BG0_ROM);
    vid.bg0rom.text(vec(1,0), message);
    vid.setWindow(LCD_height - 8, 8);

    // Kill time (efficiently)
    while (1)
        System::paint();
}
开发者ID:amgregoi,项目名称:Sifteo,代码行数:84,代码来源:main.cpp


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