add stb image
This commit is contained in:
parent
b33e491293
commit
c212e5ce1e
@ -30,6 +30,7 @@ build_lib_wasm_release sokol_shape shape/sokol_shape_wasm_gl_release SOKOL
|
||||
build_lib_wasm_release sokol_fontstash fontstash/sokol_fontstash_wasm_gl_release SOKOL_GLES3
|
||||
build_lib_wasm_release sokol_fetch fetch/sokol_fetch_wasm_gl_release SOKOL_GLES3
|
||||
build_lib_wasm_release sokol_gl gl/sokol_gl_wasm_gl_release SOKOL_GLES3
|
||||
build_lib_wasm_release stb_image stbi/stb_image SOKOL_GLES3
|
||||
|
||||
# wasm + GL + Debug
|
||||
build_lib_wasm_debug sokol_log log/sokol_log_wasm_gl_debug SOKOL_GLES3
|
||||
@ -43,5 +44,6 @@ build_lib_wasm_debug sokol_shape shape/sokol_shape_wasm_gl_debug SOKOL_G
|
||||
build_lib_wasm_debug sokol_fontstash fontstash/sokol_fontstash_wasm_gl_debug SOKOL_GLES3
|
||||
build_lib_wasm_debug sokol_fetch fetch/sokol_fetch_wasm_gl_debug SOKOL_GLES3
|
||||
build_lib_wasm_debug sokol_gl gl/sokol_gl_wasm_gl_debug SOKOL_GLES3
|
||||
build_lib_wasm_debug stb_image stbi/stb_image SOKOL_GLES3
|
||||
|
||||
rm *.o
|
||||
|
||||
11
modules/sokol-jai/sokol/c/stb_image.c
Normal file
11
modules/sokol-jai/sokol/c/stb_image.c
Normal file
@ -0,0 +1,11 @@
|
||||
#ifdef WIN32
|
||||
#define __EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define __EXPORT
|
||||
#endif
|
||||
|
||||
#define STBIDEF extern __EXPORT
|
||||
|
||||
#define STBI_NO_STDIO
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
7985
modules/sokol-jai/sokol/c/stb_image.h
Normal file
7985
modules/sokol-jai/sokol/c/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
modules/stb_image/android/arm64/stb_image.a
Normal file
BIN
modules/stb_image/android/arm64/stb_image.a
Normal file
Binary file not shown.
BIN
modules/stb_image/android/arm64/stb_image.so
Normal file
BIN
modules/stb_image/android/arm64/stb_image.so
Normal file
Binary file not shown.
BIN
modules/stb_image/android/x64/stb_image.a
Normal file
BIN
modules/stb_image/android/x64/stb_image.a
Normal file
Binary file not shown.
BIN
modules/stb_image/android/x64/stb_image.so
Normal file
BIN
modules/stb_image/android/x64/stb_image.so
Normal file
Binary file not shown.
145
modules/stb_image/bindings.jai
Normal file
145
modules/stb_image/bindings.jai
Normal file
@ -0,0 +1,145 @@
|
||||
//
|
||||
// This file was auto-generated using the following command:
|
||||
//
|
||||
// jai generate.jai
|
||||
//
|
||||
|
||||
|
||||
|
||||
STBI_VERSION :: 1;
|
||||
|
||||
STBI :: enum u32 {
|
||||
default :: 0;
|
||||
|
||||
grey :: 1;
|
||||
grey_alpha :: 2;
|
||||
rgb :: 3;
|
||||
rgb_alpha :: 4;
|
||||
|
||||
STBI_default :: default;
|
||||
|
||||
STBI_grey :: grey;
|
||||
STBI_grey_alpha :: grey_alpha;
|
||||
STBI_rgb :: rgb;
|
||||
STBI_rgb_alpha :: rgb_alpha;
|
||||
}
|
||||
|
||||
//
|
||||
// load image by filename, open file, or memory buffer
|
||||
//
|
||||
stbi_io_callbacks :: struct {
|
||||
read: #type (user: *void, data: *u8, size: s32) -> s32 #c_call; // fill 'data' with 'size' bytes. return number of bytes actually read
|
||||
skip: #type (user: *void, n: s32) -> void #c_call; // skip the next 'n' bytes, or 'unget' the last -n bytes if negative
|
||||
eof: #type (user: *void) -> s32 #c_call; // returns nonzero if we are at end of file/data
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
//
|
||||
// 8-bits-per-channel interface
|
||||
//
|
||||
stbi_load_from_memory :: (buffer: *u8, len: s32, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u8 #foreign stb_image;
|
||||
stbi_load_from_callbacks :: (clbk: *stbi_io_callbacks, user: *void, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u8 #foreign stb_image;
|
||||
|
||||
stbi_load :: (filename: *u8, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u8 #foreign stb_image;
|
||||
stbi_load_from_file :: (f: *FILE, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u8 #foreign stb_image;
|
||||
|
||||
stbi_load_gif_from_memory :: (buffer: *u8, len: s32, delays: **s32, x: *s32, y: *s32, z: *s32, comp: *s32, req_comp: s32) -> *u8 #foreign stb_image;
|
||||
|
||||
////////////////////////////////////
|
||||
//
|
||||
// 16-bits-per-channel interface
|
||||
//
|
||||
stbi_load_16_from_memory :: (buffer: *u8, len: s32, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u16 #foreign stb_image;
|
||||
stbi_load_16_from_callbacks :: (clbk: *stbi_io_callbacks, user: *void, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u16 #foreign stb_image;
|
||||
|
||||
stbi_load_16 :: (filename: *u8, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u16 #foreign stb_image;
|
||||
stbi_load_from_file_16 :: (f: *FILE, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *u16 #foreign stb_image;
|
||||
|
||||
stbi_loadf_from_memory :: (buffer: *u8, len: s32, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *float #foreign stb_image;
|
||||
stbi_loadf_from_callbacks :: (clbk: *stbi_io_callbacks, user: *void, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *float #foreign stb_image;
|
||||
|
||||
stbi_loadf :: (filename: *u8, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *float #foreign stb_image;
|
||||
stbi_loadf_from_file :: (f: *FILE, x: *s32, y: *s32, channels_in_file: *s32, desired_channels: s32) -> *float #foreign stb_image;
|
||||
|
||||
stbi_hdr_to_ldr_gamma :: (gamma: float) -> void #foreign stb_image;
|
||||
stbi_hdr_to_ldr_scale :: (scale: float) -> void #foreign stb_image;
|
||||
|
||||
stbi_ldr_to_hdr_gamma :: (gamma: float) -> void #foreign stb_image;
|
||||
stbi_ldr_to_hdr_scale :: (scale: float) -> void #foreign stb_image;
|
||||
|
||||
// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR
|
||||
stbi_is_hdr_from_callbacks :: (clbk: *stbi_io_callbacks, user: *void) -> s32 #foreign stb_image;
|
||||
stbi_is_hdr_from_memory :: (buffer: *u8, len: s32) -> s32 #foreign stb_image;
|
||||
|
||||
stbi_is_hdr :: (filename: *u8) -> s32 #foreign stb_image;
|
||||
stbi_is_hdr_from_file :: (f: *FILE) -> s32 #foreign stb_image;
|
||||
|
||||
// get a VERY brief reason for failure
|
||||
// on most compilers (and ALL modern mainstream compilers) this is threadsafe
|
||||
stbi_failure_reason :: () -> *u8 #foreign stb_image;
|
||||
|
||||
// free the loaded image -- this is just free()
|
||||
stbi_image_free :: (retval_from_stbi_load: *void) -> void #foreign stb_image;
|
||||
|
||||
// get image dimensions & components without fully decoding
|
||||
stbi_info_from_memory :: (buffer: *u8, len: s32, x: *s32, y: *s32, comp: *s32) -> s32 #foreign stb_image;
|
||||
stbi_info_from_callbacks :: (clbk: *stbi_io_callbacks, user: *void, x: *s32, y: *s32, comp: *s32) -> s32 #foreign stb_image;
|
||||
stbi_is_16_bit_from_memory :: (buffer: *u8, len: s32) -> s32 #foreign stb_image;
|
||||
stbi_is_16_bit_from_callbacks :: (clbk: *stbi_io_callbacks, user: *void) -> s32 #foreign stb_image;
|
||||
|
||||
stbi_info :: (filename: *u8, x: *s32, y: *s32, comp: *s32) -> s32 #foreign stb_image;
|
||||
stbi_info_from_file :: (f: *FILE, x: *s32, y: *s32, comp: *s32) -> s32 #foreign stb_image;
|
||||
stbi_is_16_bit :: (filename: *u8) -> s32 #foreign stb_image;
|
||||
stbi_is_16_bit_from_file :: (f: *FILE) -> s32 #foreign stb_image;
|
||||
|
||||
// for image formats that explicitly notate that they have premultiplied alpha,
|
||||
// we just return the colors as stored in the file. set this flag to force
|
||||
// unpremultiplication. results are undefined if the unpremultiply overflow.
|
||||
stbi_set_unpremultiply_on_load :: (flag_true_if_should_unpremultiply: s32) -> void #foreign stb_image;
|
||||
|
||||
// indicate whether we should process iphone images back to canonical format,
|
||||
// or just pass them through "as-is"
|
||||
stbi_convert_iphone_png_to_rgb :: (flag_true_if_should_convert: s32) -> void #foreign stb_image;
|
||||
|
||||
// flip the image vertically, so the first pixel in the output array is the bottom left
|
||||
stbi_set_flip_vertically_on_load :: (flag_true_if_should_flip: s32) -> void #foreign stb_image;
|
||||
|
||||
// as above, but only applies to images loaded on the thread that calls the function
|
||||
// this function is only available if your compiler supports thread-local variables;
|
||||
// calling it will fail to link if your compiler doesn't
|
||||
stbi_set_unpremultiply_on_load_thread :: (flag_true_if_should_unpremultiply: s32) -> void #foreign stb_image;
|
||||
stbi_convert_iphone_png_to_rgb_thread :: (flag_true_if_should_convert: s32) -> void #foreign stb_image;
|
||||
stbi_set_flip_vertically_on_load_thread :: (flag_true_if_should_flip: s32) -> void #foreign stb_image;
|
||||
|
||||
// ZLIB client - used by PNG, available for other purposes
|
||||
stbi_zlib_decode_malloc_guesssize :: (buffer: *u8, len: s32, initial_size: s32, outlen: *s32) -> *u8 #foreign stb_image;
|
||||
stbi_zlib_decode_malloc_guesssize_headerflag :: (buffer: *u8, len: s32, initial_size: s32, outlen: *s32, parse_header: s32) -> *u8 #foreign stb_image;
|
||||
stbi_zlib_decode_malloc :: (buffer: *u8, len: s32, outlen: *s32) -> *u8 #foreign stb_image;
|
||||
stbi_zlib_decode_buffer :: (obuffer: *u8, olen: s32, ibuffer: *u8, ilen: s32) -> s32 #foreign stb_image;
|
||||
|
||||
stbi_zlib_decode_noheader_malloc :: (buffer: *u8, len: s32, outlen: *s32) -> *u8 #foreign stb_image;
|
||||
stbi_zlib_decode_noheader_buffer :: (obuffer: *u8, olen: s32, ibuffer: *u8, ilen: s32) -> s32 #foreign stb_image;
|
||||
|
||||
#scope_file
|
||||
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
stb_image :: #library "windows/stb_image";
|
||||
} else #if OS == .LINUX {
|
||||
stb_image :: #library "linux/stb_image";
|
||||
} else #if OS == .MACOS {
|
||||
stb_image :: #library "macos/stb_image";
|
||||
} else #if OS == .ANDROID {
|
||||
#if CPU == .X64 {
|
||||
stb_image :: #library "android/x64/stb_image";
|
||||
} else #if CPU == .ARM64 {
|
||||
stb_image :: #library "android/arm64/stb_image";
|
||||
}
|
||||
} else #if OS == .PS5 {
|
||||
stb_image :: #library "ps5/stb_image";
|
||||
} else #if OS == .WASM {
|
||||
stb_image :: #library "wasm/stb_image";
|
||||
} else {
|
||||
#assert false;
|
||||
}
|
||||
|
||||
151
modules/stb_image/generate.jai
Normal file
151
modules/stb_image/generate.jai
Normal file
@ -0,0 +1,151 @@
|
||||
AT_COMPILE_TIME :: true;
|
||||
|
||||
SOURCE_PATH :: "source";
|
||||
LIB_BASE_NAME :: "stb_image";
|
||||
|
||||
#if AT_COMPILE_TIME {
|
||||
#run,stallable {
|
||||
set_build_options_dc(.{do_output=false});
|
||||
options := get_build_options();
|
||||
args := options.compile_time_command_line;
|
||||
if !generate_bindings(args, options.minimum_os_version) {
|
||||
compiler_set_workspace_status(.FAILED);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#import "System";
|
||||
|
||||
main :: () {
|
||||
set_working_directory(path_strip_filename(get_path_of_running_executable()));
|
||||
if !generate_bindings(get_command_line_arguments(), #run get_build_options().minimum_os_version) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generate_bindings :: (args: [] string, minimum_os_version: type_of(Build_Options.minimum_os_version)) -> bool {
|
||||
target_android := array_find(args, "-android");
|
||||
target_x64 := array_find(args, "-x64");
|
||||
target_arm := array_find(args, "-arm64");
|
||||
compile := array_find(args, "-compile");
|
||||
compile_debug := array_find(args, "-debug");
|
||||
|
||||
os_target := OS;
|
||||
cpu_target := CPU;
|
||||
if target_android os_target = .ANDROID;
|
||||
if target_x64 cpu_target = .X64;
|
||||
if target_arm cpu_target = .ARM64;
|
||||
|
||||
lib_directory: string;
|
||||
if os_target == {
|
||||
case .WINDOWS;
|
||||
lib_directory = "windows";
|
||||
case .LINUX;
|
||||
lib_directory = "linux";
|
||||
case .MACOS;
|
||||
lib_directory = "macos";
|
||||
case .ANDROID;
|
||||
lib_directory = ifx cpu_target == .X64 then "android/x64" else "android/arm64";
|
||||
case .PS5;
|
||||
lib_directory = "ps5";
|
||||
case;
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if compile {
|
||||
source_file := tprint("%/stb_image.c", SOURCE_PATH);
|
||||
|
||||
make_directory_if_it_does_not_exist(lib_directory, recursive = true);
|
||||
lib_path := tprint("%/%", lib_directory, LIB_BASE_NAME);
|
||||
success := true;
|
||||
if os_target == .MACOS {
|
||||
lib_path_x64 := tprint("%_x64", lib_path);
|
||||
lib_path_arm64 := tprint("%_arm64", lib_path);
|
||||
macos_x64_version_arg := "-mmacos-version-min=10.13"; // Our current x64 min version
|
||||
macos_arm64_version_arg := "-mmacos-version-min=11.0"; // Earliest version that supports arm64
|
||||
// x64 variant
|
||||
success &&= build_cpp_dynamic_lib(lib_path_x64, source_file, extra = .["-arch", "x86_64", macos_x64_version_arg], debug=compile_debug);
|
||||
success &&= build_cpp_static_lib( lib_path_x64, source_file, extra = .["-arch", "x86_64", macos_x64_version_arg], debug=compile_debug);
|
||||
// arm64 variant
|
||||
success &&= build_cpp_dynamic_lib(lib_path_arm64, source_file, extra = .["-arch", "arm64", macos_arm64_version_arg], debug=compile_debug);
|
||||
success &&= build_cpp_static_lib( lib_path_arm64, source_file, extra = .["-arch", "arm64", macos_arm64_version_arg], debug=compile_debug);
|
||||
// create universal binaries
|
||||
run_result := run_command("lipo", "-create", tprint("%.dylib", lib_path_x64), tprint("%.dylib", lib_path_arm64), "-output", tprint("%.dylib", lib_path));
|
||||
success &&= (run_result.exit_code == 0);
|
||||
run_result = run_command("lipo", "-create", tprint("%.a", lib_path_x64), tprint("%.a", lib_path_arm64), "-output", tprint("%.a", lib_path));
|
||||
success &&= (run_result.exit_code == 0);
|
||||
} else {
|
||||
extra: [..] string;
|
||||
if os_target == .ANDROID {
|
||||
_, target_triple_with_sdk := get_android_target_triple(cpu_target);
|
||||
array_add(*extra, "-target", target_triple_with_sdk);
|
||||
}
|
||||
if os_target != .WINDOWS {
|
||||
array_add(*extra, "-fPIC");
|
||||
}
|
||||
|
||||
if os_target != .PS5 && os_target != .WASM {
|
||||
success &&= build_cpp_dynamic_lib(lib_path, source_file, target = os_target, debug = compile_debug, extra = extra);
|
||||
}
|
||||
success &&= build_cpp_static_lib(lib_path, source_file, target = os_target, debug = compile_debug, extra = extra);
|
||||
}
|
||||
|
||||
if !success return false;
|
||||
}
|
||||
|
||||
options: Generate_Bindings_Options;
|
||||
options.os = os_target;
|
||||
options.cpu = cpu_target;
|
||||
{
|
||||
using options;
|
||||
|
||||
array_add(*libpaths, lib_directory);
|
||||
array_add(*libnames, LIB_BASE_NAME);
|
||||
array_add(*source_files, tprint("%/stb_image.h", SOURCE_PATH));
|
||||
array_add(*typedef_prefixes_to_unwrap, "stbi_");
|
||||
|
||||
|
||||
generate_library_declarations = false;
|
||||
footer = tprint(FOOTER_TEMPLATE, LIB_BASE_NAME);
|
||||
|
||||
auto_detect_enum_prefixes = true;
|
||||
log_stripped_declarations = false;
|
||||
generate_compile_time_struct_checks = false;
|
||||
}
|
||||
|
||||
output_filename := "bindings.jai";
|
||||
return generate_bindings(options, output_filename);
|
||||
}
|
||||
|
||||
FOOTER_TEMPLATE :: #string END
|
||||
|
||||
#if OS == .WINDOWS {
|
||||
%1 :: #library "windows/%1";
|
||||
} else #if OS == .LINUX {
|
||||
%1 :: #library "linux/%1";
|
||||
} else #if OS == .MACOS {
|
||||
%1 :: #library "macos/%1";
|
||||
} else #if OS == .ANDROID {
|
||||
#if CPU == .X64 {
|
||||
%1 :: #library "android/x64/%1";
|
||||
} else #if CPU == .ARM64 {
|
||||
%1 :: #library "android/arm64/%1";
|
||||
}
|
||||
} else #if OS == .PS5 {
|
||||
%1 :: #library "ps5/%1";
|
||||
} else #if OS == .WASM {
|
||||
// Wasm will be linked with emcc.
|
||||
} else {
|
||||
#assert false;
|
||||
}
|
||||
|
||||
END
|
||||
|
||||
#import "Basic";
|
||||
#import "Bindings_Generator";
|
||||
#import "BuildCpp";
|
||||
#import "Compiler";
|
||||
#import "File";
|
||||
#import "Process";
|
||||
#import "Toolchains/Android";
|
||||
|
||||
BIN
modules/stb_image/linux/stb_image.a
Normal file
BIN
modules/stb_image/linux/stb_image.a
Normal file
Binary file not shown.
BIN
modules/stb_image/linux/stb_image.so
Executable file
BIN
modules/stb_image/linux/stb_image.so
Executable file
Binary file not shown.
12
modules/stb_image/module.jai
Normal file
12
modules/stb_image/module.jai
Normal file
@ -0,0 +1,12 @@
|
||||
#load "bindings.jai";
|
||||
|
||||
#if OS == .WINDOWS || OS == .PS5 || OS == .WASM {
|
||||
#scope_module
|
||||
FILE :: void;
|
||||
} else #if OS_IS_UNIX {
|
||||
#import "POSIX";
|
||||
#library,system,link_always "libm";
|
||||
} else {
|
||||
#assert false;
|
||||
}
|
||||
|
||||
11
modules/stb_image/source/stb_image.c
Normal file
11
modules/stb_image/source/stb_image.c
Normal file
@ -0,0 +1,11 @@
|
||||
#ifdef WIN32
|
||||
#define __EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define __EXPORT
|
||||
#endif
|
||||
|
||||
#define STBIDEF extern __EXPORT
|
||||
|
||||
#define STBI_NO_STDIO
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
7985
modules/stb_image/source/stb_image.h
Normal file
7985
modules/stb_image/source/stb_image.h
Normal file
File diff suppressed because it is too large
Load Diff
BIN
modules/stb_image/windows/stb_image.dll
Normal file
BIN
modules/stb_image/windows/stb_image.dll
Normal file
Binary file not shown.
BIN
modules/stb_image/windows/stb_image.lib
Normal file
BIN
modules/stb_image/windows/stb_image.lib
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user