Skip to content

Commit

Permalink
Create a Shader screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 24, 2024
1 parent 3ec252e commit aa746ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Shader/Sources/shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@
#include <assert.h>
#include <stdlib.h>

#ifdef SCREENSHOT
#include "../../screenshot.h"
#endif

static kope_g5_device device;
static kope_g5_command_list list;
static vertex_in_buffer vertices;
static kope_g5_buffer indices;

const int width = 1024;
const int height = 768;

static void update(void *data) {
kope_g5_texture *framebuffer = kope_g5_device_get_framebuffer(&device);

Expand Down Expand Up @@ -40,10 +47,14 @@ static void update(void *data) {
kope_g5_command_list_present(&list);

kope_g5_device_execute_command_list(&device, &list);

#ifdef SCREENSHOT
screenshot_take(&device, &list, framebuffer, width, height);
#endif
}

int kickstart(int argc, char **argv) {
kinc_init("Example", 1024, 768, NULL, NULL);
kinc_init("Example", width, height, NULL, NULL);
kinc_set_update_callback(update, NULL);

kope_g5_device_wishlist wishlist = {0};
Expand All @@ -53,6 +64,10 @@ int kickstart(int argc, char **argv) {

kope_g5_device_create_command_list(&device, &list);

#ifdef SCREENSHOT
screenshot_init_buffer(&device, width, height);
#endif

kong_create_buffer_vertex_in(&device, 3, &vertices);
vertex_in *v = kong_vertex_in_buffer_lock(&vertices);

Expand Down
4 changes: 4 additions & 0 deletions Shader/kfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ project.addFile('Sources/**');
project.addKongDir('Shaders');
project.setDebugDir('Deployment');

if (Options.screenshot) {
project.addDefine('SCREENSHOT');
}

project.flatten();

resolve(project);
Binary file added Shader/reference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aa746ac

Please sign in to comment.