Skip to content

Commit c03bfce

Browse files
committed
Add a framebuffer sample
1 parent b2e5156 commit c03bfce

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

framebuffer/deployment/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't read me, but please keep me.

framebuffer/kfile.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const project = new Project('framebuffer');
2+
3+
await project.addProject(findKore());
4+
5+
project.addFile('sources/**');
6+
project.addKongDir('shaders');
7+
project.setDebugDir('deployment');
8+
9+
if (Options.screenshot) {
10+
project.addDefine('SCREENSHOT');
11+
project.addDefine('KORE_D3D12_FORCE_WARP');
12+
}
13+
14+
project.flatten();
15+
16+
resolve(project);

framebuffer/shaders/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't read me, but please keep me.

framebuffer/sources/main.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#include <kore3/framebuffer/framebuffer.h>
2+
#include <kore3/system.h>
3+
4+
#include <assert.h>
5+
#include <stdlib.h>
6+
7+
#ifdef SCREENSHOT
8+
#include "../../screenshot.h"
9+
#endif
10+
11+
static const uint32_t width = 800;
12+
static const uint32_t height = 600;
13+
14+
static uint32_t frame = 0;
15+
16+
static void update(void *data) {
17+
kore_fb_begin();
18+
19+
for (uint32_t y = 0; y < height; ++y) {
20+
for (uint32_t x = 0; x < width; ++x) {
21+
kore_fb_set_pixel(x, y, (frame + x) % 256, (frame + y) % 256, 0);
22+
}
23+
}
24+
25+
kore_fb_end();
26+
27+
++frame;
28+
}
29+
30+
int kickstart(int argc, char **argv) {
31+
kore_init("framebuffer", width, height, NULL, NULL);
32+
kore_set_update_callback(update, NULL);
33+
34+
kore_fb_init(width, height);
35+
36+
kore_start();
37+
38+
return 0;
39+
}

0 commit comments

Comments
 (0)