summaryrefslogtreecommitdiff
path: root/c2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c2.cpp')
-rw-r--r--c2.cpp50
1 files changed, 47 insertions, 3 deletions
diff --git a/c2.cpp b/c2.cpp
index f6ad356..bb1b2e1 100644
--- a/c2.cpp
+++ b/c2.cpp
@@ -1,16 +1,60 @@
#include "app.hpp"
+#include "video.hpp"
extern "C" {
#include "plat.h"
+#include "memory.h"
}
+#define video_arena_size (1024 * 1024 * 16)
+#define per_frame_memory_size (1024 * 1024)
+
+struct C2 : public App {
+ Device* dev;
+ void on_resize() override {
+ dev->on_resize();
+ }
+};
+
int main() {
- App* app = App::create("c2");
+ Arena video_arena;
+ Device* dev;
+ Shader* shader;
+ C2* app = App::create<C2>("c2");
+ void* per_frame;
app->running = 1;
+ init_arena(
+ &video_arena,
+ arena_alloc(app->arena, video_arena_size),
+ video_arena_size
+ );
+ dev = Device::create(&video_arena, app);
+ app->dev = dev;
+ shader = dev->load_shader("data/triangle.csh");
+
+ per_frame = heap_alloc(
+ dev->heap,
+ per_frame_memory_size
+ );
+ uint8_t r = 0;
while (app->running) {
+ Arena frame_arena;
+ init_arena(&frame_arena, per_frame, per_frame_memory_size);
+
app->begin();
- if (app->mp(mbtn_left))
- print("%d, %d, %d\n", app->mx, app->my, app->scrolly);
+ dev->begin_frame();
+
+ Pipeline_Builder pb(&frame_arena);
+ pb.begin_rp();
+ pb.rp_target(dev->get_backbuffer(), { r, 0x00, 0xff, 0xff });
+ Render_Pass& pass = pb.build_rp();
+
+ dev->get_ctx().submit(*dev, pass);
+
+ r += 10;
+ dev->present();
app->end();
}
+ shader->destroy(dev);
+ dev->destroy();
app->destroy();
}