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


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

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


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

示例1: main

void main()
{
    CubeID cube(0);

    VideoBuffer vid;
    vid.initMode(BG0);
    vid.attach(cube);

    for (int x = -1; x < 17; x++) {
        drawColumn(vid, x);
    }

    /*
     * Scroll horizontally through our background based on the accelerometer's X axis.
     *
     * We can scroll with pixel accuracy within a column of tiles via bg0.setPanning().
     * When we get to either edge of the currently plotted tiles, draw a new column
     * of tiles from the source image.
     *
     * Because BG0 is 1 tile wider and taller than the viewport itself, we can pre-load
     * the next column of tiles into the column at the edge before it comes into view.
     */

    float x = 0;
    int prev_xt = 0;

    for (;;) {
        // Scroll based on accelerometer tilt
        Int2 accel = vid.physicalAccel().xy();

        // Floating point pixels
        x += accel.x * (40.0f / 128.0f);

        // Integer pixels
        int xi = x + 0.5f;

        // Integer tiles
        int xt = x / 8;

        while (prev_xt < xt) {
            // Fill in new tiles, just past the right edge of the screen
            drawColumn(vid, prev_xt + 17);
            prev_xt++;
        }

        while (prev_xt > xt) {
            // Fill in new tiles, just past the left edge
            drawColumn(vid, prev_xt - 2);
            prev_xt--;
        }

        // pixel-level scrolling within the current column
        vid.bg0.setPanning(vec(xi, 0));

        System::paint();
    }
}
开发者ID:RandomOutput,项目名称:Scroller,代码行数:57,代码来源:main.cpp

示例2: writePacket

void writePacket()
{
   /*
    * This is one way to write packets to the UsbPipe; using reserve()
    * and commit(). If you already have a buffer that you want to copy to the
    * UsbPipe, you can use write().
    */

    if (Usb::isConnected() && usbPipe.writeAvailable()) {

        /*
         * Access some buffer space for writing the next packet. This
         * is the zero-copy API for writing packets. Both reading and writing
         * have a traditional (one copy) API and a zero-copy API.
         */

        UsbPacket &packet = usbPipe.sendQueue.reserve();

        /*
         * Fill most of the packet with dummy data
         */

        // 28-bit type code, for our own application's use
        packet.setType(0x5A);

        packet.resize(packet.capacity());

        for (unsigned i = 0; i < packet.capacity(); ++i) {
            packet.bytes()[i] = 'a' + i;
        }

        /* 
         * Fill the first 3 bytes with accelerometer data from Cube 0
         */

        Byte3 accel = vid.physicalAccel();

        packet.bytes()[0] = accel.x;
        packet.bytes()[1] = accel.y;
        packet.bytes()[2] = accel.z;

        /*
         * Log the packet for debugging, and commit it to the FIFO.
         * The system will asynchronously send it to our peer.
         */

        LOG("Sending: %d bytes, type=%02x, data=%19h\n",
            packet.size(), packet.type(), packet.bytes());

        usbPipe.sendQueue.commit();
        updatePacketCounts(1, 0);
    }
}
开发者ID:fidiaslothes,项目名称:thundercracker,代码行数:53,代码来源:main.cpp


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