Added noise test
This commit is contained in:
parent
4d50ed3fe2
commit
d119cfccc8
40
tests/noise.c
Normal file
40
tests/noise.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <MiniFB.h>
|
||||
|
||||
#define WIDTH 800
|
||||
#define HEIGHT 600
|
||||
static unsigned int s_buffer[WIDTH * HEIGHT];
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main()
|
||||
{
|
||||
int noise, carry, seed = 0xbeef;
|
||||
|
||||
if (!mfb_open("Noise Test", WIDTH, HEIGHT))
|
||||
return 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
int i, state;
|
||||
|
||||
for (i = 0; i < WIDTH * HEIGHT; ++i)
|
||||
{
|
||||
noise = seed;
|
||||
noise >>= 3;
|
||||
noise ^= seed;
|
||||
carry = noise & 1;
|
||||
noise >>= 1;
|
||||
seed >>= 1;
|
||||
seed |= (carry << 30);
|
||||
noise &= 0xFF;
|
||||
s_buffer[i] = MFB_RGB(0, noise, 0);
|
||||
}
|
||||
|
||||
state = mfb_update(s_buffer);
|
||||
|
||||
if (state < 0 || state == MFB_KEY_ESC)
|
||||
break;
|
||||
}
|
||||
|
||||
mfb_close();
|
||||
}
|
Loading…
Reference in New Issue
Block a user