2014-06-06 08:13:51 +00:00
|
|
|
#include <MiniFB.h>
|
2019-06-08 18:11:02 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-06-09 06:50:28 +00:00
|
|
|
#define WIDTH 800
|
|
|
|
#define HEIGHT 600
|
|
|
|
static unsigned int g_buffer[WIDTH * HEIGHT];
|
2019-06-08 18:11:02 +00:00
|
|
|
|
2014-06-06 08:13:51 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2019-06-08 18:11:02 +00:00
|
|
|
int noise, carry, seed = 0xbeef;
|
2019-06-08 18:34:05 +00:00
|
|
|
|
2019-06-09 06:50:28 +00:00
|
|
|
struct Window *window = mfb_open_ex("Noise Test", WIDTH, HEIGHT, WF_RESIZABLE);
|
|
|
|
if (!window)
|
2019-06-08 18:34:05 +00:00
|
|
|
return 0;
|
|
|
|
|
2019-06-08 18:11:02 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
2019-06-08 18:34:05 +00:00
|
|
|
int i;
|
2019-06-09 06:50:28 +00:00
|
|
|
UpdateState state;
|
2014-06-06 08:13:51 +00:00
|
|
|
|
2019-06-09 06:50:28 +00:00
|
|
|
for (i = 0; i < WIDTH * HEIGHT; ++i)
|
2019-06-08 18:11:02 +00:00
|
|
|
{
|
|
|
|
noise = seed;
|
|
|
|
noise >>= 3;
|
|
|
|
noise ^= seed;
|
|
|
|
carry = noise & 1;
|
|
|
|
noise >>= 1;
|
|
|
|
seed >>= 1;
|
|
|
|
seed |= (carry << 30);
|
|
|
|
noise &= 0xFF;
|
2019-06-09 06:50:28 +00:00
|
|
|
g_buffer[i] = MFB_RGB(noise, noise, noise);
|
2019-06-08 18:11:02 +00:00
|
|
|
}
|
2014-06-06 08:13:51 +00:00
|
|
|
|
2019-06-09 06:50:28 +00:00
|
|
|
state = mfb_update(window, g_buffer);
|
|
|
|
if (state != STATE_OK) {
|
|
|
|
window = 0x0;
|
2019-06-08 18:11:02 +00:00
|
|
|
break;
|
2019-06-08 18:34:05 +00:00
|
|
|
}
|
2019-06-08 18:11:02 +00:00
|
|
|
}
|
2014-06-06 08:13:51 +00:00
|
|
|
|
2019-06-08 18:11:02 +00:00
|
|
|
return 0;
|
2014-06-06 08:13:51 +00:00
|
|
|
}
|