Move Screenshot Code To ARM
This commit is contained in:
parent
67002006f3
commit
69d3832815
@ -62,6 +62,7 @@ endif()
|
||||
# Specify Installation Paths
|
||||
set(MCPI_INSTALL_DIR "lib/${MCPI_VARIANT_NAME}")
|
||||
set(MCPI_BIN_DIR "${MCPI_INSTALL_DIR}/bin")
|
||||
set(MCPI_LEGAL_DIR "${MCPI_INSTALL_DIR}/legal") # For Software Licenses
|
||||
set(MCPI_SDK_DIR "${MCPI_INSTALL_DIR}/sdk")
|
||||
set(MCPI_SDK_LIB_DIR "${MCPI_SDK_DIR}/lib")
|
||||
set(MCPI_SDK_INCLUDE_DIR "${MCPI_SDK_DIR}/include")
|
||||
|
4
dependencies/CMakeLists.txt
vendored
4
dependencies/CMakeLists.txt
vendored
@ -1,7 +1,9 @@
|
||||
project(dependencies)
|
||||
|
||||
# LibPNG
|
||||
add_subdirectory(libpng)
|
||||
if(BUILD_ARM_COMPONENTS)
|
||||
add_subdirectory(libpng)
|
||||
endif()
|
||||
# Minecraft: Pi Edition
|
||||
if(BUILD_ARM_COMPONENTS AND NOT MCPI_OPEN_SOURCE_ONLY)
|
||||
add_subdirectory(minecraft-pi)
|
||||
|
8
dependencies/libpng/CMakeLists.txt
vendored
8
dependencies/libpng/CMakeLists.txt
vendored
@ -16,7 +16,7 @@ set(PNG_SHARED TRUE CACHE BOOL "" FORCE)
|
||||
|
||||
# Download
|
||||
set(ZLIB_LIBRARY zlibstatic)
|
||||
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
|
||||
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src")
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0054 OLD) # Silence Warning
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0003 NEW) # Silence Warning
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0022 NEW) # Fix Error
|
||||
@ -28,6 +28,9 @@ set(CMAKE_POLICY_DEFAULT_CMP0054 NEW) # Re-Enable New Behavior
|
||||
set_target_properties(png12 PROPERTIES LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libpng.vers") # Use Symbol Versioning
|
||||
set_target_properties(png12 PROPERTIES DEBUG_POSTFIX "") # Fix LibPNG Suffix In Debug Mode
|
||||
target_include_directories(png12 PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
|
||||
foreach(zlib_include_dir IN ITEMS "${ZLIB_INCLUDE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
|
||||
target_include_directories(png12 PUBLIC "$<BUILD_INTERFACE:${zlib_include_dir}>")
|
||||
endforeach()
|
||||
|
||||
# Ensure Build
|
||||
add_custom_target(png12-build ALL DEPENDS png12)
|
||||
@ -36,3 +39,6 @@ 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")
|
||||
|
3
dependencies/libpng/zlib/CMakeLists.txt
vendored
3
dependencies/libpng/zlib/CMakeLists.txt
vendored
@ -11,3 +11,6 @@ add_subdirectory(src EXCLUDE_FROM_ALL)
|
||||
|
||||
# Ensure Build
|
||||
add_custom_target(zlib-build ALL DEPENDS zlibstatic)
|
||||
|
||||
# License
|
||||
install(FILES src/README DESTINATION "${MCPI_LEGAL_DIR}/zlib")
|
||||
|
3
dependencies/zenity/CMakeLists.txt
vendored
3
dependencies/zenity/CMakeLists.txt
vendored
@ -13,3 +13,6 @@ add_custom_target(zenity-build ALL DEPENDS zenity)
|
||||
|
||||
# Install
|
||||
install(TARGETS zenity DESTINATION "${MCPI_BIN_DIR}")
|
||||
|
||||
# License
|
||||
install(FILES src/COPYING DESTINATION "${MCPI_LEGAL_DIR}/zenity")
|
||||
|
@ -12,3 +12,6 @@ set_target_properties(patchelf PROPERTIES CXX_STANDARD 17)
|
||||
|
||||
# Install
|
||||
install(TARGETS patchelf DESTINATION "${MCPI_BIN_DIR}")
|
||||
|
||||
# License
|
||||
install(FILES src/COPYING DESTINATION "${MCPI_LEGAL_DIR}/patchelf")
|
||||
|
@ -7,7 +7,7 @@ add_subdirectory(dependencies)
|
||||
add_subdirectory(gles)
|
||||
|
||||
# Configuration
|
||||
set(CORE_SRC src/base.cpp src/media.c src/screenshot.c $<TARGET_OBJECTS:media-layer-extras>) # SDL Re-Implementation Using GLFW
|
||||
set(CORE_SRC src/base.cpp src/media.c $<TARGET_OBJECTS:media-layer-extras>) # SDL Re-Implementation Using GLFW
|
||||
if(NOT MCPI_HEADLESS_MODE)
|
||||
list(APPEND CORE_SRC src/audio/api.cpp src/audio/engine.c src/audio/file.cpp)
|
||||
else()
|
||||
@ -28,5 +28,5 @@ if(NOT MCPI_HEADLESS_MODE)
|
||||
# OpenAL
|
||||
find_library(OPENAL_LIBRARY NAMES openal REQUIRED)
|
||||
# Link
|
||||
target_link_libraries(media-layer-core PRIVATE png12 PRIVATE "${OPENAL_LIBRARY}" PRIVATE m PRIVATE glfw)
|
||||
target_link_libraries(media-layer-core PRIVATE "${OPENAL_LIBRARY}" PRIVATE m PRIVATE glfw)
|
||||
endif()
|
||||
|
@ -26,3 +26,6 @@ install(TARGETS glfw DESTINATION "${MCPI_LIB_DIR}")
|
||||
if(BUILD_ARM_COMPONENTS)
|
||||
install(TARGETS glfw EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
||||
endif()
|
||||
|
||||
# License
|
||||
install(FILES src/LICENSE.md DESTINATION "${MCPI_LEGAL_DIR}/glfw")
|
||||
|
@ -10,7 +10,6 @@ extern "C" {
|
||||
|
||||
void media_ensure_loaded();
|
||||
|
||||
void media_take_screenshot(char *home);
|
||||
void media_toggle_fullscreen();
|
||||
void media_swap_buffers();
|
||||
void media_cleanup();
|
||||
|
@ -1160,9 +1160,13 @@ CALL(58, glIsEnabled, GLboolean, (GLenum cap)) {
|
||||
static int get_glGetIntegerv_params_size(GLenum pname) {
|
||||
switch (pname) {
|
||||
case GL_TEXTURE_BINDING_2D:
|
||||
case GL_PACK_ALIGNMENT:
|
||||
case GL_UNPACK_ALIGNMENT: {
|
||||
return 1;
|
||||
}
|
||||
case GL_VIEWPORT: {
|
||||
return 4;
|
||||
}
|
||||
default: {
|
||||
PROXY_ERR("Unsupported glGetIntegerv Property: %u", pname);
|
||||
}
|
||||
@ -1198,3 +1202,43 @@ CALL(61, glGetIntegerv, void, (GLenum pname, GLint *params)) {
|
||||
safe_write((void *) params, sizeof (GLint) * size);
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL(65, glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *data)) {
|
||||
#if defined(MEDIA_LAYER_PROXY_SERVER)
|
||||
// Get Texture Size
|
||||
int size = get_texture_size(width, height, format, type);
|
||||
|
||||
// Lock Proxy
|
||||
start_proxy_call();
|
||||
|
||||
// Arguments
|
||||
write_int((uint32_t) x);
|
||||
write_int((uint32_t) y);
|
||||
write_int((uint32_t) width);
|
||||
write_int((uint32_t) height);
|
||||
write_int((uint32_t) format);
|
||||
write_int((uint32_t) type);
|
||||
|
||||
// Get Return Value
|
||||
safe_read((void *) data, size);
|
||||
|
||||
// Release Proxy
|
||||
end_proxy_call();
|
||||
#else
|
||||
GLint x = (GLint) read_int();
|
||||
GLint y = (GLint) read_int();
|
||||
GLsizei width = (GLsizei) read_int();
|
||||
GLsizei height = (GLsizei) read_int();
|
||||
GLenum format = (GLenum) read_int();
|
||||
GLenum type = (GLenum) read_int();
|
||||
int size = get_texture_size(width, height, format, type);
|
||||
void *pixels = malloc(size);
|
||||
ALLOC_CHECK(pixels);
|
||||
// Run
|
||||
glReadPixels(x, y, width, height, format, type, pixels);
|
||||
// Return Value
|
||||
safe_write((void *) pixels, (size_t) size);
|
||||
// Free
|
||||
free(pixels);
|
||||
#endif
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ void safe_read(void *buf, size_t len) {
|
||||
// Read Remaining Data
|
||||
size_t to_read_to_cache = 0;
|
||||
while (to_read_to_cache < 1) {
|
||||
CHECK_CONNECTION();
|
||||
int bytes_available;
|
||||
if (ioctl(get_connection_read(), FIONREAD, &bytes_available) == -1) {
|
||||
bytes_available = 0;
|
||||
|
@ -176,25 +176,6 @@ CALL(6, SDL_ShowCursor, int, (int32_t toggle)) {
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL(7, media_take_screenshot, void, (char *home)) {
|
||||
#if defined(MEDIA_LAYER_PROXY_SERVER)
|
||||
// Lock Proxy
|
||||
start_proxy_call();
|
||||
|
||||
// Arguments
|
||||
write_string(home);
|
||||
|
||||
// Release Proxy
|
||||
end_proxy_call();
|
||||
#else
|
||||
char *home = read_string();
|
||||
// Run
|
||||
media_take_screenshot(home);
|
||||
// Free
|
||||
free(home);
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL(8, media_swap_buffers, void, ()) {
|
||||
#if defined(MEDIA_LAYER_PROXY_SERVER)
|
||||
// Lock Proxy
|
||||
|
@ -16,6 +16,12 @@ install(DIRECTORY "include/" DESTINATION "${MCPI_SDK_INCLUDE_DIR}/mods")
|
||||
|
||||
add_library(compat SHARED src/compat/compat.c src/compat/egl.c src/compat/x11.c src/compat/bcm_host.c)
|
||||
target_link_libraries(compat mods-headers reborn-patch media-layer-core)
|
||||
if(NOT MCPI_HEADLESS_MODE)
|
||||
target_link_libraries(compat screenshot)
|
||||
endif()
|
||||
if(NOT MCPI_SERVER_MODE)
|
||||
target_link_libraries(compat input sign chat home dl)
|
||||
endif()
|
||||
|
||||
add_library(readdir SHARED src/readdir/readdir.c)
|
||||
|
||||
@ -27,23 +33,23 @@ target_link_libraries(version mods-headers reborn-patch symbols)
|
||||
|
||||
add_library(chat SHARED src/chat/chat.cpp src/chat/ui.c)
|
||||
target_link_libraries(chat mods-headers reborn-patch symbols feature)
|
||||
if(NOT MCPI_SERVER_MODE)
|
||||
target_link_libraries(chat input media-layer-core pthread)
|
||||
endif()
|
||||
|
||||
add_library(creative SHARED src/creative/creative.cpp)
|
||||
target_link_libraries(creative mods-headers reborn-patch symbols feature misc)
|
||||
|
||||
add_library(game-mode SHARED src/game-mode/game-mode.c src/game-mode/ui.cpp)
|
||||
target_link_libraries(game-mode mods-headers reborn-patch symbols feature)
|
||||
if(NOT MCPI_SERVER_MODE)
|
||||
target_link_libraries(game-mode pthread media-layer-core)
|
||||
endif()
|
||||
|
||||
if(MCPI_SERVER_MODE)
|
||||
add_library(server SHARED src/server/server.cpp src/server/server_properties.cpp)
|
||||
target_link_libraries(server mods-headers reborn-patch symbols feature home misc compat dl media-layer-core pthread)
|
||||
else()
|
||||
target_link_libraries(compat input sign chat home dl)
|
||||
|
||||
target_link_libraries(chat input media-layer-core pthread)
|
||||
|
||||
target_link_libraries(game-mode pthread media-layer-core)
|
||||
|
||||
add_library(multiplayer SHARED src/multiplayer/multiplayer.cpp)
|
||||
target_link_libraries(multiplayer mods-headers reborn-patch symbols home feature)
|
||||
|
||||
@ -51,7 +57,10 @@ else()
|
||||
target_link_libraries(sound mods-headers reborn-patch symbols feature override media-layer-core)
|
||||
|
||||
add_library(camera SHARED src/camera/camera.cpp)
|
||||
target_link_libraries(camera mods-headers reborn-patch symbols media-layer-core feature home)
|
||||
target_link_libraries(camera mods-headers reborn-patch symbols feature home)
|
||||
if(NOT MCPI_HEADLESS_MODE)
|
||||
target_link_libraries(camera screenshot)
|
||||
endif()
|
||||
|
||||
add_library(input SHARED src/input/input.cpp src/input/bow.c src/input/attack.c src/input/toggle.c src/input/misc.c src/input/drop.cpp)
|
||||
target_link_libraries(input mods-headers reborn-patch symbols creative feature misc media-layer-core)
|
||||
@ -87,6 +96,11 @@ target_link_libraries(options mods-headers reborn-patch symbols feature home)
|
||||
add_library(bucket SHARED src/bucket/bucket.cpp)
|
||||
target_link_libraries(bucket mods-headers reborn-patch symbols feature misc)
|
||||
|
||||
if(NOT MCPI_HEADLESS_MODE)
|
||||
add_library(screenshot SHARED src/screenshot/screenshot.c)
|
||||
target_link_libraries(screenshot mods-headers reborn-util media-layer-core png12)
|
||||
endif()
|
||||
|
||||
add_library(home SHARED src/home/home.c)
|
||||
target_link_libraries(home mods-headers reborn-patch symbols)
|
||||
|
||||
@ -108,6 +122,9 @@ if(MCPI_SERVER_MODE)
|
||||
else()
|
||||
list(APPEND MODS_TO_INSTALL multiplayer sound camera input sign touch textures atlas benchmark)
|
||||
endif()
|
||||
if(NOT MCPI_HEADLESS_MODE)
|
||||
list(APPEND MODS_TO_INSTALL screenshot)
|
||||
endif()
|
||||
install(TARGETS ${MODS_TO_INSTALL} DESTINATION "${MCPI_INSTALL_DIR}/mods")
|
||||
# SDK
|
||||
install(TARGETS ${MODS_TO_INSTALL} EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}")
|
||||
|
11
mods/include/mods/screenshot/screenshot.h
Normal file
11
mods/include/mods/screenshot/screenshot.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void screenshot_take(char *home);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,14 +1,16 @@
|
||||
#include <libreborn/libreborn.h>
|
||||
#include <media-layer/core.h>
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
#include <mods/feature/feature.h>
|
||||
#include <mods/screenshot/screenshot.h>
|
||||
#include <mods/home/home.h>
|
||||
#include <mods/init/init.h>
|
||||
|
||||
// Take Screenshot Using TripodCamera
|
||||
static void AppPlatform_linux_saveScreenshot_injection(__attribute__((unused)) unsigned char *app_platform, __attribute__((unused)) std::string const& path, __attribute__((unused)) int32_t width, __attribute__((unused)) int32_t height) {
|
||||
media_take_screenshot(home_get());
|
||||
#ifndef MCPI_HEADLESS_MODE
|
||||
screenshot_take(home_get());
|
||||
#endif
|
||||
}
|
||||
|
||||
// Enable TripodCameraRenderer
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <mods/compat/compat.h>
|
||||
#include <mods/screenshot/screenshot.h>
|
||||
#include <mods/init/init.h>
|
||||
|
||||
#include <libreborn/libreborn.h>
|
||||
@ -58,7 +59,9 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) {
|
||||
media_toggle_fullscreen();
|
||||
handled = 1;
|
||||
} else if (event->key.keysym.sym == SDLK_F2) {
|
||||
media_take_screenshot(home_get());
|
||||
#ifndef MCPI_HEADLESS_MODE
|
||||
screenshot_take(home_get());
|
||||
#endif
|
||||
handled = 1;
|
||||
} else if (event->key.keysym.sym == SDLK_F1) {
|
||||
input_hide_gui();
|
||||
@ -119,11 +122,7 @@ static void exit_handler(__attribute__((unused)) int data) {
|
||||
}
|
||||
void init_compat() {
|
||||
// Install Signal Handlers
|
||||
struct sigaction act_sigint;
|
||||
memset((void *) &act_sigint, 0, sizeof (struct sigaction));
|
||||
act_sigint.sa_flags = SA_RESTART;
|
||||
act_sigint.sa_handler = &exit_handler;
|
||||
sigaction(SIGINT, &act_sigint, NULL);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
struct sigaction act_sigterm;
|
||||
memset((void *) &act_sigterm, 0, sizeof (struct sigaction));
|
||||
act_sigterm.sa_flags = SA_RESTART;
|
||||
|
2
mods/src/screenshot/README.md
Normal file
2
mods/src/screenshot/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# ``screenshot`` Mod
|
||||
This mod implements the core screenshot logic.
|
@ -1,9 +1,3 @@
|
||||
// Config Needs To Load First
|
||||
#include <libreborn/libreborn.h>
|
||||
|
||||
// Screenshot Code Is Useless In Headless Mode
|
||||
#ifndef MCPI_HEADLESS_MODE
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@ -14,8 +8,9 @@
|
||||
|
||||
#include <png.h>
|
||||
|
||||
#include <libreborn/libreborn.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <media-layer/core.h>
|
||||
#include <mods/screenshot/screenshot.h>
|
||||
|
||||
// Ensure Screenshots Folder Exists
|
||||
static void ensure_screenshots_folder(char *screenshots) {
|
||||
@ -99,7 +94,7 @@ static int save_png(const char *filename, unsigned char *pixels, int line_size,
|
||||
// Return
|
||||
return ret;
|
||||
}
|
||||
void media_take_screenshot(char *home) {
|
||||
void screenshot_take(char *home) {
|
||||
// Get Directory
|
||||
char *screenshots = NULL;
|
||||
safe_asprintf(&screenshots, "%s/screenshots", home);
|
||||
@ -163,9 +158,3 @@ void media_take_screenshot(char *home) {
|
||||
free(file);
|
||||
free(screenshots);
|
||||
}
|
||||
|
||||
#else
|
||||
void media_take_screenshot() {
|
||||
// NOP
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user