More Miscellaneous Fixes + Fixed GLES v1.1 Support

This commit is contained in:
TheBrokenRail 2022-07-08 00:25:01 -04:00
parent 23df63abb7
commit 484d3e7f90
21 changed files with 197 additions and 138 deletions

28
.gitignore vendored
View File

@ -1,15 +1,15 @@
out /out
debian/tmp /debian/tmp
.vscode /.vscode
build* /build*
CMakeLists.txt.user /CMakeLists.txt.user
*.autosave *.autosave
AppImageBuilder.yml /AppImageBuilder.yml
appimage-builder-cache /appimage-builder-cache
appimage-build /appimage-build
AppDir /AppDir
*.zsync /*.zsync
*.AppImage /*.AppImage
core* /core*
qemu_* /qemu_*
.prebuilt-armhf-toolchain /cmake/.prebuilt-armhf-toolchain

View File

@ -1,9 +1,20 @@
cmake_minimum_required(VERSION 3.16.0) 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 # Specify Options
option(MCPI_IS_MIXED_BUILD "Whether The Architecture-Independent And ARM Code Are Different Architecture" FALSE) 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_OPEN_SOURCE_ONLY "Only Install Open-Source Code (Will Result In Broken Install)" FALSE)
option(MCPI_IS_APPIMAGE_BUILD "AppImage Build" 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_SERVER_MODE "Server Mode" FALSE)
option(MCPI_HEADLESS_MODE "Headless Mode" ${MCPI_SERVER_MODE}) 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 # Media Layer
if(NOT MCPI_HEADLESS_MODE) if(MCPI_HEADLESS_MODE)
option(MCPI_USE_MEDIA_LAYER_PROXY "Whether To Enable The Media Layer Proxy" ${MCPI_IS_MIXED_BUILD}) set(DEFAULT_USE_MEDIA_LAYER_PROXY FALSE)
option(MCPI_USE_GLES1_COMPATIBILITY_LAYER "Whether To Enable The GLESv1_CM Compatibility Layer" TRUE)
else() else()
set(MCPI_USE_MEDIA_LAYER_PROXY FALSE) set(DEFAULT_USE_MEDIA_LAYER_PROXY ${MCPI_IS_MIXED_BUILD})
set(MCPI_USE_GLES1_COMPATIBILITY_LAYER FALSE) 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() endif()
# App ID # App ID
@ -41,17 +51,6 @@ else()
endif() endif()
set(MCPI_APP_TITLE "${DEFAULT_APP_TITLE}" CACHE STRING "App Title") 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 # Specify Variant Name
set(MCPI_VARIANT_NAME "minecraft-pi-reborn") set(MCPI_VARIANT_NAME "minecraft-pi-reborn")
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)
@ -86,7 +85,8 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release") set(CMAKE_BUILD_TYPE "Release")
endif() 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) if(BUILD_ARM_COMPONENTS AND MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN)
include(cmake/prebuilt-armhf-toolchain.cmake) include(cmake/prebuilt-armhf-toolchain.cmake)
endif() endif()
@ -97,12 +97,10 @@ project(minecraft-pi-reborn)
# Utility Functions # Utility Functions
include(cmake/util.cmake) 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) 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.") message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.")
endif() endif()
# Require ARM Compilation
if(BUILD_ARM_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") if(BUILD_ARM_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
message(FATAL_ERROR "ARM-Targeting Compiler Required") message(FATAL_ERROR "ARM-Targeting Compiler Required")
endif() endif()
@ -139,7 +137,7 @@ add_subdirectory(dependencies)
# Warnings # Warnings
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference) 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 # Prevents False Positives
add_compile_options(-Wno-stringop-overflow) add_compile_options(-Wno-stringop-overflow)
endif() endif()

View File

@ -1,5 +1,5 @@
# Locations # 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") set(sysroot_dir "${CMAKE_CURRENT_BINARY_DIR}/bundled-armhf-sysroot")
# Force Toolchain # Force Toolchain
@ -16,7 +16,7 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}")
if(arch STREQUAL "x86_64") 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_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") 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_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") set(toolchain_sha256 "c5603772af016008ddacb7e475dc226d0cccdf069925dfded43e452a59774fc3")
else() else()
@ -35,6 +35,7 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}")
SOURCE_DIR "${toolchain_dir}" SOURCE_DIR "${toolchain_dir}"
) )
FetchContent_Populate(prebuilt-armhf-toolchain) FetchContent_Populate(prebuilt-armhf-toolchain)
# Force Sysroot Rebuild # Force Sysroot Rebuild
file(REMOVE_RECURSE "${sysroot_dir}") file(REMOVE_RECURSE "${sysroot_dir}")
endif() endif()
@ -51,11 +52,12 @@ if(NOT EXISTS "${sysroot_dir}")
USE_SOURCE_PERMISSIONS USE_SOURCE_PERMISSIONS
FILES_MATCHING FILES_MATCHING
PATTERN "*.so*" 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 # Strip Files
file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir}/*") file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir}/*")
foreach(file IN LISTS files) foreach(file IN LISTS files)

View File

@ -7,6 +7,6 @@ if(BUILD_ARM_COMPONENTS AND NOT MCPI_OPEN_SOURCE_ONLY)
add_subdirectory(minecraft-pi) add_subdirectory(minecraft-pi)
endif() endif()
# Zenity (Minimal Build) # Zenity (Minimal Build)
if(BUILD_NATIVE_COMPONENTS AND NOT MCPI_HEADLESS_MODE) if(BUILD_NATIVE_COMPONENTS AND NOT MCPI_SERVER_MODE)
add_subdirectory(zenity) add_subdirectory(zenity)
endif() endif()

View File

@ -1,14 +1,15 @@
out /out
debian/tmp /debian/tmp
.vscode /.vscode
build* /build*
CMakeLists.txt.user /CMakeLists.txt.user
*.autosave *.autosave
AppImageBuilder.yml /AppImageBuilder.yml
appimage-builder-cache /appimage-builder-cache
appimage-build /appimage-build
AppDir /AppDir
*.zsync /*.zsync
*.AppImage /*.AppImage
core* /core*
qemu_* /qemu_*
/cmake/.prebuilt-armhf-toolchain

View File

@ -1,14 +1,15 @@
out /out
debian/tmp /debian/tmp
.vscode /.vscode
build* /build*
CMakeLists.txt.user /CMakeLists.txt.user
*.autosave *.autosave
AppImageBuilder.yml /AppImageBuilder.yml
appimage-builder-cache /appimage-builder-cache
appimage-build /appimage-build
AppDir /AppDir
*.zsync /*.zsync
*.AppImage /*.AppImage
core* /core*
qemu_* /qemu_*
/cmake/.prebuilt-armhf-toolchain

View File

@ -1,14 +1,15 @@
out /out
debian/tmp /debian/tmp
.vscode /.vscode
build* /build*
CMakeLists.txt.user /CMakeLists.txt.user
*.autosave *.autosave
AppImageBuilder.yml /AppImageBuilder.yml
appimage-builder-cache /appimage-builder-cache
appimage-build /appimage-build
AppDir /AppDir
*.zsync /*.zsync
*.AppImage /*.AppImage
core* /core*
qemu_* /qemu_*
/cmake/.prebuilt-armhf-toolchain

View File

@ -1,7 +1,7 @@
project(images) project(images)
# Title Background # Title Background
if(NOT MCPI_SERVER_MODE) if(NOT MCPI_HEADLESS_MODE)
install( install(
FILES "background.png" FILES "background.png"
DESTINATION "${MCPI_INSTALL_DIR}/data/images/gui" DESTINATION "${MCPI_INSTALL_DIR}/data/images/gui"

View File

@ -149,7 +149,7 @@ void pre_bootstrap(int argc, char *argv[]) {
#endif #endif
// Debug Zenity // Debug Zenity
#ifndef MCPI_HEADLESS_MODE #ifndef MCPI_SERVER_MODE
{ {
const char *is_debug = getenv("MCPI_DEBUG"); const char *is_debug = getenv("MCPI_DEBUG");
if (is_debug != NULL && strlen(is_debug) > 0) { if (is_debug != NULL && strlen(is_debug) > 0) {

View File

@ -7,13 +7,17 @@ add_subdirectory(dependencies)
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 src/screenshot.c $<TARGET_OBJECTS:media-layer-extras>) # SDL Re-Implementation Using GLFW
if(NOT MCPI_HEADLESS_MODE) if(NOT MCPI_HEADLESS_MODE)
list(APPEND CORE_SRC src/audio/api.cpp src/audio/engine.c src/audio/file.cpp) 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() endif()
# Build # Build
add_library(media-layer-core SHARED ${CORE_SRC}) # Dependencies Are Setup Later add_library(media-layer-core SHARED ${CORE_SRC}) # Dependencies Are Setup Later
# Install # Install
install(TARGETS media-layer-core DESTINATION "${MCPI_LIB_DIR}") 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 # Link
target_link_libraries(media-layer-core PUBLIC media-layer-headers PUBLIC reborn-util PUBLIC pthread PUBLIC dl) target_link_libraries(media-layer-core PUBLIC media-layer-headers PUBLIC reborn-util PUBLIC pthread PUBLIC dl)

View File

@ -0,0 +1,6 @@
project(media-layer-core-dependencies)
# GLFW
if(NOT MCPI_HEADLESS_MODE)
add_subdirectory(glfw)
endif()

View File

@ -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()

View File

@ -0,0 +1,6 @@
#include <media-layer/audio.h>
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) {
}

View File

@ -29,6 +29,7 @@ void glDeleteBuffers(GLsizei n, const GLuint *buffers) {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
if (buffers_map.count(buffers[i]) > 0) { if (buffers_map.count(buffers[i]) > 0) {
real_glDeleteBuffers()(1, &buffers_map[i]); real_glDeleteBuffers()(1, &buffers_map[i]);
buffers_map.erase(buffers[i]);
} }
} }
} }

View File

@ -45,7 +45,11 @@ void glDepthRangef(GLclampf near, GLclampf far) {
} }
void glDepthFunc(GLenum func) { void glDepthFunc(GLenum func) {
} }
static GLuint current_buffer = 0;
void glBindBuffer(GLenum target, GLuint buffer) { void glBindBuffer(GLenum target, GLuint buffer) {
if (target == GL_ARRAY_BUFFER) {
current_buffer = buffer;
}
} }
void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
} }
@ -140,6 +144,10 @@ void glGetIntegerv(GLenum pname, GLint *data) {
data[0] = current_texture; data[0] = current_texture;
break; break;
} }
case GL_ARRAY_BUFFER_BINDING: {
data[0] = current_buffer;
break;
}
case GL_UNPACK_ALIGNMENT: { case GL_UNPACK_ALIGNMENT: {
data[0] = 1; data[0] = 1;
break; break;

View File

@ -4,15 +4,8 @@
extern "C" { extern "C" {
#endif #endif
#ifndef MCPI_HEADLESS_MODE
void media_audio_update(float volume, float x, float y, float z, float yaw); 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); 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 #ifdef __cplusplus
} }

View File

@ -35,6 +35,31 @@ CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params)) {
#endif #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 // 'pointer' Is Only Supported As An Integer, Not As An Actual Pointer
#if defined(MEDIA_LAYER_PROXY_SERVER) #if defined(MEDIA_LAYER_PROXY_SERVER)
#define CALL_GL_POINTER(unique_id, name) \ #define CALL_GL_POINTER(unique_id, name) \
@ -58,6 +83,7 @@ CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params)) {
start_proxy_call(); \ start_proxy_call(); \
\ \
/* Arguments */ \ /* Arguments */ \
write_int(bound_buffer); \
write_int((uint32_t) size); \ write_int((uint32_t) size); \
write_int((uint32_t) type); \ write_int((uint32_t) type); \
write_int((uint32_t) stride); \ write_int((uint32_t) stride); \
@ -69,10 +95,11 @@ CALL(11, glFogfv, void, (GLenum pname, const GLfloat *params)) {
#else #else
#define CALL_GL_POINTER(unique_id, name) \ #define CALL_GL_POINTER(unique_id, name) \
CALL(unique_id, name, unused, unused) { \ CALL(unique_id, name, unused, unused) { \
/* Setup Buffer Binding */ \
GLuint bound_buffer = (GLuint) read_int(); \
glBindBuffer(GL_ARRAY_BUFFER, bound_buffer); \
/* Check State */ \ /* Check State */ \
GLint current_buffer = 0; \ if (bound_buffer == 0) { \
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &current_buffer); \
if (current_buffer == 0) { \
PROXY_ERR("gl*Pointer() Functions Are Only Supported When A Buffer Is Bound To GL_ARRAY_BUFFER"); \ PROXY_ERR("gl*Pointer() Functions Are Only Supported When A Buffer Is Bound To GL_ARRAY_BUFFER"); \
} \ } \
GLint size = (GLint) read_int(); \ GLint size = (GLint) read_int(); \
@ -122,31 +149,6 @@ CALL(14, glBlendFunc, void, (GLenum sfactor, GLenum dfactor)) {
#endif #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)) { CALL(15, glDrawArrays, void, (GLenum mode, GLint first, GLsizei count)) {
#if defined(MEDIA_LAYER_PROXY_SERVER) #if defined(MEDIA_LAYER_PROXY_SERVER)
// Lock Proxy // Lock Proxy
@ -599,6 +601,12 @@ void glBindBuffer(GLenum target, GLuint buffer) {
} else { } else {
PROXY_ERR("Unsupported Buffer Binding: %u", target); 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 #endif

View File

@ -62,9 +62,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(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) add_library(textures SHARED src/textures/textures.cpp)
target_link_libraries(textures mods-headers reborn-patch symbols media-layer-core feature misc) 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) target_link_libraries(benchmark mods-headers reborn-patch symbols compat misc media-layer-core)
endif() 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) add_library(death SHARED src/death/death.cpp)
target_link_libraries(death mods-headers reborn-patch symbols feature) target_link_libraries(death mods-headers reborn-patch symbols feature)
@ -99,11 +99,11 @@ else()
endif() endif()
## Install Mods ## 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) 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 override camera input sign touch textures atlas benchmark) list(APPEND MODS_TO_INSTALL multiplayer sound camera input sign touch textures atlas benchmark)
endif() endif()
install(TARGETS ${MODS_TO_INSTALL} DESTINATION "${MCPI_INSTALL_DIR}/mods") install(TARGETS ${MODS_TO_INSTALL} DESTINATION "${MCPI_INSTALL_DIR}/mods")
# SDK # SDK

View File

@ -7,16 +7,9 @@
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
#ifndef MCPI_SERVER_MODE
#include <SDL/SDL.h> #include <SDL/SDL.h>
#include <media-layer/core.h> #ifndef MCPI_HEADLESS_MODE
#include <mods/input/input.h>
#include <mods/sign/sign.h>
#include <mods/chat/chat.h>
#include <mods/home/home.h>
// Custom Title // Custom Title
HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) { HOOK(SDL_WM_SetCaption, void, (__attribute__((unused)) const char *title, const char *icon)) {
ensure_SDL_WM_SetCaption(); ensure_SDL_WM_SetCaption();
@ -29,6 +22,15 @@ HOOK(SDL_ShowCursor, int, (int toggle)) {
ensure_SDL_ShowCursor(); ensure_SDL_ShowCursor();
return (*real_SDL_ShowCursor)(toggle == SDL_QUERY ? SDL_QUERY : SDL_DISABLE); return (*real_SDL_ShowCursor)(toggle == SDL_QUERY ? SDL_QUERY : SDL_DISABLE);
} }
#endif
#ifndef MCPI_SERVER_MODE
#include <media-layer/core.h>
#include <mods/input/input.h>
#include <mods/sign/sign.h>
#include <mods/chat/chat.h>
#include <mods/home/home.h>
// Intercept SDL Events // Intercept SDL Events
HOOK(SDL_PollEvent, int, (SDL_Event *event)) { HOOK(SDL_PollEvent, int, (SDL_Event *event)) {

View File

@ -253,7 +253,7 @@ void init_misc() {
} }
// Disable V-Sync // Disable V-Sync
if (feature_has("Disable V-Sync", server_disabled)) { if (feature_has("Disable V-Sync", server_enabled)) {
media_disable_vsync(); media_disable_vsync();
} }

View File

@ -84,7 +84,7 @@ void init_touch() {
} }
// Show Block Outlines // 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" 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); patch((void *) 0x4a210, outline_patch);
} }