From 484d3e7f90eb52bac5d6661a9885d496f72a1535 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 8 Jul 2022 00:25:01 -0400 Subject: [PATCH] More Miscellaneous Fixes + Fixed GLES v1.1 Support --- .gitignore | 28 ++++---- CMakeLists.txt | 50 +++++++-------- cmake/prebuilt-armhf-toolchain.cmake | 12 ++-- dependencies/CMakeLists.txt | 2 +- example-mods/chat-commands/.gitignore | 27 ++++---- example-mods/expanded-creative/.gitignore | 27 ++++---- example-mods/recipes/.gitignore | 27 ++++---- images/CMakeLists.txt | 2 +- launcher/src/bootstrap.c | 2 +- media-layer/core/CMakeLists.txt | 6 +- media-layer/core/dependencies/CMakeLists.txt | 6 ++ .../core/dependencies/glfw/CMakeLists.txt | 28 ++++++++ media-layer/core/src/audio/stubs.c | 6 ++ .../gles/src/compatibility-layer/buffer.cpp | 1 + media-layer/gles/src/stubs.c | 8 +++ media-layer/include/media-layer/audio.h | 7 -- media-layer/proxy/src/GLESv1_CM.c | 64 +++++++++++-------- mods/CMakeLists.txt | 10 +-- mods/src/compat/compat.c | 18 +++--- mods/src/misc/misc.c | 2 +- mods/src/touch/touch.cpp | 2 +- 21 files changed, 197 insertions(+), 138 deletions(-) create mode 100644 media-layer/core/dependencies/CMakeLists.txt create mode 100644 media-layer/core/dependencies/glfw/CMakeLists.txt create mode 100644 media-layer/core/src/audio/stubs.c diff --git a/.gitignore b/.gitignore index 7b64991..98e233c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,15 @@ -out -debian/tmp -.vscode -build* -CMakeLists.txt.user +/out +/debian/tmp +/.vscode +/build* +/CMakeLists.txt.user *.autosave -AppImageBuilder.yml -appimage-builder-cache -appimage-build -AppDir -*.zsync -*.AppImage -core* -qemu_* -.prebuilt-armhf-toolchain +/AppImageBuilder.yml +/appimage-builder-cache +/appimage-build +/AppDir +/*.zsync +/*.AppImage +/core* +/qemu_* +/cmake/.prebuilt-armhf-toolchain diff --git a/CMakeLists.txt b/CMakeLists.txt index 84f9c73..d3ba8ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,20 @@ cmake_minimum_required(VERSION 3.16.0) +# Build Mode +set(MCPI_BUILD_MODE "native" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code") +set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "arm" "native") +if(MCPI_BUILD_MODE STREQUAL "arm") + set(BUILD_ARM_COMPONENTS TRUE) + set(BUILD_NATIVE_COMPONENTS FALSE) +elseif(MCPI_BUILD_MODE STREQUAL "native") + set(BUILD_ARM_COMPONENTS FALSE) + set(BUILD_NATIVE_COMPONENTS TRUE) +else() + message(FATAL_ERROR "Invalid Mode") +endif() + # Specify Options option(MCPI_IS_MIXED_BUILD "Whether The Architecture-Independent And ARM Code Are Different Architecture" FALSE) -set(MCPI_BUILD_MODE "native" CACHE STRING "\"arm\" = Build Only Code That Must Be ARM; \"native\" = Build Architecture-Independent Code") -set_property(CACHE MCPI_BUILD_MODE PROPERTY STRINGS "arm" "native") option(MCPI_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE) option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE) @@ -11,16 +22,15 @@ option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" FALSE) option(MCPI_SERVER_MODE "Server Mode" FALSE) option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE}) -# Prebuilt ARMHF Toolchain -option(MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN "Whether To Use A Prebuilt ARMHF Toolchain For Building ARM Components" ${MCPI_IS_MIXED_BUILD}) - # Media Layer -if(NOT MCPI_HEADLESS_MODE) - option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" ${MCPI_IS_MIXED_BUILD}) - option(MCPI_USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE) +if(MCPI_HEADLESS_MODE) + set(DEFAULT_USE_MEDIA_LAYER_PROXY FALSE) else() - set(MCPI_USE_MEDIA_LAYER_PROXY FALSE) - set(MCPI_USE_GLES1_COMPATIBILITY_LAYER FALSE) + set(DEFAULT_USE_MEDIA_LAYER_PROXY ${MCPI_IS_MIXED_BUILD}) +endif() +option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" ${DEFAULT_USE_MEDIA_LAYER_PROXY}) +if(NOT MCPI_HEADLESS_MODE) + option(MCPI_USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE) endif() # App ID @@ -41,17 +51,6 @@ else() endif() set(MCPI_APP_TITLE "${DEFAULT_APP_TITLE}" CACHE STRING "App Title") -# Configure Build Mode -if(MCPI_BUILD_MODE STREQUAL "arm") - set(BUILD_ARM_COMPONENTS TRUE) - set(BUILD_NATIVE_COMPONENTS FALSE) -elseif(MCPI_BUILD_MODE STREQUAL "native") - set(BUILD_ARM_COMPONENTS FALSE) - set(BUILD_NATIVE_COMPONENTS TRUE) -else() - message(FATAL_ERROR "Invalid Mode") -endif() - # Specify Variant Name set(MCPI_VARIANT_NAME "minecraft-pi-reborn") if(MCPI_SERVER_MODE) @@ -86,7 +85,8 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") endif() -# Setup Prebuilt ARMHF Toolchain +# Prebuilt ARMHF Toolchain +option(MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN "Whether To Use A Prebuilt ARMHF Toolchain For Building ARM Components" ${MCPI_IS_MIXED_BUILD}) if(BUILD_ARM_COMPONENTS AND MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN) include(cmake/prebuilt-armhf-toolchain.cmake) endif() @@ -97,12 +97,10 @@ project(minecraft-pi-reborn) # Utility Functions include(cmake/util.cmake) -# Sanity Check +# Sanity Checks if(BUILD_NATIVE_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT MCPI_IS_MIXED_BUILD) message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.") endif() - -# Require ARM Compilation if(BUILD_ARM_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") message(FATAL_ERROR "ARM-Targeting Compiler Required") endif() @@ -139,7 +137,7 @@ add_subdirectory(dependencies) # Warnings add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference) -if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 10.0) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 10.0) # Prevents False Positives add_compile_options(-Wno-stringop-overflow) endif() diff --git a/cmake/prebuilt-armhf-toolchain.cmake b/cmake/prebuilt-armhf-toolchain.cmake index b2ea7c1..644b7eb 100644 --- a/cmake/prebuilt-armhf-toolchain.cmake +++ b/cmake/prebuilt-armhf-toolchain.cmake @@ -1,5 +1,5 @@ # Locations -set(toolchain_dir "${CMAKE_CURRENT_SOURCE_DIR}/.prebuilt-armhf-toolchain") +set(toolchain_dir "${CMAKE_CURRENT_LIST_DIR}/.prebuilt-armhf-toolchain") set(sysroot_dir "${CMAKE_CURRENT_BINARY_DIR}/bundled-armhf-sysroot") # Force Toolchain @@ -16,7 +16,7 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}") if(arch STREQUAL "x86_64") set(toolchain_url "https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz") set(toolchain_sha256 "c254f7199261fe76c32ef42187502839bda7efad0a66646cf739d074eff45fad") - elseif(arch STREQUAL "aarch64_be" OR arch STREQUAL "aarch64" OR arch STREQUAL "armv8b" OR arch STREQUAL "armv8l") + elseif(arch STREQUAL "aarch64" OR arch STREQUAL "armv8b" OR arch STREQUAL "armv8l") set(toolchain_url "https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-aarch64-arm-none-linux-gnueabihf.tar.xz") set(toolchain_sha256 "c5603772af016008ddacb7e475dc226d0cccdf069925dfded43e452a59774fc3") else() @@ -35,6 +35,7 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}") SOURCE_DIR "${toolchain_dir}" ) FetchContent_Populate(prebuilt-armhf-toolchain) + # Force Sysroot Rebuild file(REMOVE_RECURSE "${sysroot_dir}") endif() @@ -51,11 +52,12 @@ if(NOT EXISTS "${sysroot_dir}") USE_SOURCE_PERMISSIONS FILES_MATCHING PATTERN "*.so*" - PATTERN "*.py*" EXCLUDE - REGEX "gconv" EXCLUDE - REGEX "audit" EXCLUDE ) + # Delete Unneeded Files + file(REMOVE_RECURSE "${sysroot_dir}/usr/lib/audit") + file(REMOVE_RECURSE "${sysroot_dir}/usr/lib/gconv") + # Strip Files file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir}/*") foreach(file IN LISTS files) diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 7a82927..4ccd871 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -7,6 +7,6 @@ if(BUILD_ARM_COMPONENTS AND NOT MCPI_OPEN_SOURCE_ONLY) add_subdirectory(minecraft-pi) endif() # Zenity (Minimal Build) -if(BUILD_NATIVE_COMPONENTS AND NOT MCPI_HEADLESS_MODE) +if(BUILD_NATIVE_COMPONENTS AND NOT MCPI_SERVER_MODE) add_subdirectory(zenity) endif() diff --git a/example-mods/chat-commands/.gitignore b/example-mods/chat-commands/.gitignore index 8563b98..98e233c 100644 --- a/example-mods/chat-commands/.gitignore +++ b/example-mods/chat-commands/.gitignore @@ -1,14 +1,15 @@ -out -debian/tmp -.vscode -build* -CMakeLists.txt.user +/out +/debian/tmp +/.vscode +/build* +/CMakeLists.txt.user *.autosave -AppImageBuilder.yml -appimage-builder-cache -appimage-build -AppDir -*.zsync -*.AppImage -core* -qemu_* +/AppImageBuilder.yml +/appimage-builder-cache +/appimage-build +/AppDir +/*.zsync +/*.AppImage +/core* +/qemu_* +/cmake/.prebuilt-armhf-toolchain diff --git a/example-mods/expanded-creative/.gitignore b/example-mods/expanded-creative/.gitignore index 8563b98..98e233c 100644 --- a/example-mods/expanded-creative/.gitignore +++ b/example-mods/expanded-creative/.gitignore @@ -1,14 +1,15 @@ -out -debian/tmp -.vscode -build* -CMakeLists.txt.user +/out +/debian/tmp +/.vscode +/build* +/CMakeLists.txt.user *.autosave -AppImageBuilder.yml -appimage-builder-cache -appimage-build -AppDir -*.zsync -*.AppImage -core* -qemu_* +/AppImageBuilder.yml +/appimage-builder-cache +/appimage-build +/AppDir +/*.zsync +/*.AppImage +/core* +/qemu_* +/cmake/.prebuilt-armhf-toolchain diff --git a/example-mods/recipes/.gitignore b/example-mods/recipes/.gitignore index 8563b98..98e233c 100644 --- a/example-mods/recipes/.gitignore +++ b/example-mods/recipes/.gitignore @@ -1,14 +1,15 @@ -out -debian/tmp -.vscode -build* -CMakeLists.txt.user +/out +/debian/tmp +/.vscode +/build* +/CMakeLists.txt.user *.autosave -AppImageBuilder.yml -appimage-builder-cache -appimage-build -AppDir -*.zsync -*.AppImage -core* -qemu_* +/AppImageBuilder.yml +/appimage-builder-cache +/appimage-build +/AppDir +/*.zsync +/*.AppImage +/core* +/qemu_* +/cmake/.prebuilt-armhf-toolchain diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt index 2432b6a..9edf6b4 100644 --- a/images/CMakeLists.txt +++ b/images/CMakeLists.txt @@ -1,7 +1,7 @@ project(images) # Title Background -if(NOT MCPI_SERVER_MODE) +if(NOT MCPI_HEADLESS_MODE) install( FILES "background.png" DESTINATION "${MCPI_INSTALL_DIR}/data/images/gui" diff --git a/launcher/src/bootstrap.c b/launcher/src/bootstrap.c index b5baebc..ff28d12 100644 --- a/launcher/src/bootstrap.c +++ b/launcher/src/bootstrap.c @@ -149,7 +149,7 @@ void pre_bootstrap(int argc, char *argv[]) { #endif // Debug Zenity -#ifndef MCPI_HEADLESS_MODE +#ifndef MCPI_SERVER_MODE { const char *is_debug = getenv("MCPI_DEBUG"); if (is_debug != NULL && strlen(is_debug) > 0) { diff --git a/media-layer/core/CMakeLists.txt b/media-layer/core/CMakeLists.txt index 17f91cb..d6059cc 100644 --- a/media-layer/core/CMakeLists.txt +++ b/media-layer/core/CMakeLists.txt @@ -7,13 +7,17 @@ add_subdirectory(dependencies) set(CORE_SRC src/base.cpp src/media.c src/screenshot.c $) # 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() + list(APPEND CORE_SRC src/audio/stubs.c) endif() # Build add_library(media-layer-core SHARED ${CORE_SRC}) # Dependencies Are Setup Later # Install install(TARGETS media-layer-core DESTINATION "${MCPI_LIB_DIR}") -install(TARGETS media-layer-core EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}") +if(BUILD_ARM_COMPONENTS) + install(TARGETS media-layer-core EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}") +endif() # Link target_link_libraries(media-layer-core PUBLIC media-layer-headers PUBLIC reborn-util PUBLIC pthread PUBLIC dl) diff --git a/media-layer/core/dependencies/CMakeLists.txt b/media-layer/core/dependencies/CMakeLists.txt new file mode 100644 index 0000000..e228c06 --- /dev/null +++ b/media-layer/core/dependencies/CMakeLists.txt @@ -0,0 +1,6 @@ +project(media-layer-core-dependencies) + +# GLFW +if(NOT MCPI_HEADLESS_MODE) + add_subdirectory(glfw) +endif() diff --git a/media-layer/core/dependencies/glfw/CMakeLists.txt b/media-layer/core/dependencies/glfw/CMakeLists.txt new file mode 100644 index 0000000..d014d53 --- /dev/null +++ b/media-layer/core/dependencies/glfw/CMakeLists.txt @@ -0,0 +1,28 @@ +project(glfw) + +# Silence Warnings +add_compile_options(-w) + +## GLFW + +# Download +set(BUILD_SHARED_LIBS TRUE CACHE BOOL "" FORCE) +set(GLFW_BUILD_EXAMPLES FALSE CACHE BOOL "" FORCE) +set(GLFW_BUILD_TESTS FALSE CACHE BOOL "" FORCE) +set(GLFW_BUILD_DOCS FALSE CACHE BOOL "" FORCE) +set(GLFW_INSTALL FALSE CACHE BOOL "" FORCE) +set(GLFW_BUILD_WIN32 FALSE CACHE BOOL "" FORCE) +set(GLFW_BUILD_COCOA FALSE CACHE BOOL "" FORCE) +set(GLFW_BUILD_X11 TRUE CACHE BOOL "" FORCE) +set(GLFW_BUILD_WAYLAND TRUE CACHE BOOL "" FORCE) +set(GLFW_LIBRARY_TYPE "SHARED" CACHE BOOL "" FORCE) +add_subdirectory(src EXCLUDE_FROM_ALL) + +# Ensure Build +add_custom_target(glfw-build ALL DEPENDS glfw) + +# Install +install(TARGETS glfw DESTINATION "${MCPI_LIB_DIR}") +if(BUILD_ARM_COMPONENTS) + install(TARGETS glfw EXPORT sdk DESTINATION "${MCPI_SDK_LIB_DIR}") +endif() diff --git a/media-layer/core/src/audio/stubs.c b/media-layer/core/src/audio/stubs.c new file mode 100644 index 0000000..2db851b --- /dev/null +++ b/media-layer/core/src/audio/stubs.c @@ -0,0 +1,6 @@ +#include + +void media_audio_update(__attribute__((unused)) float volume, __attribute__((unused)) float x, __attribute__((unused)) float y, __attribute__((unused)) float z, __attribute__((unused)) float yaw) { +} +void media_audio_play(__attribute__((unused)) const char *source, __attribute__((unused)) const char *name, __attribute__((unused)) float x, __attribute__((unused)) float y, __attribute__((unused)) float z, __attribute__((unused)) float pitch, __attribute__((unused)) float volume, __attribute__((unused)) int is_ui) { +} diff --git a/media-layer/gles/src/compatibility-layer/buffer.cpp b/media-layer/gles/src/compatibility-layer/buffer.cpp index dd47cb6..bff5a6b 100644 --- a/media-layer/gles/src/compatibility-layer/buffer.cpp +++ b/media-layer/gles/src/compatibility-layer/buffer.cpp @@ -29,6 +29,7 @@ void glDeleteBuffers(GLsizei n, const GLuint *buffers) { for (int i = 0; i < n; i++) { if (buffers_map.count(buffers[i]) > 0) { real_glDeleteBuffers()(1, &buffers_map[i]); + buffers_map.erase(buffers[i]); } } } diff --git a/media-layer/gles/src/stubs.c b/media-layer/gles/src/stubs.c index 35bbead..0f62e22 100644 --- a/media-layer/gles/src/stubs.c +++ b/media-layer/gles/src/stubs.c @@ -45,7 +45,11 @@ void glDepthRangef(GLclampf near, GLclampf far) { } void glDepthFunc(GLenum func) { } +static GLuint current_buffer = 0; void glBindBuffer(GLenum target, GLuint buffer) { + if (target == GL_ARRAY_BUFFER) { + current_buffer = buffer; + } } void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { } @@ -140,6 +144,10 @@ void glGetIntegerv(GLenum pname, GLint *data) { data[0] = current_texture; break; } + case GL_ARRAY_BUFFER_BINDING: { + data[0] = current_buffer; + break; + } case GL_UNPACK_ALIGNMENT: { data[0] = 1; break; diff --git a/media-layer/include/media-layer/audio.h b/media-layer/include/media-layer/audio.h index 7320196..264437e 100644 --- a/media-layer/include/media-layer/audio.h +++ b/media-layer/include/media-layer/audio.h @@ -4,15 +4,8 @@ extern "C" { #endif -#ifndef MCPI_HEADLESS_MODE void media_audio_update(float volume, float x, float y, float z, float yaw); void media_audio_play(const char *source, const char *name, float x, float y, float z, float pitch, float volume, int is_ui); -#else -static inline void media_audio_update(__attribute__((unused)) float volume, __attribute__((unused)) float x, __attribute__((unused)) float y, __attribute__((unused)) float z, __attribute__((unused)) float yaw) { -} -static inline void media_audio_play(__attribute__((unused)) const char *source, __attribute__((unused)) const char *name, __attribute__((unused)) float x, __attribute__((unused)) float y, __attribute__((unused)) float z, __attribute__((unused)) float pitch, __attribute__((unused)) float volume, __attribute__((unused)) int is_ui) { -} -#endif #ifdef __cplusplus } diff --git a/media-layer/proxy/src/GLESv1_CM.c b/media-layer/proxy/src/GLESv1_CM.c index 40fef92..6c3888e 100644 --- a/media-layer/proxy/src/GLESv1_CM.c +++ b/media-layer/proxy/src/GLESv1_CM.c @@ -35,6 +35,31 @@ CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params)) { #endif } +// Track Bindings +#if defined(MEDIA_LAYER_PROXY_SERVER) +static GLuint bound_buffer = 0; +static GLuint bound_texture = 0; +static unsigned char vertex_array_enabled = 0; +static unsigned char color_array_enabled = 0; +static unsigned char tex_coord_array_enabled = 0; +static unsigned char *get_array_enabled_pointer(GLenum array) { + switch (array) { + case GL_VERTEX_ARRAY: { + return &vertex_array_enabled; + } + case GL_COLOR_ARRAY: { + return &color_array_enabled; + } + case GL_TEXTURE_COORD_ARRAY: { + return &tex_coord_array_enabled; + } + default: { + ERR("Unsupported Array Pointer: %i", array); + } + } +} +#endif + // 'pointer' Is Only Supported As An Integer, Not As An Actual Pointer #if defined(MEDIA_LAYER_PROXY_SERVER) #define CALL_GL_POINTER(unique_id, name) \ @@ -58,6 +83,7 @@ CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params)) { start_proxy_call(); \ \ /* Arguments */ \ + write_int(bound_buffer); \ write_int((uint32_t) size); \ write_int((uint32_t) type); \ write_int((uint32_t) stride); \ @@ -69,10 +95,11 @@ CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params)) { #else #define CALL_GL_POINTER(unique_id, name) \ CALL(unique_id, name, unused, unused) { \ + /* Setup Buffer Binding */ \ + GLuint bound_buffer = (GLuint) read_int(); \ + glBindBuffer(GL_ARRAY_BUFFER, bound_buffer); \ /* Check State */ \ - GLint current_buffer = 0; \ - glGetIntegerv(GL_ARRAY_BUFFER_BINDING, ¤t_buffer); \ - if (current_buffer == 0) { \ + if (bound_buffer == 0) { \ PROXY_ERR("gl*Pointer() Functions Are Only Supported When A Buffer Is Bound To GL_ARRAY_BUFFER"); \ } \ GLint size = (GLint) read_int(); \ @@ -122,31 +149,6 @@ CALL(14, glBlendFunc, void, (GLenum sfactor, GLenum dfactor)) { #endif } -// Track Bindings -#if defined(MEDIA_LAYER_PROXY_SERVER) -static GLuint bound_buffer = 0; -static GLuint bound_texture = 0; -static unsigned char vertex_array_enabled = 0; -static unsigned char color_array_enabled = 0; -static unsigned char tex_coord_array_enabled = 0; -static unsigned char *get_array_enabled_pointer(GLenum array) { - switch (array) { - case GL_VERTEX_ARRAY: { - return &vertex_array_enabled; - } - case GL_COLOR_ARRAY: { - return &color_array_enabled; - } - case GL_TEXTURE_COORD_ARRAY: { - return &tex_coord_array_enabled; - } - default: { - ERR("Unsupported Array Pointer: %i", array); - } - } -} -#endif - CALL(15, glDrawArrays, void, (GLenum mode, GLint first, GLsizei count)) { #if defined(MEDIA_LAYER_PROXY_SERVER) // Lock Proxy @@ -599,6 +601,12 @@ void glBindBuffer(GLenum target, GLuint buffer) { } else { PROXY_ERR("Unsupported Buffer Binding: %u", target); } + // Not needed when using compatibility layer +#ifndef MCPI_USE_GLES1_COMPATIBILITY_LAYER + is_set_glVertexPointer = 0; + is_set_glColorPointer = 0; + is_set_glTexCoordPointer = 0; +#endif } #endif diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index a4c7367..a6f9148 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -62,9 +62,6 @@ else() add_library(touch SHARED src/touch/touch.cpp) target_link_libraries(touch mods-headers reborn-patch symbols feature) - add_library(override SHARED src/override/override.c) - target_link_libraries(override mods-headers reborn-patch symbols dl home) - add_library(textures SHARED src/textures/textures.cpp) target_link_libraries(textures mods-headers reborn-patch symbols media-layer-core feature misc) @@ -75,6 +72,9 @@ else() target_link_libraries(benchmark mods-headers reborn-patch symbols compat misc media-layer-core) endif() +add_library(override SHARED src/override/override.c) +target_link_libraries(override mods-headers reborn-patch symbols dl home) + add_library(death SHARED src/death/death.cpp) target_link_libraries(death mods-headers reborn-patch symbols feature) @@ -99,11 +99,11 @@ else() endif() ## Install Mods -set(MODS_TO_INSTALL init compat readdir feature game-mode misc death options chat creative home version test) +set(MODS_TO_INSTALL init compat readdir feature game-mode misc override death options chat creative home version test) if(MCPI_SERVER_MODE) list(APPEND MODS_TO_INSTALL server) else() - list(APPEND MODS_TO_INSTALL multiplayer sound override camera input sign touch textures atlas benchmark) + list(APPEND MODS_TO_INSTALL multiplayer sound camera input sign touch textures atlas benchmark) endif() install(TARGETS ${MODS_TO_INSTALL} DESTINATION "${MCPI_INSTALL_DIR}/mods") # SDK diff --git a/mods/src/compat/compat.c b/mods/src/compat/compat.c index b29d26c..7a9ade9 100644 --- a/mods/src/compat/compat.c +++ b/mods/src/compat/compat.c @@ -7,16 +7,9 @@ #include -#ifndef MCPI_SERVER_MODE #include -#include - -#include -#include -#include -#include - +#ifndef MCPI_HEADLESS_MODE // Custom Title HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) { ensure_SDL_WM_SetCaption(); @@ -29,6 +22,15 @@ HOOK(SDL_ShowCursor, int, (int toggle)) { ensure_SDL_ShowCursor(); return (*real_SDL_ShowCursor)(toggle == SDL_QUERY ? SDL_QUERY : SDL_DISABLE); } +#endif + +#ifndef MCPI_SERVER_MODE +#include + +#include +#include +#include +#include // Intercept SDL Events HOOK(SDL_PollEvent, int, (SDL_Event *event)) { diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index e8e33f7..f706229 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -253,7 +253,7 @@ void init_misc() { } // Disable V-Sync - if (feature_has("Disable V-Sync", server_disabled)) { + if (feature_has("Disable V-Sync", server_enabled)) { media_disable_vsync(); } diff --git a/mods/src/touch/touch.cpp b/mods/src/touch/touch.cpp index e92a58a..0ebf24b 100644 --- a/mods/src/touch/touch.cpp +++ b/mods/src/touch/touch.cpp @@ -84,7 +84,7 @@ void init_touch() { } // Show Block Outlines - int block_outlines = feature_has("Show Block Outlines", 0); + int block_outlines = feature_has("Show Block Outlines", server_disabled); unsigned char outline_patch[4] = {(unsigned char) (block_outlines ? !touch_gui : touch_gui), 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0" patch((void *) 0x4a210, outline_patch); }