This commit is contained in:
luboslenco
2025-09-28 19:38:08 +02:00
parent 3b65a7a6a3
commit 6b3222e30a
39 changed files with 201 additions and 288 deletions
+3 -8
View File
@@ -7,7 +7,7 @@
#include <sys/stat.h>
#include <sys/types.h>
extern char mobile_title[1024];
extern char android_title[1024];
ANativeActivity *iron_android_get_activity(void);
jclass iron_android_find_class(JNIEnv *env, const char *name);
@@ -15,17 +15,12 @@ jclass iron_android_find_class(JNIEnv *env, const char *name);
JNIEXPORT void JNICALL Java_org_armory3d_IronActivity_onAndroidFilePicked(JNIEnv *env, jobject jobj, jstring jstr) {
if (jstr == NULL) return;
const char *str = (*env)->GetStringUTFChars(env, jstr, 0);
size_t len = strlen(str);
wchar_t filePath[len + 1];
mbstowcs(filePath, (char *)str, len);
filePath[len] = 0;
iron_internal_drop_files_callback(filePath);
iron_internal_drop_files_callback(str);
(*env)->ReleaseStringUTFChars(env, jstr, str);
}
JNIEXPORT jstring JNICALL Java_org_armory3d_IronActivity_getMobileTitle(JNIEnv *env, jobject jobj) {
jstring result = (*env)->NewStringUTF(env, mobile_title);
jstring result = (*env)->NewStringUTF(env, android_title);
return result;
}
+5 -1
View File
@@ -47,6 +47,7 @@ static const char *videoFormats[] = {"ts", NULL};
static __kernel_time_t start_sec = 0;
static void (*resizeCallback)(int x, int y, void *data) = NULL;
static void *resizeCallbackData = NULL;
static char ios_title[1024];
#ifdef WITH_GAMEPAD
static float last_x = 0.0f;
static float last_y = 0.0f;
@@ -1210,9 +1211,12 @@ void iron_window_change_mode(iron_window_mode_t mode) {}
void iron_window_destroy() {}
void iron_window_show() {}
void iron_window_hide() {}
void iron_window_set_title(const char *title) {}
void iron_window_create(iron_window_options_t *win) {}
void iron_window_set_title(const char *title) {
strcpy(android_title, title);
}
void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
resizeCallback = callback;
resizeCallbackData = data;
+8 -5
View File
@@ -10,7 +10,7 @@
#define MAX_TOUCH_COUNT 10
extern char mobile_title[1024];
static char ios_title[1024];
static void *touches[MAX_TOUCH_COUNT];
static int backing_width;
static int backing_height;
@@ -222,9 +222,12 @@ void iron_window_change_mode(iron_window_mode_t mode) {}
void iron_window_destroy() {}
void iron_window_show() {}
void iron_window_hide() {}
void iron_window_set_title(const char *title) {}
void iron_window_create(iron_window_options_t *win) {}
void iron_window_set_title(const char *title) {
strcpy(ios_title, title);
}
void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {
resize_callback = callback;
resize_callback_data = data;
@@ -477,7 +480,7 @@ int iron_window_display() {
void importFile(NSURL *url) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *folderName = [NSString stringWithUTF8String:mobile_title];
NSString *folderName = [NSString stringWithUTF8String:ios_title];
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:folderName];
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
[[NSFileManager defaultManager] createDirectoryAtPath:filePath withIntermediateDirectories:NO attributes:nil error:nil];
@@ -488,8 +491,8 @@ void importFile(NSURL *url) {
CFURLStartAccessingSecurityScopedResource(cfurl);
[[NSFileManager defaultManager] copyItemAtPath:url.path toPath:filePath error:nil];
CFURLStopAccessingSecurityScopedResource(cfurl);
wchar_t *wpath = (wchar_t *)[filePath cStringUsingEncoding:NSUTF32LittleEndianStringEncoding];
iron_internal_drop_files_callback(wpath);
const char *cpath = [filePath cStringUsingEncoding:NSUTF8StringEncoding];
iron_internal_drop_files_callback(cpath);
}
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
+45 -5
View File
@@ -614,6 +614,47 @@ static int xk_to_iron(KeySym symbol) {
return IRON_KEY_UNKNOWN;
}
void *gc_alloc(size_t size);
static char *uri_decode(const char *src) {
char *res = gc_alloc(1024);
char *dst = res;
char a, b;
while (*src) {
if ((*src == '%') && ((a = src[1]) && (b = src[2])) && (isxdigit(a) && isxdigit(b))) {
if (a >= 'a') {
a -= 'a' - 'A';
}
if (a >= 'A') {
a -= ('A' - 10);
}
else {
a -= '0';
}
if (b >= 'a') {
b -= 'a' - 'A';
}
if (b >= 'A') {
b -= ('A' - 10);
}
else {
b -= '0';
}
*dst++ = 16 * a + b;
src += 3;
}
else if (*src == '+') {
*dst++ = ' ';
src++;
}
else {
*dst++ = *src++;
}
}
*dst++ = '\0';
return res;
}
static bool _handle_messages() {
static bool controlDown = false;
static int ignoreKeycode = 0;
@@ -853,12 +894,11 @@ static bool _handle_messages() {
size_t len = 0;
while (pos < numItems) {
if (data[pos] == '\r') { // Found a file
wchar_t filePath[len + 1];
mbstowcs(filePath, buffer, len);
filePath[len] = 0;
iron_internal_drop_files_callback(filePath + 7); // Strip file://
pos += 2; // Avoid \n
buffer[len] = 0;
len = 0;
pos += 2; // Avoid \n
char *res = uri_decode(buffer + 7); // + 7 -> strip file://
iron_internal_drop_files_callback(res);
}
buffer[len++] = data[pos++];
}
+1 -1
View File
@@ -402,7 +402,7 @@ static int getMouseY(NSEvent *event) {
if ([[pboard types] containsObject:NSURLPboardType]) {
NSArray *urls = [pboard readObjectsForClasses:@[[NSURL class]] options:nil];
for (NSURL *fileURL in urls) {
wchar_t *filePath = (wchar_t *)[fileURL.path cStringUsingEncoding:NSUTF32LittleEndianStringEncoding];
const char *filePath = [fileURL.path cStringUsingEncoding:NSUTF8StringEncoding];
iron_internal_drop_files_callback(filePath);
}
}
-15
View File
@@ -33,11 +33,8 @@ bool iron_mouse_can_lock(void) {
}
void iron_mouse_show() {}
void iron_mouse_hide() {}
void iron_mouse_set_position(int x, int y) {}
void iron_mouse_get_position(int *x, int *y) {}
__attribute__((import_module("imports"), import_name("js_time"))) int js_time();
@@ -131,44 +128,32 @@ int iron_window_height() {
}
void iron_window_resize(int width, int height) {}
void iron_window_move(int x, int y) {}
// In HTML5 fullscreen is activable only from user input.
void iron_window_change_mode(iron_window_mode_t mode) {
if (mode == IRON_WINDOW_MODE_FULLSCREEN) {
if (iron_internal_window_mode == IRON_WINDOW_MODE_FULLSCREEN) {
iron_internal_window_mode = mode;
return;
}
// TODO: call js Fullscreen API
iron_internal_window_mode = mode;
}
else {
if (mode == iron_internal_window_mode) {
return;
}
// TODO: call js Fullscreen API
iron_internal_window_mode = mode;
}
}
void iron_window_destroy() {}
void iron_window_show() {}
void iron_window_hide() {}
// TODO: change browser title.
void iron_window_set_title(const char *title) {}
void iron_window_create(iron_window_options_t *win) {}
void iron_window_set_resize_callback(void (*callback)(int x, int y, void *data), void *data) {}
void iron_window_set_close_callback(bool (*callback)(void *), void *data) {}
iron_window_mode_t iron_window_get_mode() {
return iron_internal_window_mode;
}
+24 -1
View File
@@ -765,7 +765,9 @@ LRESULT WINAPI IronWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L
for (unsigned i = 0; i < count; ++i) {
wchar_t filePath[260];
if (DragQueryFileW(hDrop, i, filePath, 260)) {
iron_internal_drop_files_callback(filePath);
char buffer[1024];
WideCharToMultiByte(CP_UTF8, 0, filePath, wcslen(filePath) + 1, buffer, sizeof(buffer), NULL, NULL);
iron_internal_drop_files_callback(buffer);
}
}
DragFinish(hDrop);
@@ -1298,6 +1300,27 @@ bool iron_internal_call_close_callback() {
return true;
}
bool _save_and_quit_callback_internal() {
bool save = false;
wchar_t title[1024];
GetWindowTextW(iron_windows_window_handle(), title, sizeof(title));
bool dirty = wcsstr(title, L"* - ArmorPaint") != NULL;
if (dirty) {
int res = MessageBox(iron_windows_window_handle(), L"Project has been modified, save changes?", L"Save Changes?", MB_YESNOCANCEL | MB_ICONEXCLAMATION);
if (res == IDYES) {
save = true;
}
else if (res == IDNO) {
save = false;
}
else { // Cancel
return false;
}
}
iron_save_and_quit(save);
return false;
}
#ifdef WITH_GAMEPAD
bool iron_gamepad_connected(int num) {
+22 -139
View File
@@ -181,7 +181,6 @@ bool f32_isnan(f32 f) {
}
void _kickstart();
bool enable_window = true;
bool in_background = false;
int paused_frames = 0;
@@ -190,7 +189,6 @@ bool input_down = false;
int last_window_width = 0;
int last_window_height = 0;
#endif
char temp_string[1024 * 128];
char temp_string_vs[1024 * 128];
char temp_string_fs[1024 * 128];
@@ -271,14 +269,12 @@ int kickstart(int argc, char **argv) {
iron_threads_init();
iron_display_init();
gc_start(&argc);
_kickstart();
#ifdef WITH_AUDIO
iron_a2_shutdown();
#endif
gc_stop();
return 0;
}
@@ -348,24 +344,6 @@ unsigned char *iron_deflate_raw(unsigned char *data, int data_len, int *out_len,
#include <time.h>
#endif
#ifdef IRON_MACOS
const char *iron_get_resource_path();
#endif
#ifdef IRON_IOS
const char *iron_get_resource_path();
#endif
#if defined(IRON_IOS) || defined(IRON_ANDROID)
char mobile_title[1024];
#endif
static gpu_buffer_t rt_constant_buffer;
static gpu_raytrace_pipeline_t rt_pipeline;
static gpu_raytrace_acceleration_structure_t rt_accel;
static bool rt_created = false;
static bool rt_accel_created = false;
const int rt_constant_buffer_size = 24;
void _update(void *data) {
#ifdef IRON_WINDOWS
if (in_background && ++paused_frames > 3) {
@@ -580,68 +558,21 @@ void _pen_move(int x, int y, float pressure) {
#endif
}
void _drop_files(wchar_t *file_path, void *data) {
// Update mouse position
#ifdef IRON_WINDOWS
void _drop_files(char *file_path, void *data) {
// Update mouse position
#ifdef IRON_WINDOWS
POINT p;
GetCursorPos(&p);
ScreenToClient(iron_windows_window_handle(), &p);
_mouse_move(p.x, p.y, 0, 0, NULL);
#endif
#endif
char buffer[1024];
iron_drop_files(file_path);
#ifdef IRON_WINDOWS
WideCharToMultiByte(CP_UTF8, 0, file_path, wcslen(file_path) + 1, buffer, sizeof(buffer), NULL, NULL);
#else
wcstombs(buffer, file_path, sizeof(buffer));
#endif
iron_drop_files(buffer);
in_background = false;
#ifdef IDLE_SLEEP
#ifdef IDLE_SLEEP
paused_frames = 0;
#endif
}
char *uri_decode(const char *src) {
char *res = gc_alloc(1024);
char *dst = res;
char a, b;
while (*src) {
if ((*src == '%') && ((a = src[1]) && (b = src[2])) && (isxdigit(a) && isxdigit(b))) {
if (a >= 'a') {
a -= 'a' - 'A';
}
if (a >= 'A') {
a -= ('A' - 10);
}
else {
a -= '0';
}
if (b >= 'a') {
b -= 'a' - 'A';
}
if (b >= 'A') {
b -= ('A' - 10);
}
else {
b -= '0';
}
*dst++ = 16 * a + b;
src += 3;
}
else if (*src == '+') {
*dst++ = ' ';
src++;
}
else {
*dst++ = *src++;
}
}
*dst++ = '\0';
return res;
#endif
}
f32 math_floor(f32 x) { return floorf(x); }
@@ -1154,6 +1085,11 @@ gpu_texture_t *gpu_create_texture_from_encoded_bytes(buffer_t *data, string_t *f
return texture;
}
void gpu_delete_texture(gpu_texture_t *texture) {
gpu_texture_destroy(texture);
free(texture);
}
gpu_texture_t *iron_load_texture(string_t *file) {
#ifdef WITH_EMBED
buffer_t *b = embed_get(file);
@@ -1166,7 +1102,6 @@ gpu_texture_t *iron_load_texture(string_t *file) {
if (!iron_file_reader_open(&reader, file, IRON_FILE_TYPE_ASSET)) {
return NULL;
}
int size = (int)iron_file_reader_size(&reader);
unsigned char *data = (unsigned char *)malloc(size);
iron_file_reader_read(&reader, data, size);
@@ -1177,11 +1112,6 @@ gpu_texture_t *iron_load_texture(string_t *file) {
return gpu_create_texture_from_encoded_bytes(&buf, file);
}
void iron_delete_texture(gpu_texture_t *texture) {
gpu_texture_destroy(texture);
free(texture);
}
#ifdef WITH_AUDIO
any iron_load_sound(string_t *file) {
@@ -1210,17 +1140,6 @@ buffer_t *iron_load_blob(string_t *file) {
return buffer;
}
void iron_set_window_title(string_t *title) {
iron_window_set_title(title);
#if defined(IRON_IOS) || defined(IRON_ANDROID)
strcpy(mobile_title, title);
#endif
}
void iron_set_window_mode(i32 mode) {
iron_window_change_mode((iron_window_mode_t)mode);
}
i32 iron_screen_dpi() {
return iron_display_current_mode(iron_primary_display()).pixels_per_inch;
}
@@ -1334,26 +1253,6 @@ i32 iron_sys_command(string_t *cmd) {
return result;
}
string_t *iron_get_files_location() {
#ifdef IRON_MACOS
char path[1024];
strcpy(path, iron_get_resource_path());
strcat(path, "/");
strcat(path, IRON_OUTDIR);
strcat(path, "/");
return path;
#elif defined(IRON_IOS)
char path[1024];
strcpy(path, iron_get_resource_path());
strcat(path, "/");
strcat(path, IRON_OUTDIR);
strcat(path, "/");
return path;
#else
return iron_internal_get_files_location();
#endif
}
typedef struct _callback_data {
int32_t size;
char url[512];
@@ -1404,37 +1303,14 @@ void iron_file_download(string_t *url, void (*callback)(char *, buffer_t *), i32
iron_https_request(url_base, url_path, NULL, 443, 0, &_https_callback, cbd);
}
#ifdef IRON_LINUX
#if defined(IRON_WINDOWS) || (defined(IRON_LINUX) && defined(WITH_NFD))
bool _save_and_quit_callback_internal();
#endif
bool _save_and_quit_callback(void *data) {
#ifdef IRON_WINDOWS
bool save = false;
wchar_t title[1024];
GetWindowTextW(iron_windows_window_handle(), title, sizeof(title));
bool dirty = wcsstr(title, L"* - ArmorPaint") != NULL;
if (dirty) {
int res = MessageBox(iron_windows_window_handle(), L"Project has been modified, save changes?", L"Save Changes?", MB_YESNOCANCEL | MB_ICONEXCLAMATION);
if (res == IDYES) {
save = true;
}
else if (res == IDNO) {
save = false;
}
else { // Cancel
return false;
}
}
iron_save_and_quit(save);
return false;
#if defined(IRON_WINDOWS) || (defined(IRON_LINUX) && defined(WITH_NFD)) // Has gtk
return _save_and_quit_callback_internal();
#endif
#if defined(IRON_LINUX) && defined(WITH_NFD) // Has gtk
_save_and_quit_callback_internal();
return false;
#endif
return true;
}
@@ -1865,6 +1741,13 @@ void iron_mp4_encode(buffer_t *pixels) {
}
#endif
static gpu_buffer_t rt_constant_buffer;
static gpu_raytrace_pipeline_t rt_pipeline;
static gpu_raytrace_acceleration_structure_t rt_accel;
static bool rt_created = false;
static bool rt_accel_created = false;
const int rt_constant_buffer_size = 24;
void iron_raytrace_init(buffer_t *shader) {
if (rt_created) {
gpu_buffer_destroy(&rt_constant_buffer);
+20 -10
View File
@@ -11,15 +11,6 @@
#include <malloc.h>
#include <memory.h>
#endif
#ifdef IRON_IOS
const char *iron_get_resource_path(void);
#endif
#ifdef IRON_MACOS
const char *iron_get_resource_path(void);
#endif
#ifdef IRON_WINDOWS
#include <backends/windows_mini.h>
#endif
@@ -28,13 +19,32 @@ static char *fileslocation = NULL;
#ifdef IRON_WINDOWS
static wchar_t wfilepath[1001];
#endif
#if defined(IRON_MACOS) || defined(IRON_IOS)
const char *iron_get_resource_path();
#endif
void iron_internal_set_files_location(char *dir) {
fileslocation = dir;
}
char *iron_internal_get_files_location(void) {
char *iron_internal_files_location(void) {
#ifdef IRON_MACOS
char path[1024];
strcpy(path, iron_get_resource_path());
strcat(path, "/");
strcat(path, IRON_OUTDIR);
strcat(path, "/");
return path;
#elif defined(IRON_IOS)
char path[1024];
strcpy(path, iron_get_resource_path());
strcat(path, "/");
strcat(path, IRON_OUTDIR);
strcat(path, "/");
return path;
#else
return fileslocation;
#endif
}
#ifdef IRON_WINDOWS
+1 -1
View File
@@ -50,7 +50,7 @@ uint8_t iron_read_u8(uint8_t *data);
int8_t iron_read_s8(uint8_t *data);
void iron_internal_set_files_location(char *dir);
char *iron_internal_get_files_location(void);
char *iron_internal_files_location(void);
bool iron_internal_file_reader_open(iron_file_reader_t *reader, const char *filename, int type);
typedef struct iron_file_writer {
+3 -3
View File
@@ -94,7 +94,7 @@ static void (*resume_callback)(void *) = NULL;
static void *resume_callback_data = NULL;
static void (*shutdown_callback)(void *) = NULL;
static void *shutdown_callback_data = NULL;
static void (*drop_files_callback)(wchar_t *, void *) = NULL;
static void (*drop_files_callback)(char *, void *) = NULL;
static void *drop_files_callback_data = NULL;
static char *(*cut_callback)(void *) = NULL;
static void *cut_callback_data = NULL;
@@ -137,7 +137,7 @@ void iron_set_shutdown_callback(void (*callback)(void *), void *data) {
shutdown_callback_data = data;
}
void iron_set_drop_files_callback(void (*callback)(wchar_t *, void *), void *data) {
void iron_set_drop_files_callback(void (*callback)(char *, void *), void *data) {
drop_files_callback = callback;
drop_files_callback_data = data;
}
@@ -193,7 +193,7 @@ void iron_internal_shutdown_callback(void) {
}
}
void iron_internal_drop_files_callback(wchar_t *filePath) {
void iron_internal_drop_files_callback(char *filePath) {
if (drop_files_callback != NULL) {
drop_files_callback(filePath, drop_files_callback_data);
}
+2 -2
View File
@@ -100,7 +100,7 @@ void iron_set_resume_callback(void (*callback)(void *), void *data);
void iron_set_pause_callback(void (*callback)(void *), void *data);
void iron_set_background_callback(void (*callback)(void *), void *data);
void iron_set_shutdown_callback(void (*callback)(void *), void *data);
void iron_set_drop_files_callback(void (*callback)(wchar_t *, void *), void *data);
void iron_set_drop_files_callback(void (*callback)(char *, void *), void *data);
void iron_set_cut_callback(char *(*callback)(void *), void *data);
void iron_set_copy_callback(char *(*callback)(void *), void *data);
void iron_set_paste_callback(void (*callback)(char *, void *), void *data);
@@ -115,7 +115,7 @@ void iron_internal_resume_callback(void);
void iron_internal_pause_callback(void);
void iron_internal_background_callback(void);
void iron_internal_shutdown_callback(void);
void iron_internal_drop_files_callback(wchar_t *);
void iron_internal_drop_files_callback(char *);
char *iron_internal_cut_callback(void);
char *iron_internal_copy_callback(void);
void iron_internal_paste_callback(char *);
+2 -2
View File
@@ -189,7 +189,7 @@ function data_delete_image(handle: string) {
if (image == null) {
return;
}
iron_delete_texture(image);
gpu_delete_texture(image);
map_delete(data_cached_images, handle);
}
@@ -247,7 +247,7 @@ function data_delete_all() {
let cached_images_keys: string[] = map_keys(data_cached_images);
for (let i: i32 = 0; i < cached_images_keys.length; ++i) {
let c: gpu_texture_t = map_get(data_cached_images, cached_images_keys[i]);
iron_delete_texture(c);
gpu_delete_texture(c);
}
data_cached_images = map_create();
+1 -1
View File
@@ -105,7 +105,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) {
dest = iron_internal_save_path();
}
else {
dest = iron_get_files_location() + path_sep;
dest = iron_internal_files_location() + path_sep;
}
dest += path;
+4 -5
View File
@@ -152,7 +152,6 @@ declare function json_encode_end_array(): void;
declare function json_encode_begin_object(): void;
declare function json_encode_end_object(): void;
declare function json_encode_map(m: map_t<string, string>): void;
declare function uri_decode(s: string): string;
declare function js_eval(js: string): f32;
declare function js_call(f: any): string;
@@ -226,8 +225,8 @@ declare function gpu_create_pipeline(): any;
declare function gpu_delete_pipeline(pipeline: any): void;
declare function gpu_pipeline_compile(pipeline: any): void;
declare function gpu_set_pipeline(pipeline: any): void;
declare function gpu_delete_texture(image: gpu_texture_t): void;
declare function iron_load_texture(file: string): any;
declare function iron_delete_texture(image: gpu_texture_t): void;
declare function iron_load_sound(file: string): any;
declare function iron_a1_sound_destroy(sound: any): void;
declare function iron_a1_play_sound(sound: any, loop: bool, pitch: f32, unique: bool): audio_channel_t;
@@ -253,9 +252,9 @@ declare function gpu_device_name(): string;
declare function iron_time(): f32;
declare function iron_window_width(): i32;
declare function iron_window_height(): i32;
declare function iron_set_window_title(title: string): void;
declare function iron_window_set_title(title: string): void;
declare function iron_window_get_mode(): i32;
declare function iron_set_window_mode(mode: i32): void;
declare function iron_window_change_mode(mode: i32): void;
declare function iron_window_resize(width: i32, height: i32): void;
declare function iron_window_move(x: i32, y: i32): void;
declare function iron_screen_dpi(): i32;
@@ -284,7 +283,7 @@ declare function iron_sys_command(cmd: string): i32;
declare function iron_internal_save_path(): string;
declare function iron_get_arg_count(): i32;
declare function iron_get_arg(index: i32): string;
declare function iron_get_files_location(): string;
declare function iron_internal_files_location(): string;
declare function iron_file_download(url: string, callback: (url: string, _: buffer_t)=>void, size: i32 = 0): void;
declare function draw_init(image_vert: buffer_t, image_frag: buffer_t, image_transform_vert: buffer_t, image_transform_frag: buffer_t, rect_vert: buffer_t, rect_frag: buffer_t, tris_vert: buffer_t, tris_frag: buffer_t, text_vert: buffer_t, text_frag: buffer_t): void;
+2 -28
View File
@@ -5,12 +5,6 @@ let path_sep: string = "\\";
let path_sep: string = "/";
///end
// ///if arm_windows
// let path_pwd: string = "cd";
// ///else
// let path_pwd: string = "echo $PWD";
// ///end
let path_mesh_formats: string[] = ["obj", "blend"];
let path_texture_formats: string[] = ["jpg", "jpeg", "png", "tga", "bmp", "psd", "gif", "hdr", "k"];
@@ -25,10 +19,8 @@ let path_roughness_ext: string[] = ["roughness", "rough", "r", "rgh"];
let path_metallic_ext: string[] = ["metallic", "metal", "metalness", "m", "met"];
let path_displacement_ext: string[] = ["displacement", "height", "h", "disp"];
// let path_working_dir_cache: string = null;
function path_data(): string {
return iron_get_files_location() + path_sep + data_path();
return iron_internal_files_location() + path_sep + data_path();
}
function path_to_relative(from: string, to: string): string {
@@ -75,24 +67,6 @@ function path_base_name(path: string): string {
return substring(path, string_last_index_of(path, path_sep) + 1, string_last_index_of(path, "."));
}
// function path_working_dir(): string {
// if (path_working_dir_cache == null) {
// let cmd: string = path_pwd;
// let save: string;
// if (path_is_protected()) {
// save = iron_internal_save_path();
// }
// else {
// save = path_data() + path_sep;
// }
// save += "working_dir.txt";
// iron_sys_command(cmd + " > \"" + save + "\"");
// path_working_dir_cache = sys_buffer_to_string(iron_load_blob(save));
// path_working_dir_cache = trim_end(path_working_dir_cache);
// }
// return path_working_dir_cache;
// }
function path_is_mesh(path: string): bool {
let p: string = to_lower_case(path);
for (let i: i32 = 0; i < path_mesh_formats.length; ++i) {
@@ -192,7 +166,7 @@ function path_is_folder(p: string): bool {
function path_is_protected(): bool {
///if arm_windows
return string_index_of(iron_get_files_location(), "Program Files") >= 0;
return string_index_of(iron_internal_files_location(), "Program Files") >= 0;
///elseif arm_android
return true;
///elseif arm_ios
+2 -2
View File
@@ -245,7 +245,7 @@ function render_path_resize() {
for (let i: i32 = 0; i < render_targets_keys.length; ++i) {
let rt: render_target_t = map_get(render_path_render_targets, render_targets_keys[i]);
if (rt != null && rt.width == 0) {
iron_delete_texture(rt._image);
gpu_delete_texture(rt._image);
rt._image = render_path_create_image(rt);
}
}
@@ -305,6 +305,6 @@ function render_target_create(): render_target_t {
function render_target_unload(raw: render_target_t) {
if (raw._image != null) {
iron_delete_texture(raw._image);
gpu_delete_texture(raw._image);
}
}
+1 -1
View File
@@ -241,7 +241,7 @@ function sys_title(): string {
}
function sys_title_set(value: string) {
iron_set_window_title(value);
iron_window_set_title(value);
_sys_window_title = value;
}
+2 -2
View File
@@ -161,7 +161,7 @@ function list_folder(path: string) {
storage.text = string_replace_all(storage.text, "\r", "");
text_handle.text = storage.text;
editor_handle.redraws = 1;
iron_set_window_title(abs);
iron_window_set_title(abs);
}
// Expand folder
else {
@@ -318,7 +318,7 @@ function draw_minimap() {
if (minimap_h != iron_window_height()) {
minimap_h = iron_window_height();
if (minimap != null) {
iron_delete_texture(minimap);
gpu_delete_texture(minimap);
}
minimap = gpu_create_render_target(minimap_w, minimap_h);
}
+2 -5
View File
@@ -59,9 +59,6 @@ function base_init() {
base_last_window_height = iron_window_height();
sys_notify_on_drop_files(function (drop_path: string) {
///if arm_linux
drop_path = uri_decode(drop_path);
///end
drop_path = trim_end(drop_path);
array_push(base_drop_paths, drop_path);
});
@@ -667,10 +664,10 @@ function base_toggle_fullscreen() {
config_raw.window_h = iron_window_height();
config_raw.window_x = iron_window_x();
config_raw.window_y = iron_window_y();
iron_set_window_mode(window_mode_t.FULLSCREEN);
iron_window_change_mode(window_mode_t.FULLSCREEN);
}
else {
iron_set_window_mode(window_mode_t.WINDOWED);
iron_window_change_mode(window_mode_t.WINDOWED);
iron_window_resize(config_raw.window_w, config_raw.window_h);
iron_window_move(config_raw.window_x, config_raw.window_y);
}
+1 -1
View File
@@ -34,7 +34,7 @@ function color_node_get_as_image(self: color_node_t, from: i32): gpu_texture_t {
return logic_node_input_get_as_image(self.base.inputs[0]);
}
if (self.image != null) {
iron_delete_texture(self.image);
gpu_delete_texture(self.image);
}
let b: buffer_t = buffer_create(16);
buffer_set_f32(b, 0, self.value.x);
+1 -1
View File
@@ -30,7 +30,7 @@ function float_node_get_as_image(self: float_node_t, from: i32): gpu_texture_t {
return logic_node_input_get_as_image(self.base.inputs[0]);
}
if (self.image != null) {
iron_delete_texture(self.image);
gpu_delete_texture(self.image);
}
let b: buffer_t = buffer_create(16);
buffer_set_f32(b, 0, self.value);
+1 -1
View File
@@ -38,7 +38,7 @@ function vector_node_get_as_image(self: vector_node_t, from: i32): gpu_texture_t
// let y: f32 = logic_node_input_get(self.base.inputs[1]);
// let z: f32 = logic_node_input_get(self.base.inputs[2]);
if (self.image != null) {
iron_delete_texture(self.image);
gpu_delete_texture(self.image);
}
let b: buffer_t = buffer_create(16);
let n0: float_node_t = self.base.inputs[0].node;
+2 -2
View File
@@ -176,7 +176,7 @@ function export_arm_run_project() {
// ///end
iron_write_png(substring(project_filepath, 0, project_filepath.length - 4) + "_icon.png", mesh_icon_pixels, 256, 256, 0);
iron_delete_texture(mesh_icon);
gpu_delete_texture(mesh_icon);
///end
let is_packed: bool = ends_with(project_filepath, "_packed_.arm");
@@ -468,7 +468,7 @@ function export_arm_pack_assets(raw: project_format_t, assets: asset_t[]) {
for (let i: i32 = 0; i < temp_images.length; ++i) {
let image: gpu_texture_t = temp_images[i];
iron_delete_texture(image);
gpu_delete_texture(image);
}
}
+5 -5
View File
@@ -183,13 +183,13 @@ function import_arm_run_project(path: string) {
let rts: map_t<string, render_target_t> = render_path_render_targets;
let blend0: render_target_t = map_get(rts, "texpaint_blend0");
let _texpaint_blend0: gpu_texture_t = blend0._image;
iron_delete_texture(_texpaint_blend0);
gpu_delete_texture(_texpaint_blend0);
blend0.width = config_get_texture_res_x();
blend0.height = config_get_texture_res_y();
blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8);
let blend1: render_target_t = map_get(rts, "texpaint_blend1");
let _texpaint_blend1: gpu_texture_t = blend1._image;
iron_delete_texture(_texpaint_blend1);
gpu_delete_texture(_texpaint_blend1);
blend1.width = config_get_texture_res_x();
blend1.height = config_get_texture_res_y();
blend1._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8);
@@ -273,13 +273,13 @@ function import_arm_run_project(path: string) {
l.paint_emis = ld.paint_emis;
l.paint_subs = ld.paint_subs;
iron_delete_texture(_texpaint);
gpu_delete_texture(_texpaint);
if (_texpaint_nor != null) {
iron_delete_texture(_texpaint_nor);
gpu_delete_texture(_texpaint_nor);
}
if (_texpaint_pack != null) {
iron_delete_texture(_texpaint_pack);
gpu_delete_texture(_texpaint_pack);
}
}
}
+7 -7
View File
@@ -51,14 +51,14 @@ function layers_resize() {
let blend0: render_target_t = map_get(rts, "texpaint_blend0");
let _texpaint_blend0: gpu_texture_t = blend0._image;
iron_delete_texture(_texpaint_blend0);
gpu_delete_texture(_texpaint_blend0);
blend0.width = config_get_texture_res_x();
blend0.height = config_get_texture_res_y();
blend0._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8);
let blend1: render_target_t = map_get(rts, "texpaint_blend1");
let _texpaint_blend1: gpu_texture_t = blend1._image;
iron_delete_texture(_texpaint_blend1);
gpu_delete_texture(_texpaint_blend1);
blend1.width = config_get_texture_res_x();
blend1.height = config_get_texture_res_y();
blend1._image = gpu_create_render_target(config_get_texture_res_x(), config_get_texture_res_y(), tex_format_t.R8);
@@ -68,7 +68,7 @@ function layers_resize() {
let blur: render_target_t = map_get(rts, "texpaint_blur");
if (blur != null) {
let _texpaint_blur: gpu_texture_t = blur._image;
iron_delete_texture(_texpaint_blur);
gpu_delete_texture(_texpaint_blur);
let size_x: f32 = math_floor(config_get_texture_res_x() * 0.95);
let size_y: f32 = math_floor(config_get_texture_res_y() * 0.95);
blur.width = size_x;
@@ -120,7 +120,7 @@ function layers_make_temp_img() {
function layers_make_temp_mask_img() {
if (pipes_temp_mask_image != null && (pipes_temp_mask_image.width != config_get_texture_res_x() || pipes_temp_mask_image.height != config_get_texture_res_y())) {
let _temp_mask_image: gpu_texture_t = pipes_temp_mask_image;
iron_delete_texture(_temp_mask_image);
gpu_delete_texture(_temp_mask_image);
pipes_temp_mask_image = null;
}
if (pipes_temp_mask_image == null) {
@@ -135,9 +135,9 @@ function layers_make_export_img() {
let _expa: gpu_texture_t = layers_expa;
let _expb: gpu_texture_t = layers_expb;
let _expc: gpu_texture_t = layers_expc;
iron_delete_texture(_expa);
iron_delete_texture(_expb);
iron_delete_texture(_expc);
gpu_delete_texture(_expa);
gpu_delete_texture(_expb);
gpu_delete_texture(_expc);
layers_expa = null;
layers_expb = null;
layers_expc = null;
+4 -4
View File
@@ -223,7 +223,7 @@ function make_material_bake_node_previews() {
let key: string = keys[i];
if (array_index_of(context_raw.node_previews_used, key) == -1) {
let image: gpu_texture_t = map_get(context_raw.node_previews, key);
iron_delete_texture(image);
gpu_delete_texture(image);
map_delete(context_raw.node_previews, key);
}
}
@@ -257,7 +257,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_
let res_y: i32 = math_floor(config_get_texture_res_y() / 4);
if (image == null || image.width != res_x || image.height != res_y) {
if (image != null) {
iron_delete_texture(image);
gpu_delete_texture(image);
}
image = gpu_create_render_target(res_x, res_y);
map_set(context_raw.node_previews, id, image);
@@ -275,7 +275,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_
let res_y: i32 = math_floor(config_get_texture_res_y());
if (image == null || image.width != res_x || image.height != res_y) {
if (image != null) {
iron_delete_texture(image);
gpu_delete_texture(image);
}
image = gpu_create_render_target(res_x, res_y);
map_set(context_raw.node_previews, id, image);
@@ -293,7 +293,7 @@ function make_material_bake_node_preview(node: ui_node_t, group: ui_node_canvas_
let res_y: i32 = math_floor(config_get_texture_res_y());
if (image == null || image.width != res_x || image.height != res_y) {
if (image != null) {
iron_delete_texture(image);
gpu_delete_texture(image);
}
image = gpu_create_render_target(res_x, res_y, tex_format_t.R8);
map_set(context_raw.node_previews, id, image);
@@ -157,7 +157,7 @@ function photo_to_pbr_node_get_as_image(self: photo_to_pbr_node_t, from: i32): g
draw_begin(photo_to_pbr_node_images[from]);
draw_image(temp2, x * photo_to_pbr_node_tile_w, y * photo_to_pbr_node_tile_w);
draw_end();
iron_delete_texture(temp2);
gpu_delete_texture(temp2);
}
return photo_to_pbr_node_images[from];
+1 -1
View File
@@ -16,7 +16,7 @@ function rgb_node_create(raw: ui_node_t, args: f32_array_t): rgb_node_t {
function rgb_node_get_as_image(self: rgb_node_t, from: i32): gpu_texture_t {
if (self.image != null) {
iron_delete_texture(self.image);
gpu_delete_texture(self.image);
}
let f32a: f32_array_t = f32_array_create(4);
@@ -280,7 +280,7 @@ function text_to_photo_node_vae_decoder(latents: f32_array_t, upscale: bool): gp
while (image.width < config_get_texture_res_x()) {
let last_image: gpu_texture_t = image;
image = upscale_node_esrgan(image);
iron_delete_texture(last_image);
gpu_delete_texture(last_image);
}
return image;
}
+4 -4
View File
@@ -26,7 +26,7 @@ function upscale_node_get_as_image(self: upscale_node_t, from: i32): gpu_texture
while (upscale_node_image.width < config_get_texture_res_x()) {
let last_image: gpu_texture_t = upscale_node_image;
upscale_node_image = upscale_node_esrgan(upscale_node_image);
iron_delete_texture(last_image);
gpu_delete_texture(last_image);
}
}
return upscale_node_image;
@@ -47,7 +47,7 @@ function upscale_node_do_tile(source: gpu_texture_t): gpu_texture_t {
let size2w: i32 = math_floor(size1w * 2);
let size2h: i32 = math_floor(size1h * 2);
if (upscale_node_temp != null) {
iron_delete_texture(upscale_node_temp);
gpu_delete_texture(upscale_node_temp);
}
upscale_node_temp = gpu_create_render_target(size1w, size1h);
draw_begin(upscale_node_temp);
@@ -118,10 +118,10 @@ function upscale_node_esrgan(source: gpu_texture_t): gpu_texture_t {
draw_begin(result);
draw_sub_image(tile_result, x * tile_size2x, y * tile_size2x, 64, 64, tile_size2x, tile_size2x);
draw_end();
iron_delete_texture(tile_result);
gpu_delete_texture(tile_result);
}
}
iron_delete_texture(tile_source);
gpu_delete_texture(tile_source);
}
else {
result = upscale_node_do_tile(source); // Single tile
+3 -3
View File
@@ -25,9 +25,9 @@ function render_path_raytrace_bake_commands(parse_paint_material: (b?: bool)=>vo
let baketex0: render_target_t = map_get(render_path_render_targets, "baketex0");
let baketex1: render_target_t = map_get(render_path_render_targets, "baketex1");
let baketex2: render_target_t = map_get(render_path_render_targets, "baketex2");
iron_delete_texture(baketex0._image);
iron_delete_texture(baketex1._image);
iron_delete_texture(baketex2._image);
gpu_delete_texture(baketex0._image);
gpu_delete_texture(baketex1._image);
gpu_delete_texture(baketex2._image);
}
{
+9 -9
View File
@@ -179,15 +179,15 @@ function slot_layer_unload(raw: slot_layer_t) {
let _texpaint_pack: gpu_texture_t = raw.texpaint_pack;
let _texpaint_preview: gpu_texture_t = raw.texpaint_preview;
iron_delete_texture(_texpaint);
gpu_delete_texture(_texpaint);
if (_texpaint_nor != null) {
iron_delete_texture(_texpaint_nor);
gpu_delete_texture(_texpaint_nor);
}
if (_texpaint_pack != null) {
iron_delete_texture(_texpaint_pack);
gpu_delete_texture(_texpaint_pack);
}
if (_texpaint_preview != null) {
iron_delete_texture(_texpaint_preview);
gpu_delete_texture(_texpaint_preview);
}
map_delete(render_path_render_targets, "texpaint" + raw.ext);
@@ -261,7 +261,7 @@ function slot_layer_invert_mask(raw: slot_layer_t) {
draw_set_pipeline(null);
draw_end();
let _texpaint: gpu_texture_t = raw.texpaint;
iron_delete_texture(_texpaint);
gpu_delete_texture(_texpaint);
let rt: render_target_t = map_get(render_path_render_targets, "texpaint" + raw.id);
raw.texpaint = rt._image = inverted;
context_raw.layer_preview_dirty = true;
@@ -397,12 +397,12 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) {
draw_end();
}
iron_delete_texture(_texpaint);
gpu_delete_texture(_texpaint);
if (_texpaint_nor != null) {
iron_delete_texture(_texpaint_nor);
gpu_delete_texture(_texpaint_nor);
}
if (_texpaint_pack != null) {
iron_delete_texture(_texpaint_pack);
gpu_delete_texture(_texpaint_pack);
}
let rt: render_target_t = map_get(rts, "texpaint" + raw.ext);
@@ -428,7 +428,7 @@ function slot_layer_resize_and_set_bits(raw: slot_layer_t) {
draw_set_pipeline(null);
draw_end();
iron_delete_texture(_texpaint);
gpu_delete_texture(_texpaint);
let rt: render_target_t = map_get(rts, "texpaint" + raw.ext);
rt._image = raw.texpaint;
+2 -2
View File
@@ -80,8 +80,8 @@ function slot_material_create(m: material_data_t = null, c: ui_node_canvas_t = n
}
function slot_material_unload(raw: slot_material_t) {
iron_delete_texture(raw.image);
iron_delete_texture(raw.image_icon);
gpu_delete_texture(raw.image);
gpu_delete_texture(raw.image_icon);
}
function slot_material_delete(raw: slot_material_t) {
+1 -1
View File
@@ -151,7 +151,7 @@ function tab_textures_draw(htab: ui_handle_t) {
f += ".png";
}
iron_write_png(path + path_sep + f, gpu_get_texture_pixels(target), target.width, target.height, 0);
iron_delete_texture(target);
gpu_delete_texture(target);
}, target);
});
});
+2 -2
View File
@@ -66,7 +66,7 @@ function ui_viewnodes_init() {
function ui_viewnodes_on_node_remove(n: ui_node_t) {
let img: gpu_texture_t = map_get(context_raw.node_preview_map, n);
if (img != null) {
iron_delete_texture(img);
gpu_delete_texture(img);
map_delete(context_raw.node_preview_map, n);
}
}
@@ -816,7 +816,7 @@ function ui_nodes_render() {
if (ui_nodes_grid_redraw) {
if (ui_nodes_grid != null) {
iron_delete_texture(ui_nodes_grid);
gpu_delete_texture(ui_nodes_grid);
}
ui_nodes_grid = ui_nodes_draw_grid(ui_nodes.zoom);
ui_nodes_grid_redraw = false;
+1 -1
View File
@@ -75,7 +75,7 @@ function ui_view2d_render() {
// Cache grid
if (ui_view2d_grid_redraw) {
if (ui_view2d_grid != null) {
iron_delete_texture(ui_view2d_grid);
gpu_delete_texture(ui_view2d_grid);
}
ui_view2d_grid = ui_nodes_draw_grid(ui_view2d_pan_scale);
ui_view2d_grid_redraw = false;
+1 -1
View File
@@ -151,7 +151,7 @@ function util_render_make_text_preview() {
tex_w = 512;
}
if (context_raw.text_tool_image != null && context_raw.text_tool_image.width < tex_w) {
iron_delete_texture(context_raw.text_tool_image);
gpu_delete_texture(context_raw.text_tool_image);
context_raw.text_tool_image = null;
}
if (context_raw.text_tool_image == null) {
+4 -4
View File
@@ -12,7 +12,7 @@ let util_uv_pipe_dilate: gpu_pipeline_t = null;
function util_uv_cache_uv_map() {
if (util_uv_uvmap != null && (util_uv_uvmap.width != config_get_texture_res_x() || util_uv_uvmap.height != config_get_texture_res_y())) {
iron_delete_texture(util_uv_uvmap);
gpu_delete_texture(util_uv_uvmap);
util_uv_uvmap = null;
util_uv_uvmap_cached = false;
}
@@ -54,7 +54,7 @@ function util_uv_cache_uv_map() {
function util_uv_cache_triangle_map() {
if (util_uv_trianglemap != null && (util_uv_trianglemap.width != config_get_texture_res_x() || util_uv_trianglemap.height != config_get_texture_res_y())) {
iron_delete_texture(util_uv_trianglemap);
gpu_delete_texture(util_uv_trianglemap);
util_uv_trianglemap = null;
util_uv_trianglemap_cached = false;
}
@@ -92,7 +92,7 @@ function util_uv_cache_triangle_map() {
function util_uv_cache_dilate_map() {
if (util_uv_dilatemap != null && (util_uv_dilatemap.width != config_get_texture_res_x() || util_uv_dilatemap.height != config_get_texture_res_y())) {
iron_delete_texture(util_uv_dilatemap);
gpu_delete_texture(util_uv_dilatemap);
util_uv_dilatemap = null;
util_uv_dilatemap_cached = false;
}
@@ -181,7 +181,7 @@ function util_uv_cache_uv_island_map() {
}
if (util_uv_uvislandmap != null) {
iron_delete_texture(util_uv_uvislandmap);
gpu_delete_texture(util_uv_uvislandmap);
}
util_uv_uvislandmap = gpu_create_texture_from_bytes(bytes, w, h, tex_format_t.R8);
util_uv_uvislandmap_cached = true;