Remove LibPNG + Clean Up
This commit is contained in:
parent
1f05424651
commit
11230c120d
14
.gitmodules
vendored
14
.gitmodules
vendored
@ -1,12 +1,5 @@
|
|||||||
[submodule "dependencies/libpng/src"]
|
|
||||||
path = dependencies/libpng/src
|
|
||||||
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/libpng.git
|
|
||||||
[submodule "dependencies/zlib/src"]
|
|
||||||
path = dependencies/libpng/zlib/src
|
|
||||||
url = https://github.com/madler/zlib.git
|
|
||||||
ignore = dirty
|
|
||||||
[submodule "dependencies/glfw/src"]
|
[submodule "dependencies/glfw/src"]
|
||||||
path = media-layer/core/dependencies/glfw/src
|
path = dependencies/glfw/src
|
||||||
url = https://github.com/glfw/glfw.git
|
url = https://github.com/glfw/glfw.git
|
||||||
[submodule "dependencies/zenity/src"]
|
[submodule "dependencies/zenity/src"]
|
||||||
path = dependencies/zenity/src
|
path = dependencies/zenity/src
|
||||||
@ -19,5 +12,8 @@
|
|||||||
url = https://gitlab.com/qemu-project/qemu.git
|
url = https://gitlab.com/qemu-project/qemu.git
|
||||||
ignore = dirty
|
ignore = dirty
|
||||||
[submodule "media-layer/core/gles/dependencies/gles-compatibility-layer"]
|
[submodule "media-layer/core/gles/dependencies/gles-compatibility-layer"]
|
||||||
path = media-layer/core/gles/dependencies/gles-compatibility-layer/src
|
path = dependencies/gles-compatibility-layer/src
|
||||||
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/gles-compatibility-layer.git
|
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/gles-compatibility-layer.git
|
||||||
|
[submodule "dependencies/stb_image/include"]
|
||||||
|
path = dependencies/stb_image/include
|
||||||
|
url = https://github.com/nothings/stb.git
|
||||||
|
@ -37,6 +37,11 @@ option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" ${DE
|
|||||||
if(NOT MCPI_HEADLESS_MODE)
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
option(MCPI_USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE)
|
option(MCPI_USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
if(MCPI_USE_MEDIA_LAYER_PROXY)
|
||||||
|
set(BUILD_MEDIA_LAYER_CORE "${BUILD_NATIVE_COMPONENTS}")
|
||||||
|
else()
|
||||||
|
set(BUILD_MEDIA_LAYER_CORE "${BUILD_ARM_COMPONENTS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# App ID
|
# App ID
|
||||||
set(DEFAULT_APP_ID "com.thebrokenrail.MCPIReborn")
|
set(DEFAULT_APP_ID "com.thebrokenrail.MCPIReborn")
|
||||||
|
14
dependencies/CMakeLists.txt
vendored
14
dependencies/CMakeLists.txt
vendored
@ -1,8 +1,8 @@
|
|||||||
project(dependencies)
|
project(dependencies)
|
||||||
|
|
||||||
# LibPNG
|
# stb_image
|
||||||
if(BUILD_ARM_COMPONENTS)
|
if(BUILD_ARM_COMPONENTS AND NOT MCPI_HEADLESS_MODE)
|
||||||
add_subdirectory(libpng)
|
add_subdirectory(stb_image)
|
||||||
endif()
|
endif()
|
||||||
# Minecraft: Pi Edition
|
# Minecraft: Pi Edition
|
||||||
if(BUILD_ARM_COMPONENTS AND NOT MCPI_OPEN_SOURCE_ONLY)
|
if(BUILD_ARM_COMPONENTS AND NOT MCPI_OPEN_SOURCE_ONLY)
|
||||||
@ -20,3 +20,11 @@ endif()
|
|||||||
if(BUILD_NATIVE_COMPONENTS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64"))
|
if(BUILD_NATIVE_COMPONENTS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "arm*" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64"))
|
||||||
add_subdirectory(qemu)
|
add_subdirectory(qemu)
|
||||||
endif()
|
endif()
|
||||||
|
# GLFW
|
||||||
|
if(BUILD_MEDIA_LAYER_CORE AND NOT MCPI_HEADLESS_MODE)
|
||||||
|
add_subdirectory(glfw)
|
||||||
|
endif()
|
||||||
|
# GLES Compatibility Layer
|
||||||
|
if(BUILD_NATIVE_COMPONENTS AND NOT MCPI_HEADLESS_MODE AND MCPI_USE_GLES1_COMPATIBILITY_LAYER)
|
||||||
|
add_subdirectory(gles-compatibility-layer)
|
||||||
|
endif()
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
project(media-layer-core-gles-dependencies-gles-compatibility-layer)
|
project(gles-compatibility-layer)
|
||||||
|
|
||||||
# GLES Compatibility Layer
|
# GLES Compatibility Layer
|
||||||
set(GLES_COMPATIBILITY_LAYER_USE_DEFAULT_INCLUDE_PATH FALSE CACHE BOOL "" FORCE)
|
|
||||||
set(GLES_COMPATIBILITY_LAYER_USE_ES3 FALSE CACHE BOOL "" FORCE)
|
set(GLES_COMPATIBILITY_LAYER_USE_ES3 FALSE CACHE BOOL "" FORCE)
|
||||||
set(GLES_COMPATIBILITY_LAYER_USE_SDL FALSE CACHE BOOL "" FORCE)
|
set(GLES_COMPATIBILITY_LAYER_USE_SDL FALSE CACHE BOOL "" FORCE)
|
||||||
set(GLES_COMPATIBILITY_LAYER_DEPENDENCY glfw CACHE STRING "" FORCE)
|
set(GLES_COMPATIBILITY_LAYER_DEPENDENCY glfw CACHE STRING "" FORCE)
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
target_link_libraries(gles-compatibility-layer media-layer-headers)
|
|
@ -23,9 +23,6 @@ add_custom_target(glfw-build ALL DEPENDS glfw)
|
|||||||
|
|
||||||
# Install
|
# Install
|
||||||
install(TARGETS glfw DESTINATION "${MCPI_LIB_DIR}")
|
install(TARGETS glfw DESTINATION "${MCPI_LIB_DIR}")
|
||||||
if(BUILD_ARM_COMPONENTS)
|
|
||||||
install(TARGETS glfw EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# License
|
# License
|
||||||
install(FILES src/LICENSE.md DESTINATION "${MCPI_LEGAL_DIR}/glfw")
|
install(FILES src/LICENSE.md DESTINATION "${MCPI_LEGAL_DIR}/glfw")
|
33
dependencies/libpng/CMakeLists.txt
vendored
33
dependencies/libpng/CMakeLists.txt
vendored
@ -1,33 +0,0 @@
|
|||||||
project(libpng)
|
|
||||||
|
|
||||||
# ZLib (Needed By libpng)
|
|
||||||
add_subdirectory(zlib)
|
|
||||||
|
|
||||||
# Silence Warnings
|
|
||||||
add_compile_options(-w)
|
|
||||||
|
|
||||||
## LibPNG
|
|
||||||
|
|
||||||
# Options
|
|
||||||
set(PNG_TESTS FALSE CACHE BOOL "" FORCE)
|
|
||||||
set(PNG_NO_STDIO FALSE CACHE BOOL "" FORCE)
|
|
||||||
set(PNG_BUILD_ZLIB TRUE CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
# Download
|
|
||||||
set(ZLIB_LIBRARY zlibstatic)
|
|
||||||
set(ZLIB_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
|
|
||||||
add_subdirectory(src EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
# Use Symbol Versioning
|
|
||||||
set_target_properties(png12 PROPERTIES LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libpng.vers")
|
|
||||||
|
|
||||||
# Ensure Build
|
|
||||||
add_custom_target(png12-build ALL DEPENDS png12)
|
|
||||||
# Install
|
|
||||||
install(TARGETS png12 DESTINATION "${MCPI_LIB_DIR}")
|
|
||||||
if(BUILD_ARM_COMPONENTS)
|
|
||||||
install(TARGETS png12 zlibstatic EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# License
|
|
||||||
install(FILES src/LICENSE DESTINATION "${MCPI_LEGAL_DIR}/libpng")
|
|
208
dependencies/libpng/libpng.vers
vendored
208
dependencies/libpng/libpng.vers
vendored
@ -1,208 +0,0 @@
|
|||||||
PNG12_0 {global:
|
|
||||||
png_libpng_ver;
|
|
||||||
png_pass_start;
|
|
||||||
png_pass_inc;
|
|
||||||
png_pass_ystart;
|
|
||||||
png_pass_yinc;
|
|
||||||
png_pass_mask;
|
|
||||||
png_pass_dsp_mask;
|
|
||||||
png_access_version_number;
|
|
||||||
png_set_sig_bytes;
|
|
||||||
png_sig_cmp;
|
|
||||||
png_check_sig;
|
|
||||||
png_create_read_struct;
|
|
||||||
png_create_write_struct;
|
|
||||||
png_get_compression_buffer_size;
|
|
||||||
png_set_compression_buffer_size;
|
|
||||||
png_reset_zstream;
|
|
||||||
png_create_read_struct_2;
|
|
||||||
png_create_write_struct_2;
|
|
||||||
png_write_chunk;
|
|
||||||
png_write_chunk_start;
|
|
||||||
png_write_chunk_data;
|
|
||||||
png_write_chunk_end;
|
|
||||||
png_create_info_struct;
|
|
||||||
png_info_init;
|
|
||||||
png_info_init_3;
|
|
||||||
png_write_info_before_PLTE;
|
|
||||||
png_write_info;
|
|
||||||
png_read_info;
|
|
||||||
png_convert_to_rfc1123;
|
|
||||||
png_convert_from_struct_tm;
|
|
||||||
png_convert_from_time_t;
|
|
||||||
png_set_expand;
|
|
||||||
png_set_expand_gray_1_2_4_to_8;
|
|
||||||
png_set_palette_to_rgb;
|
|
||||||
png_set_tRNS_to_alpha;
|
|
||||||
png_set_gray_1_2_4_to_8;
|
|
||||||
png_set_bgr;
|
|
||||||
png_set_gray_to_rgb;
|
|
||||||
png_set_rgb_to_gray;
|
|
||||||
png_set_rgb_to_gray_fixed;
|
|
||||||
png_get_rgb_to_gray_status;
|
|
||||||
png_build_grayscale_palette;
|
|
||||||
png_set_strip_alpha;
|
|
||||||
png_set_swap_alpha;
|
|
||||||
png_set_invert_alpha;
|
|
||||||
png_set_filler;
|
|
||||||
png_set_add_alpha;
|
|
||||||
png_set_swap;
|
|
||||||
png_set_packing;
|
|
||||||
png_set_packswap;
|
|
||||||
png_set_shift;
|
|
||||||
png_set_interlace_handling;
|
|
||||||
png_set_invert_mono;
|
|
||||||
png_set_background;
|
|
||||||
png_set_strip_16;
|
|
||||||
png_set_dither;
|
|
||||||
png_set_gamma;
|
|
||||||
png_permit_empty_plte;
|
|
||||||
png_set_flush;
|
|
||||||
png_write_flush;
|
|
||||||
png_start_read_image;
|
|
||||||
png_read_update_info;
|
|
||||||
png_read_rows;
|
|
||||||
png_read_row;
|
|
||||||
png_read_image;
|
|
||||||
png_write_row;
|
|
||||||
png_write_rows;
|
|
||||||
png_write_image;
|
|
||||||
png_write_end;
|
|
||||||
png_read_end;
|
|
||||||
png_destroy_info_struct;
|
|
||||||
png_destroy_read_struct;
|
|
||||||
png_destroy_write_struct;
|
|
||||||
png_set_crc_action;
|
|
||||||
png_set_filter;
|
|
||||||
png_set_filter_heuristics;
|
|
||||||
png_set_compression_level;
|
|
||||||
png_set_compression_mem_level;
|
|
||||||
png_set_compression_strategy;
|
|
||||||
png_set_compression_window_bits;
|
|
||||||
png_set_compression_method;
|
|
||||||
png_init_io;
|
|
||||||
png_set_error_fn;
|
|
||||||
png_get_error_ptr;
|
|
||||||
png_set_write_fn;
|
|
||||||
png_set_read_fn;
|
|
||||||
png_get_io_ptr;
|
|
||||||
png_set_read_status_fn;
|
|
||||||
png_set_write_status_fn;
|
|
||||||
png_set_mem_fn;
|
|
||||||
png_get_mem_ptr;
|
|
||||||
png_set_read_user_transform_fn;
|
|
||||||
png_set_write_user_transform_fn;
|
|
||||||
png_set_user_transform_info;
|
|
||||||
png_get_user_transform_ptr;
|
|
||||||
png_set_read_user_chunk_fn;
|
|
||||||
png_get_user_chunk_ptr;
|
|
||||||
png_set_progressive_read_fn;
|
|
||||||
png_get_progressive_ptr;
|
|
||||||
png_process_data;
|
|
||||||
png_progressive_combine_row;
|
|
||||||
png_malloc;
|
|
||||||
png_malloc_warn;
|
|
||||||
png_free;
|
|
||||||
png_free_data;
|
|
||||||
png_data_freer;
|
|
||||||
png_malloc_default;
|
|
||||||
png_free_default;
|
|
||||||
png_memcpy_check;
|
|
||||||
png_memset_check;
|
|
||||||
png_error;
|
|
||||||
png_chunk_error;
|
|
||||||
png_warning;
|
|
||||||
png_chunk_warning;
|
|
||||||
png_get_valid;
|
|
||||||
png_get_rowbytes;
|
|
||||||
png_get_rows;
|
|
||||||
png_set_rows;
|
|
||||||
png_get_channels;
|
|
||||||
png_get_image_width;
|
|
||||||
png_get_image_height;
|
|
||||||
png_get_bit_depth;
|
|
||||||
png_get_color_type;
|
|
||||||
png_get_filter_type;
|
|
||||||
png_get_interlace_type;
|
|
||||||
png_get_compression_type;
|
|
||||||
png_get_pixels_per_meter;
|
|
||||||
png_get_x_pixels_per_meter;
|
|
||||||
png_get_y_pixels_per_meter;
|
|
||||||
png_get_pixel_aspect_ratio;
|
|
||||||
png_get_x_offset_pixels;
|
|
||||||
png_get_y_offset_pixels;
|
|
||||||
png_get_x_offset_microns;
|
|
||||||
png_get_y_offset_microns;
|
|
||||||
png_get_signature;
|
|
||||||
png_get_bKGD;
|
|
||||||
png_set_bKGD;
|
|
||||||
png_get_cHRM;
|
|
||||||
png_get_cHRM_fixed;
|
|
||||||
png_set_cHRM;
|
|
||||||
png_set_cHRM_fixed;
|
|
||||||
png_get_gAMA;
|
|
||||||
png_get_gAMA_fixed;
|
|
||||||
png_set_gAMA;
|
|
||||||
png_set_gAMA_fixed;
|
|
||||||
png_get_hIST;
|
|
||||||
png_set_hIST;
|
|
||||||
png_get_IHDR;
|
|
||||||
png_set_IHDR;
|
|
||||||
png_get_oFFs;
|
|
||||||
png_set_oFFs;
|
|
||||||
png_get_pCAL;
|
|
||||||
png_set_pCAL;
|
|
||||||
png_get_pHYs;
|
|
||||||
png_set_pHYs;
|
|
||||||
png_get_PLTE;
|
|
||||||
png_set_PLTE;
|
|
||||||
png_get_sBIT;
|
|
||||||
png_set_sBIT;
|
|
||||||
png_get_sRGB;
|
|
||||||
png_set_sRGB;
|
|
||||||
png_set_sRGB_gAMA_and_cHRM;
|
|
||||||
png_get_iCCP;
|
|
||||||
png_set_iCCP;
|
|
||||||
png_get_sPLT;
|
|
||||||
png_set_sPLT;
|
|
||||||
png_get_text;
|
|
||||||
png_set_text;
|
|
||||||
png_get_tIME;
|
|
||||||
png_set_tIME;
|
|
||||||
png_get_tRNS;
|
|
||||||
png_set_tRNS;
|
|
||||||
png_get_sCAL;
|
|
||||||
png_set_sCAL;
|
|
||||||
png_set_keep_unknown_chunks;
|
|
||||||
png_handle_as_unknown;
|
|
||||||
png_set_unknown_chunks;
|
|
||||||
png_set_unknown_chunk_location;
|
|
||||||
png_get_unknown_chunks;
|
|
||||||
png_set_invalid;
|
|
||||||
png_read_png;
|
|
||||||
png_write_png;
|
|
||||||
png_get_copyright;
|
|
||||||
png_get_header_ver;
|
|
||||||
png_get_header_version;
|
|
||||||
png_get_libpng_ver;
|
|
||||||
png_permit_mng_features;
|
|
||||||
png_get_mmx_flagmask;
|
|
||||||
png_get_asm_flagmask;
|
|
||||||
png_get_asm_flags;
|
|
||||||
png_get_mmx_bitdepth_threshold;
|
|
||||||
png_get_mmx_rowbytes_threshold;
|
|
||||||
png_set_asm_flags;
|
|
||||||
png_set_mmx_thresholds;
|
|
||||||
png_mmx_support;
|
|
||||||
png_set_strip_error_numbers;
|
|
||||||
png_set_user_limits;
|
|
||||||
png_get_user_width_max;
|
|
||||||
png_get_user_height_max;
|
|
||||||
png_get_uint_32;
|
|
||||||
png_get_uint_16;
|
|
||||||
png_get_int_32;
|
|
||||||
png_get_uint_31;
|
|
||||||
png_save_uint_32;
|
|
||||||
png_save_int_32;
|
|
||||||
png_save_uint_16;
|
|
||||||
local: *; };
|
|
1
dependencies/libpng/src
vendored
1
dependencies/libpng/src
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 6c445538879f9e916f8e62723d2ac7cd77d96191
|
|
16
dependencies/libpng/zlib/CMakeLists.txt
vendored
16
dependencies/libpng/zlib/CMakeLists.txt
vendored
@ -1,16 +0,0 @@
|
|||||||
project(zlib)
|
|
||||||
|
|
||||||
# Silence Warnings
|
|
||||||
add_compile_options(-w)
|
|
||||||
|
|
||||||
## zlib
|
|
||||||
|
|
||||||
# Download
|
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0022 NEW) # Fix Error
|
|
||||||
add_subdirectory(src EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
# Ensure Build
|
|
||||||
add_custom_target(zlib-build ALL DEPENDS zlibstatic)
|
|
||||||
|
|
||||||
# License
|
|
||||||
install(FILES src/LICENSE DESTINATION "${MCPI_LEGAL_DIR}/zlib")
|
|
1
dependencies/libpng/zlib/src
vendored
1
dependencies/libpng/zlib/src
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 09155eaa2f9270dc4ed1fa13e2b4b2613e6e4851
|
|
8
dependencies/minecraft-pi/CMakeLists.txt
vendored
8
dependencies/minecraft-pi/CMakeLists.txt
vendored
@ -17,5 +17,13 @@ install(
|
|||||||
DESTINATION "${MCPI_INSTALL_DIR}/game"
|
DESTINATION "${MCPI_INSTALL_DIR}/game"
|
||||||
USE_SOURCE_PERMISSIONS
|
USE_SOURCE_PERMISSIONS
|
||||||
REGEX "api" EXCLUDE
|
REGEX "api" EXCLUDE
|
||||||
|
REGEX "data" EXCLUDE
|
||||||
)
|
)
|
||||||
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
|
install(
|
||||||
|
DIRECTORY "${minecraft-pi_SOURCE_DIR}/data/"
|
||||||
|
DESTINATION "${MCPI_INSTALL_DIR}/game/data"
|
||||||
|
USE_SOURCE_PERMISSIONS
|
||||||
|
)
|
||||||
|
endif()
|
||||||
install_symlink("game/minecraft-pi" "${MCPI_INSTALL_DIR}/minecraft-pi")
|
install_symlink("game/minecraft-pi" "${MCPI_INSTALL_DIR}/minecraft-pi")
|
||||||
|
28
dependencies/stb_image/CMakeLists.txt
vendored
Normal file
28
dependencies/stb_image/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
project(stb_image)
|
||||||
|
|
||||||
|
# Silence Warnings
|
||||||
|
add_compile_options(-w)
|
||||||
|
|
||||||
|
## stb_image
|
||||||
|
|
||||||
|
# Build
|
||||||
|
add_library(stb_image SHARED src/stb_image_impl.c)
|
||||||
|
target_include_directories(
|
||||||
|
stb_image
|
||||||
|
PUBLIC
|
||||||
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
||||||
|
"$<INSTALL_INTERFACE:${MCPI_SDK_INCLUDE_DIR}/stb_image>"
|
||||||
|
)
|
||||||
|
target_link_libraries(stb_image PRIVATE m)
|
||||||
|
target_compile_definitions(stb_image PUBLIC STBI_ONLY_PNG)
|
||||||
|
|
||||||
|
# Install
|
||||||
|
install(TARGETS stb_image DESTINATION "${MCPI_LIB_DIR}")
|
||||||
|
install(
|
||||||
|
DIRECTORY "include/"
|
||||||
|
DESTINATION "${MCPI_SDK_INCLUDE_DIR}/stb_image"
|
||||||
|
)
|
||||||
|
install(TARGETS stb_image EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
||||||
|
|
||||||
|
# License
|
||||||
|
install(FILES include/LICENSE DESTINATION "${MCPI_LEGAL_DIR}/stb_image")
|
1
dependencies/stb_image/include
vendored
Submodule
1
dependencies/stb_image/include
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit beebb24b945efdea3b9bba23affb8eb3ba8982e7
|
5
dependencies/stb_image/src/stb_image_impl.c
vendored
Normal file
5
dependencies/stb_image/src/stb_image_impl.c
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
|
||||||
|
#include "stb_image.h"
|
||||||
|
#include "stb_image_write.h"
|
@ -186,7 +186,7 @@ void pre_bootstrap(int argc, char *argv[]) {
|
|||||||
// Copy SDK Into ~/.minecraft-pi
|
// Copy SDK Into ~/.minecraft-pi
|
||||||
void run_simple_command(const char *const command[], const char *error) {
|
void run_simple_command(const char *const command[], const char *error) {
|
||||||
int status = 0;
|
int status = 0;
|
||||||
char *output = run_command(command, &status);
|
char *output = run_command(command, &status, NULL);
|
||||||
if (output != NULL) {
|
if (output != NULL) {
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ static void run_command_and_set_env(const char *env_name, const char *command[])
|
|||||||
if (getenv(env_name) == NULL) {
|
if (getenv(env_name) == NULL) {
|
||||||
// Run
|
// Run
|
||||||
int return_code;
|
int return_code;
|
||||||
char *output = run_command(command, &return_code);
|
char *output = run_command(command, &return_code, NULL);
|
||||||
if (output != NULL) {
|
if (output != NULL) {
|
||||||
// Trim
|
// Trim
|
||||||
int length = strlen(output);
|
int length = strlen(output);
|
||||||
|
@ -32,3 +32,17 @@ if(BUILD_ARM_COMPONENTS)
|
|||||||
# SDK
|
# SDK
|
||||||
install(TARGETS reborn-patch EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
install(TARGETS reborn-patch EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Fake LibPNG To Satisy Symbol Versioning Requirement
|
||||||
|
if(BUILD_ARM_COMPONENTS)
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.c" "")
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.vers" "PNG12_0 { global: *; };")
|
||||||
|
add_library(fake-libpng SHARED "${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.c")
|
||||||
|
set_target_properties(fake-libpng PROPERTIES
|
||||||
|
OUTPUT_NAME "png12"
|
||||||
|
SOVERSION 0
|
||||||
|
LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_BINARY_DIR}/fake-libpng.vers"
|
||||||
|
)
|
||||||
|
# Install
|
||||||
|
install(TARGETS fake-libpng DESTINATION "${MCPI_LIB_DIR}")
|
||||||
|
endif()
|
||||||
|
@ -36,7 +36,7 @@ char *get_binary_directory();
|
|||||||
#define CHILD_PROCESS_TAG "(Child Process) "
|
#define CHILD_PROCESS_TAG "(Child Process) "
|
||||||
|
|
||||||
// Run Command And Get Output
|
// Run Command And Get Output
|
||||||
char *run_command(const char *const command[], int *exit_status);
|
char *run_command(const char *const command[], int *exit_status, size_t *output_size);
|
||||||
#define is_exit_status_success(status) (WIFEXITED(status) && WEXITSTATUS(status) == 0)
|
#define is_exit_status_success(status) (WIFEXITED(status) && WEXITSTATUS(status) == 0)
|
||||||
|
|
||||||
// Get Exit Status String
|
// Get Exit Status String
|
||||||
|
@ -68,7 +68,7 @@ char *get_binary_directory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run Command And Get Output
|
// Run Command And Get Output
|
||||||
char *run_command(const char *const command[], int *exit_status) {
|
char *run_command(const char *const command[], int *exit_status, size_t *output_size) {
|
||||||
// Store Output
|
// Store Output
|
||||||
int output_pipe[2];
|
int output_pipe[2];
|
||||||
safe_pipe2(output_pipe, 0);
|
safe_pipe2(output_pipe, 0);
|
||||||
@ -149,7 +149,12 @@ char *run_command(const char *const command[], int *exit_status) {
|
|||||||
output = new_output;
|
output = new_output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output[position] = '\0';
|
output[position++] = '\0';
|
||||||
|
|
||||||
|
// Return Output Size
|
||||||
|
if (output_size != NULL) {
|
||||||
|
*output_size = position;
|
||||||
|
}
|
||||||
|
|
||||||
// Get Return Code
|
// Get Return Code
|
||||||
int status;
|
int status;
|
||||||
|
@ -29,11 +29,11 @@ endif()
|
|||||||
add_subdirectory(extras)
|
add_subdirectory(extras)
|
||||||
|
|
||||||
# Add Core
|
# Add Core
|
||||||
if((BUILD_NATIVE_COMPONENTS AND MCPI_USE_MEDIA_LAYER_PROXY) OR (BUILD_ARM_COMPONENTS AND NOT MCPI_USE_MEDIA_LAYER_PROXY))
|
if(BUILD_MEDIA_LAYER_CORE)
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add Proxy
|
# Add Proxy
|
||||||
if(MCPI_USE_MEDIA_LAYER_PROXY)
|
if(MCPI_USE_MEDIA_LAYER_PROXY OR BUILD_ARM_COMPONENTS)
|
||||||
add_subdirectory(proxy)
|
add_subdirectory(proxy)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
project(media-layer-core)
|
project(media-layer-core)
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
add_subdirectory(dependencies)
|
|
||||||
|
|
||||||
# OpenGL
|
# OpenGL
|
||||||
add_subdirectory(gles)
|
add_subdirectory(gles)
|
||||||
|
|
||||||
@ -15,18 +12,19 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
add_library(media-layer-core SHARED ${CORE_SRC}) # Dependencies Are Setup Later
|
add_library(media-layer-core-real SHARED ${CORE_SRC}) # Dependencies Are Setup Later
|
||||||
# Install
|
set_target_properties(media-layer-core-real PROPERTIES OUTPUT_NAME "media-layer-core")
|
||||||
install(TARGETS media-layer-core DESTINATION "${MCPI_LIB_DIR}")
|
if(BUILD_NATIVE_COMPONENTS)
|
||||||
if(BUILD_ARM_COMPONENTS)
|
add_library(media-layer-core ALIAS media-layer-core-real)
|
||||||
install(TARGETS media-layer-core EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
|
||||||
endif()
|
endif()
|
||||||
|
# Install
|
||||||
|
install(TARGETS media-layer-core-real DESTINATION "${MCPI_LIB_DIR}")
|
||||||
|
|
||||||
# Link
|
# Link
|
||||||
target_link_libraries(media-layer-core PUBLIC media-layer-headers PUBLIC reborn-util PUBLIC GLESv1_CM PUBLIC dl)
|
target_link_libraries(media-layer-core-real PUBLIC media-layer-headers PUBLIC reborn-util PUBLIC GLESv1_CM PUBLIC dl)
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
# OpenAL
|
# OpenAL
|
||||||
find_library(OPENAL_LIBRARY NAMES openal REQUIRED)
|
find_library(OPENAL_LIBRARY NAMES openal REQUIRED)
|
||||||
# Link
|
# Link
|
||||||
target_link_libraries(media-layer-core PRIVATE "${OPENAL_LIBRARY}" PRIVATE m PRIVATE glfw PRIVATE LIB_LIEF)
|
target_link_libraries(media-layer-core-real PRIVATE "${OPENAL_LIBRARY}" PRIVATE m PRIVATE glfw PRIVATE LIB_LIEF)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
project(media-layer-core-dependencies)
|
|
||||||
|
|
||||||
# GLFW
|
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
|
||||||
add_subdirectory(glfw)
|
|
||||||
endif()
|
|
@ -1,8 +1,5 @@
|
|||||||
project(media-layer-gles)
|
project(media-layer-gles)
|
||||||
|
|
||||||
# Dependencies
|
|
||||||
add_subdirectory(dependencies)
|
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
if(MCPI_HEADLESS_MODE)
|
if(MCPI_HEADLESS_MODE)
|
||||||
# Stubs For Headless Mode
|
# Stubs For Headless Mode
|
||||||
@ -17,11 +14,3 @@ else()
|
|||||||
add_library(GLESv1_CM OBJECT src/passthrough.c)
|
add_library(GLESv1_CM OBJECT src/passthrough.c)
|
||||||
target_link_libraries(GLESv1_CM PRIVATE glfw media-layer-headers)
|
target_link_libraries(GLESv1_CM PRIVATE glfw media-layer-headers)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# SDK
|
|
||||||
if(BUILD_ARM_COMPONENTS)
|
|
||||||
install(TARGETS GLESv1_CM EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
|
||||||
if(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
|
|
||||||
install(TARGETS gles-compatibility-layer EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
project(media-layer-core-gles-dependencies)
|
|
||||||
|
|
||||||
# GLES Compatibility Layer
|
|
||||||
if(NOT MCPI_HEADLESS_MODE AND MCPI_USE_GLES1_COMPATIBILITY_LAYER)
|
|
||||||
add_subdirectory(gles-compatibility-layer)
|
|
||||||
endif()
|
|
@ -1 +1 @@
|
|||||||
../core/gles/dependencies/gles-compatibility-layer/src/include/GLES
|
../../dependencies/gles-compatibility-layer/src/include/GLES
|
@ -17,6 +17,8 @@ elseif(BUILD_ARM_COMPONENTS)
|
|||||||
target_link_libraries(media-layer-core media-layer-headers reborn-util)
|
target_link_libraries(media-layer-core media-layer-headers reborn-util)
|
||||||
target_compile_definitions(media-layer-core PRIVATE -DMEDIA_LAYER_PROXY_SERVER)
|
target_compile_definitions(media-layer-core PRIVATE -DMEDIA_LAYER_PROXY_SERVER)
|
||||||
# Install
|
# Install
|
||||||
install(TARGETS media-layer-core DESTINATION "${MCPI_LIB_DIR}")
|
if(MCPI_USE_MEDIA_LAYER_PROXY)
|
||||||
|
install(TARGETS media-layer-core DESTINATION "${MCPI_LIB_DIR}")
|
||||||
|
endif()
|
||||||
install(TARGETS media-layer-core EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
install(TARGETS media-layer-core EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -71,9 +71,6 @@ else()
|
|||||||
add_library(touch SHARED src/touch/touch.cpp)
|
add_library(touch SHARED src/touch/touch.cpp)
|
||||||
target_link_libraries(touch mods-headers reborn-patch symbols feature)
|
target_link_libraries(touch mods-headers reborn-patch symbols feature)
|
||||||
|
|
||||||
add_library(textures SHARED src/textures/textures.cpp)
|
|
||||||
target_link_libraries(textures mods-headers reborn-patch symbols media-layer-core feature misc)
|
|
||||||
|
|
||||||
add_library(atlas SHARED src/atlas/atlas.cpp)
|
add_library(atlas SHARED src/atlas/atlas.cpp)
|
||||||
target_link_libraries(atlas mods-headers reborn-patch symbols feature media-layer-core)
|
target_link_libraries(atlas mods-headers reborn-patch symbols feature media-layer-core)
|
||||||
|
|
||||||
@ -81,12 +78,22 @@ else()
|
|||||||
target_link_libraries(title-screen mods-headers reborn-patch symbols feature compat)
|
target_link_libraries(title-screen mods-headers reborn-patch symbols feature compat)
|
||||||
|
|
||||||
add_library(skin SHARED src/skin/skin.cpp src/skin/loader.cpp)
|
add_library(skin SHARED src/skin/skin.cpp src/skin/loader.cpp)
|
||||||
target_link_libraries(skin mods-headers reborn-patch symbols feature misc textures media-layer-core png12)
|
target_link_libraries(skin mods-headers reborn-patch symbols feature misc textures media-layer-core)
|
||||||
|
|
||||||
add_library(benchmark SHARED src/benchmark/benchmark.cpp)
|
add_library(benchmark SHARED src/benchmark/benchmark.cpp)
|
||||||
target_link_libraries(benchmark mods-headers reborn-patch symbols compat misc media-layer-core)
|
target_link_libraries(benchmark mods-headers reborn-patch symbols compat misc media-layer-core)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
|
add_library(textures SHARED src/textures/textures.cpp)
|
||||||
|
else()
|
||||||
|
add_library(textures SHARED src/textures/headless.cpp)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(textures mods-headers reborn-patch symbols)
|
||||||
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
|
target_link_libraries(textures media-layer-core feature misc stb_image)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(override SHARED src/override/override.c)
|
add_library(override SHARED src/override/override.c)
|
||||||
target_link_libraries(override mods-headers reborn-patch symbols dl home)
|
target_link_libraries(override mods-headers reborn-patch symbols dl home)
|
||||||
|
|
||||||
@ -104,7 +111,7 @@ target_link_libraries(bucket mods-headers reborn-patch symbols feature misc)
|
|||||||
|
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
add_library(screenshot SHARED src/screenshot/screenshot.c)
|
add_library(screenshot SHARED src/screenshot/screenshot.c)
|
||||||
target_link_libraries(screenshot mods-headers reborn-util media-layer-core png12)
|
target_link_libraries(screenshot mods-headers reborn-util media-layer-core stb_image)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(home SHARED src/home/home.c)
|
add_library(home SHARED src/home/home.c)
|
||||||
@ -114,19 +121,19 @@ add_library(test SHARED src/test/test.c)
|
|||||||
target_link_libraries(test mods-headers reborn-patch home)
|
target_link_libraries(test mods-headers reborn-patch home)
|
||||||
|
|
||||||
add_library(init SHARED src/init/init.c)
|
add_library(init SHARED src/init/init.c)
|
||||||
target_link_libraries(init mods-headers reborn-util compat game-mode misc death options chat creative bucket home version test media-layer-core)
|
target_link_libraries(init mods-headers reborn-util compat game-mode misc death options chat creative bucket textures home version test media-layer-core)
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
target_link_libraries(init server)
|
target_link_libraries(init server)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(init multiplayer sound camera input sign touch textures atlas title-screen skin benchmark)
|
target_link_libraries(init multiplayer sound camera input sign touch atlas title-screen skin benchmark)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
## Install Mods
|
## Install Mods
|
||||||
set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative bucket home version test)
|
set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative bucket textures home version test)
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
list(APPEND MODS_TO_INSTALL server)
|
list(APPEND MODS_TO_INSTALL server)
|
||||||
else()
|
else()
|
||||||
list(APPEND MODS_TO_INSTALL multiplayer sound camera input sign touch textures atlas title-screen skin benchmark)
|
list(APPEND MODS_TO_INSTALL multiplayer sound camera input sign touch atlas title-screen skin benchmark)
|
||||||
endif()
|
endif()
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
list(APPEND MODS_TO_INSTALL screenshot)
|
list(APPEND MODS_TO_INSTALL screenshot)
|
||||||
|
@ -18,11 +18,11 @@ void init_input();
|
|||||||
void init_sign();
|
void init_sign();
|
||||||
void init_camera();
|
void init_camera();
|
||||||
void init_touch();
|
void init_touch();
|
||||||
void init_textures();
|
|
||||||
void init_atlas();
|
void init_atlas();
|
||||||
void init_title_screen();
|
void init_title_screen();
|
||||||
void init_skin();
|
void init_skin();
|
||||||
#endif
|
#endif
|
||||||
|
void init_textures();
|
||||||
void init_creative();
|
void init_creative();
|
||||||
void init_game_mode();
|
void init_game_mode();
|
||||||
void init_misc();
|
void init_misc();
|
||||||
|
@ -34,7 +34,7 @@ static void *chat_thread(__attribute__((unused)) void *nop) {
|
|||||||
"--text", "Enter Chat Message:",
|
"--text", "Enter Chat Message:",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
char *output = run_command(command, &return_code);
|
char *output = run_command(command, &return_code, NULL);
|
||||||
// Handle Message
|
// Handle Message
|
||||||
if (output != NULL) {
|
if (output != NULL) {
|
||||||
// Check Return Code
|
// Check Return Code
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
static char *run_command_proper(const char *command[], bool allow_empty) {
|
static char *run_command_proper(const char *command[], bool allow_empty) {
|
||||||
// Run
|
// Run
|
||||||
int return_code;
|
int return_code;
|
||||||
char *output = run_command(command, &return_code);
|
char *output = run_command(command, &return_code, NULL);
|
||||||
|
|
||||||
// Handle Message
|
// Handle Message
|
||||||
if (output != NULL) {
|
if (output != NULL) {
|
||||||
|
@ -18,11 +18,11 @@ __attribute__((constructor)) static void init() {
|
|||||||
init_sign();
|
init_sign();
|
||||||
init_camera();
|
init_camera();
|
||||||
init_touch();
|
init_touch();
|
||||||
init_textures();
|
|
||||||
init_atlas();
|
init_atlas();
|
||||||
init_title_screen();
|
init_title_screen();
|
||||||
init_skin();
|
init_skin();
|
||||||
#endif
|
#endif
|
||||||
|
init_textures();
|
||||||
init_creative();
|
init_creative();
|
||||||
init_game_mode();
|
init_game_mode();
|
||||||
init_misc();
|
init_misc();
|
||||||
|
@ -13,12 +13,21 @@
|
|||||||
|
|
||||||
// Read Asset File
|
// Read Asset File
|
||||||
static AppPlatform_readAssetFile_return_value AppPlatform_readAssetFile_injection(__attribute__((unused)) unsigned char *app_platform, std::string const& path) {
|
static AppPlatform_readAssetFile_return_value AppPlatform_readAssetFile_injection(__attribute__((unused)) unsigned char *app_platform, std::string const& path) {
|
||||||
// Read File
|
// Open File
|
||||||
std::ifstream stream("data/" + path, std::ios_base::binary | std::ios_base::ate);
|
std::ifstream stream("data/" + path, std::ios_base::binary | std::ios_base::ate);
|
||||||
|
if (!stream) {
|
||||||
|
// Does Not Exist
|
||||||
|
AppPlatform_readAssetFile_return_value ret;
|
||||||
|
ret.length = -1;
|
||||||
|
ret.data = NULL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
// Read File
|
||||||
long len = stream.tellg();
|
long len = stream.tellg();
|
||||||
char *buf = new char[len];
|
char *buf = new char[len];
|
||||||
stream.seekg(0, stream.beg);
|
stream.seekg(0, stream.beg);
|
||||||
stream.read(buf, len);
|
stream.read(buf, len);
|
||||||
|
stream.close();
|
||||||
// Return String
|
// Return String
|
||||||
AppPlatform_readAssetFile_return_value ret;
|
AppPlatform_readAssetFile_return_value ret;
|
||||||
ret.length = len;
|
ret.length = len;
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <png.h>
|
#include "stb_image.h"
|
||||||
|
#include "stb_image_write.h"
|
||||||
|
|
||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
@ -31,68 +32,11 @@ static void ensure_screenshots_folder(char *screenshots) {
|
|||||||
|
|
||||||
// Take Screenshot
|
// Take Screenshot
|
||||||
static int save_png(const char *filename, unsigned char *pixels, int line_size, int width, int height) {
|
static int save_png(const char *filename, unsigned char *pixels, int line_size, int width, int height) {
|
||||||
// Return value
|
// Setup
|
||||||
int ret = 0;
|
stbi_flip_vertically_on_write(1);
|
||||||
|
|
||||||
// Variables
|
// Write Image
|
||||||
png_structp png = NULL;
|
return !stbi_write_png(filename, width, height, 4, pixels, line_size);
|
||||||
png_infop info = NULL;
|
|
||||||
FILE *file = NULL;
|
|
||||||
png_colorp palette = NULL;
|
|
||||||
png_bytep rows[height];
|
|
||||||
for (int i = 0; i < height; ++i) {
|
|
||||||
rows[height - i - 1] = (png_bytep) (&pixels[i * line_size]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init
|
|
||||||
png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
|
||||||
if (!png) {
|
|
||||||
ret = 1;
|
|
||||||
goto ret;
|
|
||||||
}
|
|
||||||
info = png_create_info_struct(png);
|
|
||||||
if (!info) {
|
|
||||||
ret = 1;
|
|
||||||
goto ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open File
|
|
||||||
file = fopen(filename, "wb");
|
|
||||||
if (!file) {
|
|
||||||
ret = 1;
|
|
||||||
goto ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare To Write
|
|
||||||
png_init_io(png, file);
|
|
||||||
png_set_IHDR(png, info, width, height, 8 /* Depth */, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
|
||||||
palette = (png_colorp) png_malloc(png, PNG_MAX_PALETTE_LENGTH * sizeof(png_color));
|
|
||||||
if (!palette) {
|
|
||||||
ret = 1;
|
|
||||||
goto ret;
|
|
||||||
}
|
|
||||||
png_set_PLTE(png, info, palette, PNG_MAX_PALETTE_LENGTH);
|
|
||||||
png_write_info(png, info);
|
|
||||||
png_set_packing(png);
|
|
||||||
|
|
||||||
// Write
|
|
||||||
png_write_image(png, rows);
|
|
||||||
png_write_end(png, info);
|
|
||||||
|
|
||||||
ret:
|
|
||||||
// Free
|
|
||||||
if (palette != NULL) {
|
|
||||||
png_free(png, palette);
|
|
||||||
}
|
|
||||||
if (file != NULL) {
|
|
||||||
fclose(file);
|
|
||||||
}
|
|
||||||
if (png != NULL) {
|
|
||||||
png_destroy_write_struct(&png, &info);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
void screenshot_take(char *home) {
|
void screenshot_take(char *home) {
|
||||||
// Get Directory
|
// Get Directory
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
#include <symbols/minecraft.h>
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
#include <png.h>
|
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
|
|
||||||
#include <mods/misc/misc.h>
|
#include <mods/misc/misc.h>
|
||||||
#include <mods/textures/textures.h>
|
#include <mods/textures/textures.h>
|
||||||
#include "skin-internal.h"
|
#include "skin-internal.h"
|
||||||
|
|
||||||
|
#include "stb_image.h"
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
#define SKIN_WIDTH 64
|
#define SKIN_WIDTH 64
|
||||||
#define SKIN_HEIGHT 32
|
#define SKIN_HEIGHT 32
|
||||||
@ -19,68 +20,35 @@
|
|||||||
struct pending_skin {
|
struct pending_skin {
|
||||||
int32_t texture_id;
|
int32_t texture_id;
|
||||||
char *data;
|
char *data;
|
||||||
|
int size;
|
||||||
};
|
};
|
||||||
static std::vector<pending_skin> &get_pending_skins() {
|
static std::vector<pending_skin> &get_pending_skins() {
|
||||||
static std::vector<pending_skin> pending_skins;
|
static std::vector<pending_skin> pending_skins;
|
||||||
return pending_skins;
|
return pending_skins;
|
||||||
}
|
}
|
||||||
static pthread_mutex_t pending_skins_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t pending_skins_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static void read_from_png(png_structp pngPtr, png_bytep data, png_size_t length) {
|
|
||||||
char **src = (char **) png_get_io_ptr(pngPtr);
|
|
||||||
memcpy(data, *src, length);
|
|
||||||
*src += length;
|
|
||||||
}
|
|
||||||
static void load_pending_skins(__attribute__((unused)) unsigned char *minecraft) {
|
static void load_pending_skins(__attribute__((unused)) unsigned char *minecraft) {
|
||||||
// Lock
|
// Lock
|
||||||
pthread_mutex_lock(&pending_skins_lock);
|
pthread_mutex_lock(&pending_skins_lock);
|
||||||
|
|
||||||
// Loop
|
// Loop
|
||||||
for (pending_skin &skin : get_pending_skins()) {
|
for (pending_skin &skin : get_pending_skins()) {
|
||||||
// Init LibPNG
|
|
||||||
png_structp pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
|
||||||
if (!pngPtr) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
png_infop infoPtr = png_create_info_struct(pngPtr);
|
|
||||||
if (!infoPtr) {
|
|
||||||
png_destroy_read_struct(&pngPtr, NULL, NULL);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read PNG Info
|
// Read PNG Info
|
||||||
char *cursor = skin.data;
|
int width = 0, height = 0, channels = 0;
|
||||||
png_set_read_fn(pngPtr, (png_voidp) &cursor, read_from_png);
|
stbi_uc *img = stbi_load_from_memory((unsigned char *) skin.data, skin.size, &width, &height, &channels, STBI_rgb_alpha);
|
||||||
png_read_info(pngPtr, infoPtr);
|
|
||||||
int width = png_get_image_width(pngPtr, infoPtr);
|
|
||||||
int height = png_get_image_height(pngPtr, infoPtr);
|
|
||||||
if (png_get_color_type(pngPtr, infoPtr) != PNG_COLOR_TYPE_RGBA) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (width != SKIN_WIDTH || height != SKIN_HEIGHT) {
|
if (width != SKIN_WIDTH || height != SKIN_HEIGHT) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int pixelSize = 4;
|
|
||||||
|
|
||||||
// Read Image
|
|
||||||
png_bytep *rowPtrs = new png_bytep[height];
|
|
||||||
unsigned char *data = new unsigned char[pixelSize * width * height];
|
|
||||||
int rowStrideBytes = pixelSize * width;
|
|
||||||
for (int i = 0; i < height; i++) {
|
|
||||||
rowPtrs[i] = (png_bytep) &data[i * rowStrideBytes];
|
|
||||||
}
|
|
||||||
png_read_image(pngPtr, rowPtrs);
|
|
||||||
|
|
||||||
// Load Texture
|
// Load Texture
|
||||||
GLint last_texture;
|
GLint last_texture;
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, skin.texture_id);
|
glBindTexture(GL_TEXTURE_2D, skin.texture_id);
|
||||||
glTexSubImage2D_with_scaling(GL_TEXTURE_2D, 0, 0, 0, width, height, SKIN_WIDTH, SKIN_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
glTexSubImage2D_with_scaling(GL_TEXTURE_2D, 0, 0, 0, width, height, SKIN_WIDTH, SKIN_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, img);
|
||||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||||
|
|
||||||
// Free
|
// Free
|
||||||
delete[] data;
|
stbi_image_free(img);
|
||||||
png_destroy_read_struct(&pngPtr, &infoPtr, (png_infopp) 0);
|
|
||||||
delete[] rowPtrs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free
|
// Free
|
||||||
@ -118,7 +86,8 @@ static void *loader_thread(void *user_data) {
|
|||||||
std::string url = get_skin_server() + '/' + data->name + ".png";
|
std::string url = get_skin_server() + '/' + data->name + ".png";
|
||||||
int return_code;
|
int return_code;
|
||||||
const char *command[] = {"wget", "-O", "-", url.c_str(), NULL};
|
const char *command[] = {"wget", "-O", "-", url.c_str(), NULL};
|
||||||
char *output = run_command(command, &return_code);
|
size_t output_size = 0;
|
||||||
|
char *output = run_command(command, &return_code, &output_size);
|
||||||
|
|
||||||
// Check Success
|
// Check Success
|
||||||
if (output != NULL && is_exit_status_success(return_code)) {
|
if (output != NULL && is_exit_status_success(return_code)) {
|
||||||
@ -129,6 +98,7 @@ static void *loader_thread(void *user_data) {
|
|||||||
pending_skin skin;
|
pending_skin skin;
|
||||||
skin.texture_id = data->texture_id;
|
skin.texture_id = data->texture_id;
|
||||||
skin.data = output;
|
skin.data = output;
|
||||||
|
skin.size = (int) output_size;
|
||||||
pthread_mutex_lock(&pending_skins_lock);
|
pthread_mutex_lock(&pending_skins_lock);
|
||||||
get_pending_skins().push_back(skin);
|
get_pending_skins().push_back(skin);
|
||||||
pthread_mutex_unlock(&pending_skins_lock);
|
pthread_mutex_unlock(&pending_skins_lock);
|
||||||
|
14
mods/src/textures/headless.cpp
Normal file
14
mods/src/textures/headless.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include <libreborn/libreborn.h>
|
||||||
|
#include <symbols/minecraft.h>
|
||||||
|
#include <mods/init/init.h>
|
||||||
|
|
||||||
|
// Disable Texture Loading
|
||||||
|
static Texture AppPlatform_linux_loadTexture_injection(__attribute__((unused)) unsigned char *app_platform, __attribute__((unused)) std::string const& path, __attribute__((unused)) bool b) {
|
||||||
|
return Texture();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init
|
||||||
|
void init_textures() {
|
||||||
|
// Disable Texture Loading
|
||||||
|
overwrite((void *) AppPlatform_linux_loadTexture, (void *) AppPlatform_linux_loadTexture_injection);
|
||||||
|
}
|
@ -12,6 +12,8 @@
|
|||||||
#include <mods/textures/textures.h>
|
#include <mods/textures/textures.h>
|
||||||
#include <mods/init/init.h>
|
#include <mods/init/init.h>
|
||||||
|
|
||||||
|
#include "stb_image.h"
|
||||||
|
|
||||||
// Animated Water
|
// Animated Water
|
||||||
static void Minecraft_tick_injection(unsigned char *minecraft) {
|
static void Minecraft_tick_injection(unsigned char *minecraft) {
|
||||||
// Tick Dynamic Textures
|
// Tick Dynamic Textures
|
||||||
@ -166,6 +168,38 @@ static void Textures_tick_glTexSubImage2D_injection(GLenum target, GLint level,
|
|||||||
glTexSubImage2D_with_scaling(target, level, xoffset, yoffset, width, height, 256, 256, format, type, pixels);
|
glTexSubImage2D_with_scaling(target, level, xoffset, yoffset, width, height, 256, 256, format, type, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load Textures
|
||||||
|
static Texture AppPlatform_linux_loadTexture_injection(__attribute__((unused)) unsigned char *app_platform, std::string const& path, bool b) {
|
||||||
|
Texture out;
|
||||||
|
std::string real_path = path;
|
||||||
|
if (b) {
|
||||||
|
real_path = "data/images/" + real_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read Image
|
||||||
|
int width = 0, height = 0, channels = 0;
|
||||||
|
stbi_uc *img = stbi_load(real_path.c_str(), &width, &height, &channels, STBI_rgb_alpha);
|
||||||
|
if (!img)
|
||||||
|
{
|
||||||
|
// Failed To Parse Image
|
||||||
|
WARN("Unable To Load Texture: %s", real_path.c_str());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy Image
|
||||||
|
unsigned char *img2 = new unsigned char[width * height * channels];
|
||||||
|
memcpy(img2, img, width * height * channels);
|
||||||
|
stbi_image_free(img);
|
||||||
|
|
||||||
|
// Create Texture
|
||||||
|
out.width = width;
|
||||||
|
out.height = height;
|
||||||
|
out.data = img2;
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
void init_textures() {
|
void init_textures() {
|
||||||
// Tick Dynamic Textures (Animated Water)
|
// Tick Dynamic Textures (Animated Water)
|
||||||
@ -175,4 +209,7 @@ void init_textures() {
|
|||||||
|
|
||||||
// Scale Animated Textures
|
// Scale Animated Textures
|
||||||
overwrite_call((void *) 0x53274, (void *) Textures_tick_glTexSubImage2D_injection);
|
overwrite_call((void *) 0x53274, (void *) Textures_tick_glTexSubImage2D_injection);
|
||||||
|
|
||||||
|
// Load Textures
|
||||||
|
overwrite((void *) AppPlatform_linux_loadTexture, (void *) AppPlatform_linux_loadTexture_injection);
|
||||||
}
|
}
|
||||||
|
@ -947,6 +947,22 @@ struct ConnectedClient {
|
|||||||
long time;
|
long time;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Texture {
|
||||||
|
int32_t width = 0;
|
||||||
|
int32_t height = 0;
|
||||||
|
unsigned char *data = NULL;
|
||||||
|
int32_t field3_0xc = 0;
|
||||||
|
bool field4_0x10 = true;
|
||||||
|
bool field5_0x11 = false;
|
||||||
|
int32_t field6_0x14 = 0;
|
||||||
|
int32_t field7_0x18 = -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
// AppPlatform_linux
|
||||||
|
|
||||||
|
typedef Texture (*AppPlatform_linux_loadTexture_t)(unsigned char *app_platform, std::string const& path, bool b);
|
||||||
|
static AppPlatform_linux_loadTexture_t AppPlatform_linux_loadTexture = (AppPlatform_linux_loadTexture_t) 0x12c20;
|
||||||
|
|
||||||
// Tile
|
// Tile
|
||||||
|
|
||||||
typedef unsigned char *(*Tile_setDescriptionId_t)(unsigned char *tile, std::string const& description_id);
|
typedef unsigned char *(*Tile_setDescriptionId_t)(unsigned char *tile, std::string const& description_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user