本文整理汇总了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();
}