// engine.h - interface for the Titan engine core (the reconstruction target inside libg.so). // // The JNI boundary (native/src/libg/jni/titan_jni.cpp) forwards lifecycle / input / GL-config calls // into this interface. The real implementation is recovered from the stripped ARMv7 libg.so. // // 64-bit note: the Java side hands the engine a `jlong` handle in createGameMain(...) and // locationChanged(...). Store native pointers in that jlong (NOT jint) - it is already 64-bit-wide, // which is what makes this boundary arm64-safe. See analysis/JNI_MAP.md. #pragma once #include #include #include namespace titan { // Pixel/surface configuration the Java GLSurfaceView queries before creating the EGL context. struct SurfaceConfig { int surfaceFormat = 4; // getSurfaceFormat() (RGBA_8888-ish; placeholder) int depthBits = 16; // getDepthBits() int stencilBits = 8; // getStencilBits() int allowedRotations = 0;// getAllowedScreenRotations() }; class Engine { public: static Engine& instance(); // Called from JNI_OnLoad; caches the JavaVM for engine->Java up-calls. void onJniLoad(JavaVM* vm); // --- lifecycle (GameApp native methods) --- // createGameMain(AssetManager, docPath, ..., handle, w, h, ...): boots the engine and returns a // status/config string. Returns "" from the stub. `handle` is the 64-bit native handle carrier. std::string createGameMain(JNIEnv* env, jobject assetManager, const std::string& docPath, const std::string& a2, const std::string& a3, jlong handle, int w, int h, int i2, int i3); bool init(int w, int h, const std::string& path); void start(const std::string& arg); void stop(); void deinit(); bool update(); // per-frame tick // --- input --- void setTouch(int id, int action, int x, int y); void clearTouches(); // --- GL surface config queries --- SurfaceConfig surfaceConfig() const; private: Engine() = default; JavaVM* vm_ = nullptr; bool booted_ = false; }; } // namespace titan // Exposed to the JNI layer (defined in titan_jni.cpp): the cached JavaVM. extern "C" JavaVM* titan_get_vm();