From a1f1681ce73d6ace1e5b7b6f426d945683feb154 Mon Sep 17 00:00:00 2001 From: JuiceyDev Date: Thu, 5 Mar 2026 14:02:05 +0100 Subject: [PATCH] Starting IGGY impl --- Minecraft.Client/Build/CMakeLists.txt | 2 + .../Platform/Linux/Linux_UIController.cpp | 80 ++++++++++++++++++- .../Platform/Linux/Stubs/iggy_stubs.h | 27 +++++++ 3 files changed, 105 insertions(+), 4 deletions(-) diff --git a/Minecraft.Client/Build/CMakeLists.txt b/Minecraft.Client/Build/CMakeLists.txt index f1824aeac..e2ed67a27 100644 --- a/Minecraft.Client/Build/CMakeLists.txt +++ b/Minecraft.Client/Build/CMakeLists.txt @@ -1106,6 +1106,8 @@ set(Linux "../Platform/Linux/Linux_App.cpp" "../Platform/Linux/LinuxGL.cpp" "../Platform/Linux/linux_game_stubs.cpp" + "../Platform/Linux/Iggy/gdraw/gdraw_glfw.c" + "../Platform/Linux/Iggy/gdraw/gdraw_glfw.h" ) source_group("Linux" FILES ${Linux}) diff --git a/Minecraft.Client/Platform/Linux/Linux_UIController.cpp b/Minecraft.Client/Platform/Linux/Linux_UIController.cpp index 4935914f6..fb6e8b40e 100644 --- a/Minecraft.Client/Platform/Linux/Linux_UIController.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_UIController.cpp @@ -1,6 +1,13 @@ #include "../../../Minecraft.World/Build/stdafx.h" #include "Linux_UIController.h" +// Temp +#include "../../Minecraft.h" +#include "../../Textures/Textures.h" + +// GDraw GL backend for Linux +#include "Iggy/gdraw/gdraw_glfw.h" + #define _ENABLEIGGY ConsoleUIController ui; @@ -9,46 +16,111 @@ void ConsoleUIController::init(S32 w, S32 h) { #ifdef _ENABLEIGGY // Shared init - preInit(w,h); + preInit(w, h); + + //init + gdraw_funcs = gdraw_GL_CreateContext(w, h, 0); + + if (!gdraw_funcs) + { + app.DebugPrintf("Failed to initialise GDraw GL!\n"); + fprintf(stderr, "[Linux_UIController] Failed to initialise GDraw GL!\n"); + // nott fatal for now + } + else + { + + gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_vertexbuffer, 5000, 16 * 1024 * 1024); + gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_texture, 5000, 128 * 1024 * 1024); + gdraw_GL_SetResourceLimits(GDRAW_GL_RESOURCE_rendertarget, 10, 32 * 1024 * 1024); + + IggySetGDraw(gdraw_funcs); + } + postInit(); #endif } void ConsoleUIController::render() { +#ifdef _ENABLEIGGY + if (!gdraw_funcs) + return; + + gdraw_GL_SetTileOrigin(0, 0, 0); + + // render + renderScenes(); + + gdraw_GL_NoMoreGDrawThisFrame(); +#endif } void ConsoleUIController::beginIggyCustomDraw4J(IggyCustomDrawCallbackRegion *region, CustomDrawData *customDrawRegion) -{ + + gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat); } CustomDrawData *ConsoleUIController::setupCustomDraw(UIScene *scene, IggyCustomDrawCallbackRegion *region) { - return nullptr; + CustomDrawData *customDrawRegion = new CustomDrawData(); + customDrawRegion->x0 = region->x0; + customDrawRegion->x1 = region->x1; + customDrawRegion->y0 = region->y0; + customDrawRegion->y1 = region->y1; + + + gdraw_GL_BeginCustomDraw_4J(region, customDrawRegion->mat); + + setupCustomDrawGameStateAndMatrices(scene, customDrawRegion); + + return customDrawRegion; } CustomDrawData *ConsoleUIController::calculateCustomDraw(IggyCustomDrawCallbackRegion *region) { - return nullptr; + CustomDrawData *customDrawRegion = new CustomDrawData(); + customDrawRegion->x0 = region->x0; + customDrawRegion->x1 = region->x1; + customDrawRegion->y0 = region->y0; + customDrawRegion->y1 = region->y1; + + gdraw_GL_CalculateCustomDraw_4J(region, customDrawRegion->mat); + + return customDrawRegion; } void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion *region) { + endCustomDrawGameStateAndMatrices(); + + gdraw_GL_EndCustomDraw(region); } void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) { + gdraw_GL_SetTileOrigin(xPos, yPos, 0); } GDrawTexture *ConsoleUIController::getSubstitutionTexture(int textureId) { + // todo impl return nullptr; } void ConsoleUIController::destroySubstitutionTexture(void *destroyCallBackData, GDrawTexture *handle) { + if (handle) + gdraw_GL_WrappedTextureDestroy(handle); } void ConsoleUIController::shutdown() { +#ifdef _ENABLEIGGY + if (gdraw_funcs) + { + gdraw_GL_DestroyContext(); + gdraw_funcs = nullptr; + } +#endif } \ No newline at end of file diff --git a/Minecraft.Client/Platform/Linux/Stubs/iggy_stubs.h b/Minecraft.Client/Platform/Linux/Stubs/iggy_stubs.h index 8f9232f82..532c4b265 100644 --- a/Minecraft.Client/Platform/Linux/Stubs/iggy_stubs.h +++ b/Minecraft.Client/Platform/Linux/Stubs/iggy_stubs.h @@ -159,4 +159,31 @@ RADEXPFUNC inline void RADEXPLINK IggyLibraryDestroy(IggyLibrary lib) { STUBBED; } +// Iggy is fake +static GDrawFunctions *s_iggy_gdraw_funcs = 0; +RADEXPFUNC inline void RADEXPLINK IggySetGDraw(GDrawFunctions *gdraw_funcs) { + s_iggy_gdraw_funcs = gdraw_funcs; +} + +// Audio stubs +RADEXPFUNC inline void RADEXPLINK IggyAudioUseDefault(void) { + STUBBED; +} + +// Explorer/Perfmon, shit implmentation +RADEXPFUNC inline void * RADEXPLINK IggyExpCreate(const char *host, int port, void *storage, int storage_size) { + STUBBED; + return 0; +} +RADEXPFUNC inline void RADEXPLINK IggyUseExplorer(Iggy *player, void *explorer) { + STUBBED; +} +RADEXPFUNC inline void * RADEXPLINK IggyPerfmonCreate(void *(*alloc_func)(unsigned long), void (*free_func)(void *), void *user) { + STUBBED; + return 0; +} +RADEXPFUNC inline void RADEXPLINK IggyInstallPerfmon(void *perfmon) { + STUBBED; +} + #endif // IGGYSTUBS_H \ No newline at end of file