Clean Up Compat Code

This commit is contained in:
TheBrokenRail 2020-10-06 11:08:10 -04:00
parent 98d6ac2577
commit 7ac5d15737
2 changed files with 43 additions and 58 deletions

View File

@ -28,11 +28,6 @@ static Window x11_window;
static Window x11_root_window; static Window x11_root_window;
static int window_loaded = 0; static int window_loaded = 0;
HOOK(eglGetDisplay, EGLDisplay, (__attribute__((unused)) NativeDisplayType native_display)) {
// Handled In ensure_x11_window()
return 0;
}
// Get Reference To X Window // Get Reference To X Window
static void store_x11_window() { static void store_x11_window() {
x11_display = glfwGetX11Display(); x11_display = glfwGetX11Display();
@ -42,57 +37,6 @@ static void store_x11_window() {
window_loaded = 1; window_loaded = 1;
} }
// Handled In SDL_WM_SetCaption
HOOK(eglInitialize, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLint *major, __attribute__((unused)) EGLint *minor)) {
return EGL_TRUE;
}
// Handled In SDL_WM_SetCaption
HOOK(eglChooseConfig, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLint const *attrib_list, __attribute__((unused)) EGLConfig *configs, __attribute__((unused)) EGLint config_size, __attribute__((unused)) EGLint *num_config)) {
return EGL_TRUE;
}
// Handled In SDL_WM_SetCaption
HOOK(eglBindAPI, EGLBoolean, (__attribute__((unused)) EGLenum api)) {
return EGL_TRUE;
}
// Handled In SDL_WM_SetCaption
HOOK(eglCreateContext, EGLContext, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLConfig config, __attribute__((unused)) EGLContext share_context, __attribute__((unused)) EGLint const *attrib_list)) {
return 0;
}
// Handled In SDL_WM_SetCaption
HOOK(eglCreateWindowSurface, EGLSurface, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLConfig config, __attribute__((unused)) NativeWindowType native_window, __attribute__((unused)) EGLint const *attrib_list)) {
return 0;
}
// Handled In SDL_WM_SetCaption
HOOK(eglMakeCurrent, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLSurface draw, __attribute__((unused)) EGLSurface read, __attribute__((unused)) EGLContext context)) {
return EGL_TRUE;
}
// Handled In SDL_Quit
HOOK(eglDestroySurface, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLSurface surface)) {
return EGL_TRUE;
}
// Handled In SDL_Quit
HOOK(eglDestroyContext, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLContext context)) {
return EGL_TRUE;
}
// Handled In SDL_Quit
HOOK(eglTerminate, EGLBoolean, (__attribute__((unused)) EGLDisplay display)) {
return EGL_TRUE;
}
// Handled In SDL_WM_SetCaption
HOOK(SDL_SetVideoMode, SDL_Surface *, (__attribute__((unused)) int width, __attribute__((unused)) int height, __attribute__((unused)) int bpp, __attribute__((unused)) uint32_t flags)) {
// Return Value Is Only Used For A NULL-Check
return (SDL_Surface *) 1;
}
// Handle GLFW Error // Handle GLFW Error
static void glfw_error(__attribute__((unused)) int error, const char *description) { static void glfw_error(__attribute__((unused)) int error, const char *description) {
fprintf(stderr, "GLFW Error: %s\n", description); fprintf(stderr, "GLFW Error: %s\n", description);
@ -392,7 +336,7 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) {
return ret; return ret;
} }
// Terminate EGL // Terminate GLFW
HOOK(SDL_Quit, void, ()) { HOOK(SDL_Quit, void, ()) {
ensure_SDL_Quit(); ensure_SDL_Quit();
(*real_SDL_Quit)(); (*real_SDL_Quit)();
@ -425,6 +369,12 @@ HOOK(SDL_ShowCursor, int, (int toggle)) {
return toggle == SDL_QUERY ? (glfwGetInputMode(glfw_window, GLFW_CURSOR) == GLFW_CURSOR_NORMAL ? SDL_ENABLE : SDL_DISABLE) : toggle; return toggle == SDL_QUERY ? (glfwGetInputMode(glfw_window, GLFW_CURSOR) == GLFW_CURSOR_NORMAL ? SDL_ENABLE : SDL_DISABLE) : toggle;
} }
// SDL Stub
HOOK(SDL_SetVideoMode, SDL_Surface *, (__attribute__((unused)) int width, __attribute__((unused)) int height, __attribute__((unused)) int bpp, __attribute__((unused)) uint32_t flags)) {
// Return Value Is Only Used For A NULL-Check
return (SDL_Surface *) 1;
}
HOOK(XTranslateCoordinates, int, (Display *display, Window src_w, Window dest_w, int src_x, int src_y, int *dest_x_return, int *dest_y_return, Window *child_return)) { HOOK(XTranslateCoordinates, int, (Display *display, Window src_w, Window dest_w, int src_x, int src_y, int *dest_x_return, int *dest_y_return, Window *child_return)) {
ensure_XTranslateCoordinates(); ensure_XTranslateCoordinates();
if (window_loaded) { if (window_loaded) {
@ -443,6 +393,39 @@ HOOK(XGetWindowAttributes, int, (Display *display, Window w, XWindowAttributes *
} }
} }
// EGL Stubs
HOOK(eglGetDisplay, EGLDisplay, (__attribute__((unused)) NativeDisplayType native_display)) {
return 0;
}
HOOK(eglInitialize, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLint *major, __attribute__((unused)) EGLint *minor)) {
return EGL_TRUE;
}
HOOK(eglChooseConfig, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLint const *attrib_list, __attribute__((unused)) EGLConfig *configs, __attribute__((unused)) EGLint config_size, __attribute__((unused)) EGLint *num_config)) {
return EGL_TRUE;
}
HOOK(eglBindAPI, EGLBoolean, (__attribute__((unused)) EGLenum api)) {
return EGL_TRUE;
}
HOOK(eglCreateContext, EGLContext, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLConfig config, __attribute__((unused)) EGLContext share_context, __attribute__((unused)) EGLint const *attrib_list)) {
return 0;
}
HOOK(eglCreateWindowSurface, EGLSurface, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLConfig config, __attribute__((unused)) NativeWindowType native_window, __attribute__((unused)) EGLint const *attrib_list)) {
return 0;
}
HOOK(eglMakeCurrent, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLSurface draw, __attribute__((unused)) EGLSurface read, __attribute__((unused)) EGLContext context)) {
return EGL_TRUE;
}
HOOK(eglDestroySurface, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLSurface surface)) {
return EGL_TRUE;
}
HOOK(eglDestroyContext, EGLBoolean, (__attribute__((unused)) EGLDisplay display, __attribute__((unused)) EGLContext context)) {
return EGL_TRUE;
}
HOOK(eglTerminate, EGLBoolean, (__attribute__((unused)) EGLDisplay display)) {
return EGL_TRUE;
}
#include <stdlib.h> #include <stdlib.h>
// Use VirGL // Use VirGL

View File

@ -19,4 +19,6 @@ mkdir -p out/lib
cp -r mods/include out/lib/include cp -r mods/include out/lib/include
# Copy Shared Library # Copy Shared Library
docker run -v "$(pwd)/out/lib:/out" --entrypoint sh thebrokenrail/minecraft-pi -c 'cp ./mods/lib*.so /out' IMG_ID="$(docker create thebrokenrail/minecraft-pi)"
docker cp "${IMG_ID}":/app/minecraft-pi/mods/. ./out/lib/.
docker rm -v "${IMG_ID}"