M0' scaffold: Godot 4.7 + GDExtension + libgr2 wired up (macOS)

- extension/: godot-cpp submodule (master, API 4.7), Metin2Model node
  registered, links xrender-poc/libgr2 via sibling-dir reference.
- project/: Godot 4.7 project — orbit camera + DirectionalLight3D (shadows)
  + WorldEnvironment/procedural sky + placeholder cube; main.gd probes the
  extension and can run libgr2 on a real .gr2 (MTGODOT_PROBE_GR2).
- build.sh one-shot build into project/bin/.
- docs/GODOT-POC-PLAN.md (phased: Phase 1 macOS -> M0'/M1/M2/M2.5).

Verified on this machine:
  [mtgodot] Metin2Model registered OK — libgr2 linked
  probe_gr2(warrior_cheongrin.gr2) -> gr2 OK: format_version=6 sections=8
  Metal Forward+ renders the scene (test/golden/m0-scaffold.png).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WaHYEY9rwLWt21PULiYjeJ
This commit is contained in:
Claude
2026-08-29 09:09:55 +09:00
commit c52b8657c4
21 changed files with 839 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
# mtgodot GDExtension — M0' skeleton (registers Metin2Model, links libgr2).
# --- godot-cpp (submodule @ master) ---
# master has no per-minor branch; it ships bundled extension_api-4-*.json.
# Pin to 4.7 to match the installed editor (4.7.1; patch-level ABI is compatible).
set(GODOTCPP_API_VERSION "4.7" CACHE STRING "Target Godot API version" FORCE)
add_subdirectory(godot-cpp)
# --- libgr2 from the sibling xrender-poc repo ---
# M0': plain sibling-directory reference (both repos live under .../mt/).
# For a portable checkout, either git-submodule xrender-poc or vendor libgr2,
# then pass -DXRENDER_POC_DIR=/path/to/xrender-poc.
set(XRENDER_POC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../xrender-poc"
CACHE PATH "Path to the xrender-poc repo (provides libgr2)")
if(NOT EXISTS "${XRENDER_POC_DIR}/libgr2/CMakeLists.txt")
message(FATAL_ERROR
"libgr2 not found at '${XRENDER_POC_DIR}/libgr2'. "
"Pass -DXRENDER_POC_DIR=/path/to/xrender-poc")
endif()
add_subdirectory("${XRENDER_POC_DIR}/libgr2" "${CMAKE_CURRENT_BINARY_DIR}/libgr2")
# --- the extension shared library ---
add_library(mtgodot SHARED
src/register_types.cpp
src/metin2_model.cpp
)
target_compile_features(mtgodot PRIVATE cxx_std_20)
target_link_libraries(mtgodot PRIVATE godot::cpp xrender::libgr2)
# Drop the dylib straight into the Godot project where the .gdextension expects it:
# project/bin/libmtgodot.macos.template_debug.dylib (Debug)
# project/bin/libmtgodot.macos.template_release.dylib (Release)
set_target_properties(mtgodot PROPERTIES
PREFIX "lib"
OUTPUT_NAME "mtgodot.macos.$<IF:$<CONFIG:Release>,template_release,template_debug>"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/project/bin"
)