paint: cleanup
This commit is contained in:
@@ -32,7 +32,7 @@ static void export_texture_write_texture(char *file, buffer_t *pixels, i32 type,
|
||||
}
|
||||
#endif
|
||||
gpu_texture_t *image = gpu_create_texture_from_bytes(pixels, res_x, res_y, GPU_TEXTURE_FORMAT_RGBA32);
|
||||
any_map_set(data_cached_images, file, image);
|
||||
any_map_set(data_cached_textures, file, image);
|
||||
string_array_t *ar = string_split(file, PATH_SEP);
|
||||
char *name = ar->buffer[ar->length - 1];
|
||||
asset_t *asset = GC_ALLOC_INIT(asset_t, {.name = name, .file = file, .id = g_project->_->next_asset_id++});
|
||||
|
||||
@@ -96,7 +96,7 @@ void import_arm_make_pink(char *abs) {
|
||||
b->buffer[2] = 255;
|
||||
b->buffer[3] = 255;
|
||||
gpu_texture_t *pink = gpu_create_texture_from_bytes(b, 1, 1, GPU_TEXTURE_FORMAT_RGBA32);
|
||||
any_map_set(data_cached_images, abs, pink);
|
||||
any_map_set(data_cached_textures, abs, pink);
|
||||
}
|
||||
|
||||
void import_arm_init_nodes(ui_node_t_array_t *nodes) {
|
||||
@@ -136,7 +136,7 @@ void import_arm_unpack_asset(project_t *project, char *abs, char *file, bool gc_
|
||||
any_array_push(g_project->packed_assets, pa);
|
||||
}
|
||||
gpu_texture_t *image = gpu_create_texture_from_encoded_bytes(pa->bytes, ends_with(pa->name, ".jpg") ? ".jpg" : ".png");
|
||||
any_map_set(data_cached_images, abs, image);
|
||||
any_map_set(data_cached_textures, abs, image);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ void import_arm_run_material_from_project(project_t *project, char *path) {
|
||||
abs = string_copy(path_normalize(abs));
|
||||
import_arm_unpack_asset(project, abs, file, true);
|
||||
}
|
||||
if (any_map_get(data_cached_images, abs) == NULL && !iron_file_exists(abs)) {
|
||||
if (any_map_get(data_cached_textures, abs) == NULL && !iron_file_exists(abs)) {
|
||||
import_arm_make_pink(abs);
|
||||
}
|
||||
import_texture_run(abs, true);
|
||||
@@ -336,7 +336,7 @@ void import_arm_run_project(char *path) {
|
||||
abs = string_copy(path_normalize(abs));
|
||||
import_arm_unpack_asset(g_project, abs, file, false);
|
||||
}
|
||||
if (any_map_get(data_cached_images, abs) == NULL && !iron_file_exists(abs)) {
|
||||
if (any_map_get(data_cached_textures, abs) == NULL && !iron_file_exists(abs)) {
|
||||
import_arm_make_pink(abs);
|
||||
}
|
||||
bool hdr_as_envmap = ends_with(abs, ".hdr") && string_equals(g_project->envmap, abs);
|
||||
@@ -694,7 +694,7 @@ void import_arm_run_brush_from_project(project_t *project, char *path) {
|
||||
abs = string_copy(path_normalize(abs));
|
||||
import_arm_unpack_asset(project, abs, file, true);
|
||||
}
|
||||
if (any_map_get(data_cached_images, abs) == NULL && !iron_file_exists(abs)) {
|
||||
if (any_map_get(data_cached_textures, abs) == NULL && !iron_file_exists(abs)) {
|
||||
import_arm_make_pink(abs);
|
||||
}
|
||||
import_texture_run(abs, true);
|
||||
|
||||
@@ -29,7 +29,7 @@ void import_envmap_get_radiance_mip(gpu_texture_t *mip, i32 level, gpu_texture_t
|
||||
import_envmap_params.w = i;
|
||||
gpu_set_float4(import_envmap_params_loc, import_envmap_params.x, import_envmap_params.y, import_envmap_params.z, import_envmap_params.w);
|
||||
gpu_set_texture(import_envmap_radiance_loc, radiance);
|
||||
gpu_texture_t *noise = data_get_image("bnoise256.k");
|
||||
gpu_texture_t *noise = data_get_texture("bnoise256.k");
|
||||
gpu_set_texture(import_envmap_noise_loc, noise);
|
||||
gpu_draw();
|
||||
gpu_end();
|
||||
|
||||
@@ -7,7 +7,7 @@ typedef struct import_texture_data {
|
||||
} import_texture_data_t;
|
||||
|
||||
gpu_texture_t *import_texture_default_importer(char *path) {
|
||||
return data_get_image(path);
|
||||
return data_get_texture(path);
|
||||
}
|
||||
|
||||
void import_texture_run_on_next_frame(import_texture_data_t *itd) {
|
||||
@@ -28,7 +28,7 @@ void import_texture_run(char *path, bool hdr_as_envmap) {
|
||||
if (string_equals(a->file, path)) {
|
||||
// Set as envmap
|
||||
if (hdr_as_envmap && ends_with(to_lower_case(path), ".hdr")) {
|
||||
gpu_texture_t *image = data_get_image(path);
|
||||
gpu_texture_t *image = data_get_texture(path);
|
||||
import_texture_data_t *itd = GC_ALLOC_INIT(import_texture_data_t, {.path = path, .image = image});
|
||||
sys_notify_on_next_frame(&import_texture_run_on_next_frame, itd); // Make sure file browser process did finish
|
||||
}
|
||||
@@ -40,7 +40,7 @@ void import_texture_run(char *path, bool hdr_as_envmap) {
|
||||
char *ext = substring(path, string_last_index_of(path, ".") + 1, string_length(path));
|
||||
gpu_texture_t *(*importer)(char *path) = any_map_get(import_texture_importers, ext);
|
||||
|
||||
bool cached = any_map_get(data_cached_images, path) != NULL; // Already loaded or pink texture for missing file
|
||||
bool cached = any_map_get(data_cached_textures, path) != NULL; // Already loaded or pink texture for missing file
|
||||
gpu_texture_t *image;
|
||||
if (importer == NULL || cached) {
|
||||
image = import_texture_default_importer(path);
|
||||
@@ -53,7 +53,7 @@ void import_texture_run(char *path, bool hdr_as_envmap) {
|
||||
return;
|
||||
}
|
||||
|
||||
any_map_set(data_cached_images, path, image);
|
||||
any_map_set(data_cached_textures, path, image);
|
||||
string_array_t *ar = string_split(path, PATH_SEP);
|
||||
char *name = ar->buffer[ar->length - 1];
|
||||
asset_t *asset = GC_ALLOC_INIT(asset_t, {.name = name, .file = path, .id = g_project->_->next_asset_id++});
|
||||
|
||||
Reference in New Issue
Block a user