paint: fix bgra swap
This commit is contained in:
@@ -36,7 +36,7 @@ void ui_view2d_init() {
|
||||
}
|
||||
|
||||
void ui_view2d_capture_output(void *_) {
|
||||
util_texture_capture_output(ui_view2d_tex, "tex_capture");
|
||||
util_texture_capture_output(ui_view2d_tex, "tex_capture", false);
|
||||
}
|
||||
|
||||
void ui_view2d_draw_edit() {
|
||||
|
||||
@@ -233,7 +233,13 @@ void ui_nodes_capture_output() {
|
||||
ui_nodes_t *ui_nodes = ui_nodes_get_nodes();
|
||||
ui_node_canvas_t *c = ui_nodes_get_canvas(true);
|
||||
ui_node_t *sel = ui_get_node(c->nodes, ui_nodes->nodes_selected_id->buffer[0]);
|
||||
util_texture_capture_output(ui_nodes_get_node_preview_image(sel), "node_preview");
|
||||
|
||||
bool bgra = false;
|
||||
#ifdef IRON_BGRA
|
||||
bgra = string_equals(sel->type, "TEX_IMAGE") || starts_with(sel->type, "NEURAL_");
|
||||
#endif
|
||||
|
||||
util_texture_capture_output(ui_nodes_get_node_preview_image(sel), "node_preview", bgra);
|
||||
}
|
||||
|
||||
void ui_viewnodes_on_canvas_capture_output(void *_) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "../global.h"
|
||||
|
||||
void util_texture_capture_output(gpu_texture_t *img, char *basename) {
|
||||
void util_texture_capture_output(gpu_texture_t *img, char *basename, bool bgra) {
|
||||
if (img == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -21,7 +21,15 @@ void util_texture_capture_output(gpu_texture_t *img, char *basename) {
|
||||
}
|
||||
}
|
||||
|
||||
u8_array_t *bytes = iron_encode_png(gpu_get_texture_pixels(img), img->width, img->height, 0);
|
||||
buffer_t *buf = gpu_get_texture_pixels(img);
|
||||
|
||||
#ifdef IRON_BGRA
|
||||
if (bgra) {
|
||||
buf = buffer_bgra_swap(buf); // Vulkan non-rt textures need a flip
|
||||
}
|
||||
#endif
|
||||
|
||||
u8_array_t *bytes = iron_encode_png(buf, img->width, img->height, 0);
|
||||
packed_asset_t *pa = GC_ALLOC_INIT(packed_asset_t, {.name = abs, .bytes = bytes});
|
||||
any_array_push(g_project->packed_assets, pa);
|
||||
gpu_texture_t *copy = gpu_create_texture_from_encoded_bytes(bytes, ".png");
|
||||
|
||||
Reference in New Issue
Block a user