-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathExampleTrueColor.cpp
executable file
·45 lines (35 loc) · 1.05 KB
/
ExampleTrueColor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// TrueColor Example
// How to open a display in truecolor mode and work with 32 bit integer pixels.
// Part of the PixelToaster Framebuffer Library - http://www.pixeltoaster.com
#include "PixelToaster.h"
#ifdef PIXELTOASTER_NO_STL
# include <vector>
using std::vector;
#endif
using namespace PixelToaster;
int main()
{
const int width = 320;
const int height = 240;
Display display("TrueColor Example", width, height, Output::Default, Mode::TrueColor);
vector<TrueColorPixel> pixels(width * height);
while (display.open())
{
unsigned int index = 0;
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
pixels[index].r = (integer8)(x < 255 ? x : 255);
pixels[index].g = (integer8)(y < 255 ? y : 255);
pixels[index].b = (integer8)(x + y < 255 ? x + y : 255);
++index;
}
}
#ifdef PIXELTOASTER_NO_STL
display.update(pixels.data());
#else
display.update(pixels);
#endif
}
}