summaryrefslogtreecommitdiff
path: root/Rend/README.md
blob: 2655f98751d9786c8979ae3a74772574f4d62b36 (plain)
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
# Rend 

Send data to the GPU in a stable cross-platform and cross-graphics-API way. 

Here's an example render loop used in my game! 

```c
        if (rend_renderer_frame_begin(renderer)) {

            // First pass: draw to a texture representing the in-game pixel art dimentions.
            rend_cmd_render_begin_texture(renderer, &canvas); { // brackets for style
                rend_cmd_bind_pipeline(ui_pipeline);
                rend_cmd_push_constants(ui_pipeline, &push_constants, sizeof(push_constants));
                rend_cmd_draw(ui_pipeline, vert_count, 1); // a vertex buffer is not bound because it's passed via push constants
            } rend_cmd_render_end_texture(renderer, &canvas);

            // Second pass: apply post processing using the native swapchain
            rend_cmd_render_begin(renderer, 1.0, 0.5, 0.0, 1.0); { // RGBA clear colors
                rend_cmd_bind_pipeline(present_pipeline);
                rend_cmd_push_constants(present_pipeline, &present_pc, sizeof(present_pc));
                rend_cmd_draw(present_pipeline, 4, 1); // 4 vertices and one instance
            } rend_cmd_render_end(renderer);

            rend_renderer_frame_end(renderer, &delta);
        }

    }
```