Skip to content

Commit

Permalink
Create screenshots of Texture
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 25, 2024
1 parent 6ba71ea commit c4b93ab
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Texture/Sources/texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#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;
Expand All @@ -19,10 +23,21 @@ static kope_g5_sampler sampler;
static kope_g5_buffer constants;
static everything_set everything;

static const int width = 800;
static const int height = 600;

static bool first_update = true;

static float time(void) {
#ifdef SCREENSHOT
return 0.3f;
#else
return (float)kinc_time();
#endif
}

static void update(void *data) {
kinc_matrix3x3_t matrix = kinc_matrix3x3_rotation_z((float)kinc_time());
kinc_matrix3x3_t matrix = kinc_matrix3x3_rotation_z(time());

constants_type *constants_data = constants_type_buffer_lock(&constants);
constants_data->mvp = matrix;
Expand Down Expand Up @@ -70,10 +85,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 @@ -83,6 +102,10 @@ int kickstart(int argc, char **argv) {

kope_g5_device_create_command_list(&device, &list);

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

kope_g5_buffer_parameters buffer_parameters;
buffer_parameters.size = 250 * 250 * 4;
buffer_parameters.usage_flags = KOPE_G5_BUFFER_USAGE_CPU_WRITE;
Expand Down
5 changes: 5 additions & 0 deletions Texture/kfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ project.addFile('Sources/**');
project.addKongDir('Shaders');
project.setDebugDir('Deployment');

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

project.flatten();

resolve(project);
Binary file added Texture/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 c4b93ab

Please sign in to comment.