### Camera Position Management Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source APIs for setting and getting the camera's position in 3D space. ```APIDOC ## POST /camera/position ### Description Sets the camera's position. ### Method POST ### Endpoint /camera/position ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **handle** (S3DCameraHandle) - Required - Handle to the camera. - **pos** (cS3DVector3) - Required - The new position for the camera. ### Request Example ```json { "handle": "some_camera_handle", "pos": { "x": 10.0, "y": 5.0, "z": 2.0 } } ``` ### Response #### Success Response (200) No specific data returned on success. ## GET /camera/position ### Description Gets the current camera position. ### Method GET ### Endpoint /camera/position ### Parameters #### Path Parameters None #### Query Parameters - **handle** (S3DCameraHandle) - Required - Handle to the camera. #### Request Body None ### Response #### Success Response (200) - **outPos** (cS3DVector3) - The current position of the camera. #### Response Example ```json { "outPos": { "x": 10.0, "y": 5.0, "z": 2.0 } } ``` ``` -------------------------------- ### Get API Version (C++) Source: https://caspervg.github.io/sc4-render-services-dll/cIGZImGuiService_8h_source Returns the version of the ImGui service API. This is useful for ensuring compatibility between the service and its clients. ```cpp virtual uint32_t GetApiVersion() const =0 ``` -------------------------------- ### Doxygen Class Inheritance Example Source: https://caspervg.github.io/sc4-render-services-dll/graph_legend Demonstrates Doxygen comments for documenting C++ classes and their inheritance relationships. This includes public, protected, and private inheritance, as well as template class instantiation. ```cpp /*! Invisible class because of truncation */ class Invisible { }; /*! Truncated class, inheritance relation is hidden */ class Truncated : public Invisible { }; /* Class not documented with doxygen comments */ class Undocumented { }; /*! Class that is inherited using public inheritance */ class PublicBase : public Truncated { }; /*! A template class */ template class Templ { }; /*! Class that is inherited using protected inheritance */ class ProtectedBase { }; /*! Class that is inherited using private inheritance */ class PrivateBase { }; /*! Class that is used by the Inherited class */ class Used { }; /*! Super class that inherits a number of other classes */ class Inherited : public PublicBase, protected ProtectedBase, private PrivateBase, public Undocumented, public Templ { private: Used *m_usedClass; }; ``` -------------------------------- ### Error Handling for Texture Creation and Retrieval (C++) Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README Provides an example of robust error handling for ImGui texture operations. It demonstrates checking the result of `CreateTexture` and `GetTextureID`, and using `IsTextureValid` to differentiate between device loss and stale handles. ```cpp // Creation can fail - check handle ImGuiTextureHandle handle = service->CreateTexture(desc); if (handle.id == 0) { LOG_ERROR("Texture creation failed"); return; } // GetTextureID returns nullptr on failure void* texId = service->GetTextureID(handle); if (!texId) { // Device lost, generation mismatch, or surface recreation failed // Check IsTextureValid() to distinguish: if (!service->IsTextureValid(handle)) { // Handle is stale (generation mismatch) // Need to create new texture } } ``` -------------------------------- ### Acquire DirectX 7 Interfaces (C++) Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README Demonstrates how to acquire and release DirectX 7 device and draw interfaces using cIGZImGuiService. It's crucial to release these interfaces after use to prevent memory leaks. The example shows a basic usage pattern within a conditional block. ```cpp IDirect3DDevice7* d3d = nullptr; IDirectDraw7* dd = nullptr; if (service->AcquireD3DInterfaces(&d3d, &dd)) { // use d3d/dd d3d->Release(); dd->Release(); } ``` -------------------------------- ### Matrix and Service Information Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZDrawService Functions for retrieving the model-view matrix, checking lighting status, and getting the service ID. ```APIDOC ## GetLighting() ### Description Checks if lighting is enabled. ### Method `virtual bool` ### Endpoint N/A (Internal function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (bool) Returns true if lighting is enabled, false otherwise. #### Response Example `true` or `false` ## GetModelViewMatrix() ### Description Retrieves the current model-view matrix. ### Method `virtual void` ### Endpoint N/A (Internal function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (void) N/A #### Response Example None ## GetServiceID() ### Description Returns the service ID (kDrawServiceID). ### Method `virtual uint32_t` ### Endpoint N/A (Internal function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (uint32_t) The service ID. #### Response Example `kDrawServiceID` ``` -------------------------------- ### Get ImGui Context (C++) Source: https://caspervg.github.io/sc4-render-services-dll/cIGZImGuiService_8h_source Returns a pointer to the underlying ImGui context. This is useful for direct interaction with the ImGui library. Returns nullptr if the ImGui context is not yet initialized or available. ```cpp virtual void * GetContext() const =0 ``` -------------------------------- ### Set Fog Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Configures fog settings for the draw context. Requires a handle, fog enable flag, fog color, start distance, and end distance. ```cpp virtual void SetFog(SC4DrawContextHandle handle, bool enableFog, float *fogColorRgb, float fogStart, float fogEnd)=0; ``` -------------------------------- ### Get ImGui Context Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZImGuiService This function, GetContext, retrieves a pointer to the ImGui context. It returns nullptr if the context is not yet ready. This is a const member function, indicating it does not modify the state of the cIGZImGuiService object. ```cpp virtual void * GetContext () const = 0; // Returns the ImGui context pointer, or nullptr if not ready. ``` -------------------------------- ### Get Service ID Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Retrieves the unique identifier for the rendering service. Returns a uint32_t. ```cpp virtual uint32_t GetServiceID() const =0; ``` -------------------------------- ### Device Generation Handling Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README Explains the device generation pattern and how to handle texture recreation after device resets (e.g., Alt+Tab). ```APIDOC ## Device Generation Handling ### Description Details the mechanism for tracking DirectX device resets and the implications for texture handles. Provides guidance on how to detect and respond to device generation changes to ensure textures remain valid. ### Method `cIGZImGuiService::GetDeviceGeneration()` retrieves the current device generation. The `ImGuiTexture` RAII wrapper handles this internally. ### Endpoint N/A ### Parameters None ### Request Example ```cpp void OnRender() { static uint32_t lastGen = 0; uint32_t currentGen = service->GetDeviceGeneration(); if (currentGen != lastGen) { // Device was reset - recreate textures RecreateMyTextures(); lastGen = currentGen; } // Use textures normally... } ``` ### Response `GetDeviceGeneration()` returns a `uint32_t` representing the current device generation. ### Error Handling When the device generation changes, previously obtained texture IDs may become invalid. The `ImGuiTexture` wrapper returns `nullptr` from `GetID()`, and manual API usage requires checking `IsTextureValid()` or recreating textures when a generation mismatch is detected. ``` -------------------------------- ### RAII Wrapper for ImGui Texture Creation and Rendering (C++) Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README Demonstrates the recommended RAII approach using the ImGuiTexture class for automatic lifetime management of textures. It shows how to create a texture with pixel data and retrieve its ID for rendering, handling device loss gracefully. ```cpp #include "public/ImGuiTexture.h" class MyPanel { cIGZImGuiService* service_; ImGuiTexture myTexture_; void OnInit() { // Generate RGBA32 pixel data (4 bytes per pixel) std::vector pixels(128 * 128 * 4); // ... fill pixel data ... // Create texture - automatically manages lifetime if (!myTexture_.Create(service_, 128, 128, pixels.data())) { // Handle error } } void OnRender() { // Get texture ID - returns nullptr if device was lost void* texId = myTexture_.GetID(); if (texId) { ImGui::Image(texId, ImVec2(128, 128)); } else { ImGui::TextUnformatted("Texture unavailable"); } } // Texture is automatically released in destructor }; ``` -------------------------------- ### ImGuiPanel OnInit Function Documentation (C++) Source: https://caspervg.github.io/sc4-render-services-dll/structImGuiPanel Documentation for the OnInit member function of the ImGuiPanel class in C++. This function is virtual and intended for initialization logic within the panel. ```cpp virtual void ImGuiPanel::OnInit() ``` -------------------------------- ### DrawPrims Function Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Draws primitives based on type, starting vertex, and primitive count. This function is part of the cIGZDrawService interface. ```cpp virtual void DrawPrims(SC4DrawContextHandle handle, uint32_t primType, uint32_t startVertex, uint32_t primitiveCount, uint32_t flags)=0; ``` -------------------------------- ### Initialize and Use S3D Camera Service Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2docs_2services Demonstrates how to obtain the S3D Camera Service, wrap the active renderer camera, and convert world coordinates to screen coordinates. It also shows the basic structure for releasing the service. ```cpp cIGZS3DCameraService* cameraService = nullptr; if (!fw->GetSystemService(kS3DCameraServiceID, GZIID_cIGZS3DCameraService, reinterpret_cast(&cameraService))) { return; } auto handle = cameraService->WrapActiveRendererCamera(); float sx = 0.0f; float sy = 0.0f; if (cameraService->WorldToScreen(handle, worldX, worldY, worldZ, sx, sy)) { // use screen coordinates } cameraService->Release(); ``` -------------------------------- ### Get Service ID Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZDrawService Returns the unique identifier for the drawing service. This is typically a constant value (kDrawServiceID). ```cpp virtual uint32_t cIGZDrawService::GetServiceID ( ) const ``` -------------------------------- ### Registering an ImGui Panel Using a Class-Based Adapter Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README This C++ code illustrates how to register an ImGui panel using a class-based approach with ImGuiPanelAdapter. It shows the definition of a custom panel class inheriting from ImGuiPanel and the registration process using cIGZFrameWork and cIGZImGuiService. ```cpp class MyPanel final : public ImGuiPanel { public: void OnInit() override {} void OnRender() override { ImGui::Begin("Class Panel"); ImGui::TextUnformatted("Hello from a class-based panel."); ImGui::End(); } }; void RegisterPanel(cIGZFrameWork* fw) { cIGZImGuiService* service = nullptr; if (!fw->GetSystemService(kImGuiServiceID, GZIID_cIGZImGuiService, reinterpret_cast(&service))) { return; } auto* panel = new MyPanel(); ImGuiPanelDesc desc = ImGuiPanelAdapter::MakeDesc(panel, 0x12345678, 100, true); if (!service->RegisterPanel(desc)) { delete panel; } service->Release(); } ``` -------------------------------- ### Manual API for ImGui Texture Creation and Rendering (C++) Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README Illustrates the manual API usage for creating and managing ImGui textures. This involves using ImGuiTextureDesc and ImGuiTextureHandle with the cIGZImGuiService, requiring explicit calls for creation, retrieval of texture ID, and release. ```cpp #include "public/cIGZImGuiService.h" // Create texture descriptor ImGuiTextureDesc desc{}; desc.width = 128; desc.height = 128; desc.pixels = myRGBA32Data; // Must remain valid during call desc.useSystemMemory = false; // Prefer video memory // Create texture - service stores pixel data internally ImGuiTextureHandle handle = service->CreateTexture(desc); if (handle.id == 0) { // Handle error } // In render loop: void* texId = service->GetTextureID(handle); if (texId) { ImGui::Image(texId, ImVec2(128, 128)); } // When done: service->ReleaseTexture(handle); ``` -------------------------------- ### Get Model-View Matrix Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZDrawService Retrieves the current model-view matrix. This matrix transforms object coordinates into camera coordinates. ```cpp virtual void cIGZDrawService::GetModelViewMatrix ( SC4DrawContextHandle _handle_ , void * _outMatrix4x4_ ) ``` -------------------------------- ### Registering an ImGui Panel Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2docs_2services Demonstrates how to register a new ImGui panel with the service. This involves obtaining the ImGui service interface, defining the panel descriptor, and calling the RegisterPanel method. The panel's render function is provided as a callback. ```cpp static void RenderPanel(void* data) { ImGui::Begin("My Panel"); ImGui::TextUnformatted("Hello from a client DLL."); ImGui::End(); } void RegisterPanel(cIGZFrameWork* fw) { cIGZImGuiService* service = nullptr; if (!fw->GetSystemService(kImGuiServiceID, GZIID_cIGZImGuiService, reinterpret_cast(&service))) { return; } ImGuiPanelDesc desc{}; desc.id = 0x12345678; desc.order = 100; desc.visible = true; desc.on_render = &RenderPanel; service->RegisterPanel(desc); service->Release(); } ``` -------------------------------- ### Acquire ImGui Service using C++ Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2docs_2services Demonstrates the common pattern for acquiring a service using cIGZFrameWork::GetSystemService. It shows how to obtain a pointer to the cIGZImGuiService, use it, and then release it. This pattern is applicable to other services as well. Note that the returned interface is AddRef'd and must be Release()'d by the caller. ```cpp cIGZImGuiService* service = nullptr; if (fw->GetSystemService(kImGuiServiceID, GZIID_cIGZImGuiService, reinterpret_cast(&service))) { // use service service->Release(); } ``` -------------------------------- ### Get Lighting State Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZDrawService Retrieves the current lighting state. Returns a boolean indicating whether lighting is enabled. ```cpp virtual bool cIGZDrawService::GetLighting ( SC4DrawContextHandle _handle_ ) ``` -------------------------------- ### Get Camera Position Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Retrieves the current position of the 3D camera. Requires a camera handle and an output parameter for the position vector. ```cpp virtual void GetPosition(S3DCameraHandle handle, cS3DVector3 &outPos)=0 ``` -------------------------------- ### Lighting and Fog Configuration in C++ Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Functions to query and set lighting states, as well as configure fog effects. SetLighting enables or disables lighting, while SetFog allows customization of fog color and density based on distance. ```cpp virtual bool GetLighting(SC4DrawContextHandle handle) = 0; virtual void SetLighting(SC4DrawContextHandle handle, bool enableLighting) = 0; virtual void SetFog(SC4DrawContextHandle handle, bool enableFog, float* fogColorRgb, float fogStart, float fogEnd) = 0; ``` -------------------------------- ### Rendering and Service Info Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZImGuiService APIs for queuing render callbacks, checking device readiness, and retrieving service information. ```APIDOC ## POST /render/queue ### Description Queues a render callback to execute on the next ImGui frame. The callback runs on the render thread between ImGui::NewFrame() and ImGui::EndFrame(). If a cleanup callback is provided, it is called after the render callback (or during shutdown) to free associated data. ### Method POST ### Endpoint `/render/queue` ### Parameters #### Request Body - **callback** (ImGuiRenderCallback) - Required - The function to call for rendering. - **data** (void*) - Optional - Data to pass to the callback function. - **cleanup** (ImGuiRenderCleanup) - Optional - A function to call for cleaning up data after rendering or during shutdown. ### Request Example ```json { "callback": "myRenderFunction", "data": "0xABCDEF01", "cleanup": "myCleanupFunction" } ``` ### Response #### Success Response (200) - **success** (bool) - True if the render callback was queued successfully, false otherwise. #### Response Example ```json { "success": true } ``` ## GET /service/ready ### Description Returns true when the DX7 interfaces are ready for use. ### Method GET ### Endpoint `/service/ready` ### Response #### Success Response (200) - **isReady** (bool) - True if the device is ready, false otherwise. #### Response Example ```json { "isReady": true } ``` ## GET /service/id ### Description Returns the service ID (kImGuiServiceID). ### Method GET ### Endpoint `/service/id` ### Response #### Success Response (200) - **serviceId** (uint32_t) - The unique identifier for the ImGui service. #### Response Example ```json { "serviceId": 12345 } ``` ``` -------------------------------- ### Get Camera Projection Type Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Retrieves the current projection type (e.g., perspective, orthographic) of a given camera. Requires a camera handle. ```cpp virtual int GetProjectionType(S3DCameraHandle handle)=0 ``` -------------------------------- ### cIGZDrawService::InitContext Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Initializes the drawing context. ```APIDOC ## POST /InitContext ### Description Initializes the drawing context. ### Method POST ### Endpoint /InitContext ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **handle** (SC4DrawContextHandle) - Required - Handle to the drawing context to initialize. ### Request Example ```json { "handle": "SC4DrawContextHandle_value" } ``` ### Response #### Success Response (200) This method does not return a value. #### Response Example (No specific response body for success) ``` -------------------------------- ### Get Texture ID (C++) Source: https://caspervg.github.io/sc4-render-services-dll/cIGZImGuiService_8h_source Retrieves the underlying device-specific texture identifier from an ImGui texture handle. This can be used for low-level graphics API interactions. ```cpp virtual void * GetTextureID(ImGuiTextureHandle handle)=0 ``` -------------------------------- ### SC4 Render Services DLL - Version and Handles Source: https://caspervg.github.io/sc4-render-services-dll/functions Information regarding versioning and handles for camera and draw contexts. ```APIDOC ## SC4 Render Services DLL - Version and Handles ### Description Provides access to version information and handles for camera and draw contexts. ### Properties - version : S3DCameraHandle, SC4DrawContextHandle ### Parameters (Not applicable for property descriptions) ### Request Example (Not applicable for property descriptions) ### Response (Not applicable for property descriptions) ``` -------------------------------- ### Get Camera Look-At Vector Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Retrieves the direction vector that the camera is currently looking at. Requires a camera handle and an output parameter for the look-at vector. ```cpp virtual void GetLookAt(S3DCameraHandle handle, cS3DVector3 &outLookAt)=0 ``` -------------------------------- ### Texture Management Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZImGuiService APIs for handling texture resources, including getting texture IDs, checking validity, releasing textures, and managing texture handles. ```APIDOC ## GET /textures/{handle} ### Description Gets a texture ID for use with ImGui::Image(). Returns nullptr if the handle is invalid or from a stale device generation. The texture surface is recreated on-demand if the device was lost. This function must be called from the render thread only. ### Method GET ### Endpoint `/textures/{handle}` ### Parameters #### Path Parameters - **handle** (ImGuiTextureHandle) - Required - The handle of the texture. ### Response #### Success Response (200) - **textureId** (void*) - A pointer to the texture ID, or nullptr if the handle is invalid or from a stale device generation. #### Response Example ```json { "textureId": "0xABCD1234" } ``` ## GET /textures/validity/{handle} ### Description Checks if a texture handle is valid and matches the current device generation. This function must be called from the render thread only. ### Method GET ### Endpoint `/textures/validity/{handle}` ### Parameters #### Path Parameters - **handle** (ImGuiTextureHandle) - Required - The handle of the texture to check. ### Response #### Success Response (200) - **isValid** (bool) - True if the texture handle is valid, false otherwise. #### Response Example ```json { "isValid": true } ``` ## DELETE /textures/{handle} ### Description Releases a texture and frees associated resources. This operation is safe to call with invalid handles (it will be a no-op). This function must be called from the render thread only. ### Method DELETE ### Endpoint `/textures/{handle}` ### Parameters #### Path Parameters - **handle** (ImGuiTextureHandle) - Required - The handle of the texture to release. ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the texture was released or the handle was invalid. #### Response Example ```json { "message": "Texture released successfully." } ``` ``` -------------------------------- ### Registering a Minimal ImGui Panel Function Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README This C++ snippet shows the minimal way to register an ImGui panel using a standalone render function. It defines the render function and then uses cIGZImGuiService to register it with a specific ID, order, and visibility. ```cpp static void RenderPanel(void* data) { ImGui::Begin("My Panel"); ImGui::TextUnformatted("Hello from a client DLL."); ImGui::End(); } void RegisterPanel(cIGZFrameWork* fw) { cIGZImGuiService* service = nullptr; if (!fw->GetSystemService(kImGuiServiceID, GZIID_cIGZImGuiService, reinterpret_cast(&service))) { return; } ImGuiPanelDesc desc{}; desc.id = 0x12345678; desc.order = 100; desc.visible = true; desc.on_render = &RenderPanel; desc.on_shutdown = nullptr; desc.data = nullptr; service->RegisterPanel(desc); service->Release(); } ``` -------------------------------- ### Get Service ID (C++) Source: https://caspervg.github.io/sc4-render-services-dll/cIGZImGuiService_8h_source Returns the unique service ID for the ImGui service. This is typically a constant value (kImGuiServiceID) used for identification within the system. ```cpp virtual uint32_t GetServiceID() const =0 ``` -------------------------------- ### Include Headers for ImGuiPanelAdapter Source: https://caspervg.github.io/sc4-render-services-dll/ImGuiPanelAdapter_8h This snippet shows the necessary header files to include for using ImGuiPanelAdapter.h. It demonstrates standard C++ type traits and project-specific service and panel headers. ```cpp #include #include "public/cIGZImGuiService.h" #include "public/ImGuiPanel.h" ``` -------------------------------- ### Get Camera View State Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Returns the current view state of the camera. The meaning of the returned integer value depends on the specific implementation of the camera service. ```cpp virtual int GetViewState(S3DCameraHandle handle)=0 ``` -------------------------------- ### Panel Registration and Callbacks Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2docs_2services This section covers the registration of ImGui panels and the various callback functions that can be implemented to handle panel lifecycle events. ```APIDOC ## POST /ImGuiService/RegisterPanel ### Description Registers a panel with the ImGui service. The service will manage the lifecycle and rendering of the registered panel. ### Method POST ### Endpoint /ImGuiService/RegisterPanel ### Parameters #### Request Body - **desc** (ImGuiPanelDesc) - Required - Descriptor for the ImGui panel, including its ID, order, visibility, and callback functions. ### Request Example ```json { "desc": { "id": 12345678, "order": 100, "visible": true, "on_init": "function_pointer", "on_update": "function_pointer", "on_render": "function_pointer", "on_visible_changed": "function_pointer", "on_shutdown": "function_pointer", "on_unregister": "function_pointer", "on_device_lost": "function_pointer", "on_device_restored": "function_pointer" } } ``` ### Response #### Success Response (200) - **success** (boolean) - True if the panel was registered successfully, false otherwise (e.g., duplicate ID). #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Context and Camera Management in C++ Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Functions for initializing and shutting down the rendering context, and for setting the active camera. InitContext and ShutdownContext manage the lifecycle of the rendering environment. ```cpp virtual void SetCamera(SC4DrawContextHandle handle, int camera) = 0; virtual void InitContext(SC4DrawContextHandle handle) = 0; virtual void ShutdownContext(SC4DrawContextHandle handle) = 0; ``` -------------------------------- ### Renderer Draw Functions in C++ Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Functions for initiating rendering operations. RendererDraw starts the main rendering process, while RendererDrawPostDynamicView performs rendering after dynamic views are processed. ```cpp virtual uint32_t RendererDraw() = 0; virtual void RendererDrawPostDynamicView() = 0; ``` -------------------------------- ### Get Font by ID (C++) Source: https://caspervg.github.io/sc4-render-services-dll/cIGZImGuiService_8h_source Retrieves a pointer to an ImFont object associated with a given font ID. Returns nullptr if the font ID is not registered. This function is part of the cIGZImGuiService interface. ```cpp virtual void * GetFont(uint32_t fontId) const =0 ``` -------------------------------- ### Create Camera Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Attempts to create a new camera. This function is not supported by the built-in service and will return a null handle. ```cpp virtual S3DCameraHandle CreateCamera()=0 ``` -------------------------------- ### Draw Primitives Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZDrawService Draws a sequence of primitives based on vertex data. It supports different primitive types and allows specifying the start vertex and primitive count. ```cpp virtual void | DrawPrims (SC4DrawContextHandle handle, uint32_t primType, uint32_t startVertex, uint32_t primitiveCount, uint32_t flags)=0 ``` -------------------------------- ### Camera Lifecycle Management Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source APIs for creating, destroying, and managing camera handles. ```APIDOC ## POST /camera/create ### Description Creates a new camera. Note: Not supported by the built-in service; returns a null handle. ### Method POST ### Endpoint /camera/create ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **handle** (S3DCameraHandle) - The handle to the newly created camera (or null if not supported). #### Response Example ```json { "handle": "new_camera_handle_123" } ``` ## POST /camera/destroy ### Description Destroys a camera created by the service. No-op for wrapped cameras. ### Method POST ### Endpoint /camera/destroy ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **handle** (S3DCameraHandle) - Required - Handle to the camera to destroy. ### Request Example ```json { "handle": "camera_handle_to_destroy" } ``` ### Response #### Success Response (200) No specific data returned on success. ## POST /camera/wrap ### Description Wraps an existing camera pointer with a service handle. ### Method POST ### Endpoint /camera/wrap ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **existingCameraPtr** (void*) - Required - Pointer to the existing camera object. ### Request Example ```json { "existingCameraPtr": "0x12345678" } ``` ### Response #### Success Response (200) - **handle** (S3DCameraHandle) - The handle to the wrapped camera. #### Response Example ```json { "handle": "wrapped_camera_handle_456" } ``` ``` -------------------------------- ### Get View Transform Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Returns a constant pointer to the camera's view transformation matrix. This matrix defines the camera's orientation and position in world space. Requires a camera handle. ```cpp virtual const cS3DTransform * GetViewTransform(S3DCameraHandle handle)=0 ``` -------------------------------- ### Camera Configuration Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source APIs for configuring camera properties like projection, viewport, and view volume. ```APIDOC ## POST /camera/projection/ortho ### Description Sets an orthographic projection for the camera. ### Method POST ### Endpoint /camera/projection/ortho ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **handle** (S3DCameraHandle) - Required - Handle to the camera. - **left** (float) - Required - The left clipping plane. - **right** (float) - Required - The right clipping plane. - **bottom** (float) - Required - The bottom clipping plane. - **top** (float) - Required - The top clipping plane. - **nearPlane** (float) - Required - The near clipping plane. - **farPlane** (float) - Required - The far clipping plane. ### Request Example ```json { "handle": "some_camera_handle", "left": -10.0, "right": 10.0, "bottom": -5.0, "top": 5.0, "nearPlane": 0.1, "farPlane": 100.0 } ``` ### Response #### Success Response (200) No specific data returned on success. ## POST /camera/viewport ### Description Sets the viewport size for the camera. ### Method POST ### Endpoint /camera/viewport ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **handle** (S3DCameraHandle) - Required - Handle to the camera. - **width** (float) - Required - The width of the viewport. - **height** (float) - Required - The height of the viewport. ### Request Example ```json { "handle": "some_camera_handle", "width": 800.0, "height": 600.0 } ``` ### Response #### Success Response (200) No specific data returned on success. ## POST /camera/subview ### Description Sets a sub-viewport rectangle for the camera. ### Method POST ### Endpoint /camera/subview ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **handle** (S3DCameraHandle) - Required - Handle to the camera. - **left** (float) - Required - The left coordinate of the sub-viewport. - **top** (float) - Required - The top coordinate of the sub-viewport. - **right** (float) - Required - The right coordinate of the sub-viewport. - **bottom** (float) - Required - The bottom coordinate of the sub-viewport. ### Request Example ```json { "handle": "some_camera_handle", "left": 0.1, "top": 0.1, "right": 0.9, "bottom": 0.9 } ``` ### Response #### Success Response (200) No specific data returned on success. ## POST /camera/viewport-offset ### Description Sets the viewport offset for the camera. ### Method POST ### Endpoint /camera/viewport-offset ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **handle** (S3DCameraHandle) - Required - Handle to the camera. - **offset** (cS3DVector2) - Required - The offset vector for the viewport. ### Request Example ```json { "handle": "some_camera_handle", "offset": { "x": 10.0, "y": 20.0 } } ``` ### Response #### Success Response (200) No specific data returned on success. ## GET /camera/view-volume ### Description Gets the view volume parameters of the camera. ### Method GET ### Endpoint /camera/view-volume ### Parameters #### Path Parameters None #### Query Parameters - **handle** (S3DCameraHandle) - Required - Handle to the camera. #### Request Body None ### Response #### Success Response (200) - **left** (float) - The left boundary of the view volume. - **right** (float) - The right boundary of the view volume. - **bottom** (float) - The bottom boundary of the view volume. - **top** (float) - The top boundary of the view volume. - **nearPlane** (int) - The near clipping plane distance. - **farPlane** (int) - The far clipping plane distance. #### Response Example ```json { "left": -10.0, "right": 10.0, "bottom": -5.0, "top": 5.0, "nearPlane": 1, "farPlane": 100 } ``` ``` -------------------------------- ### Render Model Instance Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Renders a model instance. Requires a handle, model counts and lists, draw information, and a preview-only flag. ```cpp virtual void RenderModelInstance(SC4DrawContextHandle handle, int *modelCount, int *modelList, uint8_t *drawInfo, bool previewOnly)=0; ``` -------------------------------- ### Initialize Draw Context Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Initializes the draw context. Requires a handle. ```cpp virtual void InitContext(SC4DrawContextHandle handle)=0; ``` -------------------------------- ### Get View Volume Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Retrieves the parameters defining the camera's view frustum (left, right, bottom, top, near plane, far plane). Requires a camera handle and output pointers for each parameter. ```cpp virtual void GetViewVolume(S3DCameraHandle handle, float *left, float *right, float *bottom, float *top, int *nearPlane, int *farPlane)=0 ``` -------------------------------- ### Panel Management Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZImGuiService APIs for registering, unregistering, and controlling the visibility of ImGui panels. ```APIDOC ## POST /panels/register ### Description Registers a panel. Returns false on duplicate ID or missing callbacks. ### Method POST ### Endpoint `/panels/register` ### Parameters #### Request Body - **desc** (ImGuiPanelDesc) - Required - A description object containing panel details, including its ID and callbacks. ### Request Example ```json { "desc": { "panelId": 1, "drawCallback": "myDrawCallback", "updateCallback": "myUpdateCallback" } } ``` ### Response #### Success Response (200) - **success** (bool) - True if the panel was registered successfully, false otherwise. #### Response Example ```json { "success": true } ``` ## DELETE /panels/{panelId} ### Description Unregisters a panel by its ID. Returns false if the panel ID is not found. ### Method DELETE ### Endpoint `/panels/{panelId}` ### Parameters #### Path Parameters - **panelId** (uint32_t) - Required - The ID of the panel to unregister. ### Response #### Success Response (200) - **success** (bool) - True if the panel was unregistered successfully, false otherwise. #### Response Example ```json { "success": true } ``` ## PUT /panels/{panelId}/visibility ### Description Sets a panel's visibility. Returns false if the panel ID is not found. ### Method PUT ### Endpoint `/panels/{panelId}/visibility` ### Parameters #### Path Parameters - **panelId** (uint32_t) - Required - The ID of the panel to modify. #### Request Body - **visible** (bool) - Required - The desired visibility state for the panel (true for visible, false for hidden). ### Request Example ```json { "visible": false } ``` ### Response #### Success Response (200) - **success** (bool) - True if the panel's visibility was set successfully, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Device Generation Tracking for Texture Recreation (C++) Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README Shows how to manually track DirectX device generation changes to recreate textures after device reset. It involves comparing the current device generation with the last known generation and calling a texture recreation function if they differ. ```cpp void OnRender() { static uint32_t lastGen = 0; uint32_t currentGen = service->GetDeviceGeneration(); if (currentGen != lastGen) { // Device was reset - recreate textures RecreateMyTextures(); lastGen = currentGen; } // Use textures normally... } ``` -------------------------------- ### Draw Indexed Primitives Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZDrawService Draws primitives using an index buffer. This method is efficient for drawing complex geometry with shared vertices. It specifies the primitive type, index start, and index count. ```cpp virtual void | DrawPrimsIndexed (SC4DrawContextHandle handle, uint8_t primType, long indexStart, long indexCount)=0 ``` -------------------------------- ### Get Device Generation Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZImGuiService This function, GetDeviceGeneration, returns an identifier for the current generation of the DX7 device. The generation number increases when the DX7 device or context is reinitialized. Callers are advised to rebuild any cached textures when this value changes. ```cpp virtual uint32_t GetDeviceGeneration () const = 0; // Generation increments when the DX7 device/context is reinitialized. ``` -------------------------------- ### Acquiring Direct3D 7 Interfaces Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2docs_2services Shows how to acquire AddRef'd IDirect3DDevice7 and IDirectDraw7 pointers from the ImGui service. It's crucial to release these interfaces when they are no longer needed to prevent resource leaks. Prefer acquiring these interfaces per operation rather than caching them across frames. ```cpp // Assuming 'service' is a valid cIGZImGuiService pointer IDirect3DDevice7* d3d_device = nullptr; IDirectDraw7* ddraw_device = nullptr; if (service->AcquireD3DInterfaces(&d3d_device, &ddraw_device)) { // Use d3d_device and ddraw_device here // Remember to release them when done: if (d3d_device) { d3d_device->Release(); } if (ddraw_device) { ddraw_device->Release(); } } ``` -------------------------------- ### cIGZImGuiService Interface Functions Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZImGuiService This snippet lists the core functions of the cIGZImGuiService interface, including getting service information, managing panels, handling textures, and registering/unregistering fonts. It highlights functions that are pure virtual and intended for specific threading contexts. ```cpp #include // Example usage (conceptual): // uint32_t serviceId = imguiService->GetServiceID(); // bool registered = imguiService->RegisterPanel(panelDesc); // ImGuiTextureHandle textureHandle = imguiService->CreateTexture(textureDesc); // void* font = imguiService->GetFont(fontId); ``` -------------------------------- ### Render Queue Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2docs_2services Details on how to queue one-shot rendering callbacks to be executed on the next frame. ```APIDOC ## POST /ImGuiService/QueueRender ### Description Queues a one-shot callback function to be executed on the render thread during the next frame's ImGui rendering cycle. An optional cleanup callback can also be provided. ### Method POST ### Endpoint /ImGuiService/QueueRender ### Parameters #### Request Body - **callback** (function_pointer) - Required - The callback function to execute. - **cleanup** (function_pointer) - Optional - A callback function to execute after the main callback or during service shutdown if the callback is still queued. ### Request Example ```json { "callback": "&MyRenderCallback", "cleanup": "&MyCleanupCallback" } ``` ### Response #### Success Response (200) - **queued** (boolean) - True if the render callback was successfully queued. #### Response Example ```json { "queued": true } ``` ``` -------------------------------- ### Set Fog - cIGZDrawService Source: https://caspervg.github.io/sc4-render-services-dll/classcIGZDrawService-members Configures fogging parameters for rendering. This pure virtual function from cIGZDrawService allows enabling or disabling fog, setting its color, start distance, and end distance. It requires a draw context handle and relevant fog parameters. ```cpp SetFog(SC4DrawContextHandle handle, bool enableFog, float *fogColorRgb, float fogStart, float fogEnd)=0| cIGZDrawService| pure virtual ``` -------------------------------- ### ImGuiPanelAdapter Lifecycle Functions Source: https://caspervg.github.io/sc4-render-services-dll/structImGuiPanelAdapter This snippet details the static lifecycle management functions for ImGuiPanelAdapter: OnInit, OnRender, OnUpdate, OnShutdown, and OnUnregister. These functions are called at specific points in the ImGui panel's lifecycle to handle initialization, rendering, updates, shutdown, and unregistration. ```cpp template, int > = 0> static void ImGuiPanelAdapter< T, >::OnInit(void * _data_) template, int > = 0> static void ImGuiPanelAdapter< T, >::OnRender(void * _data_) template, int > = 0> static void ImGuiPanelAdapter< T, >::OnShutdown(void * _data_) template, int > = 0> static void ImGuiPanelAdapter< T, >::OnUnregister(void * _data_) template, int > = 0> static void ImGuiPanelAdapter< T, >::OnUpdate(void * _data_) ``` -------------------------------- ### Get Eye Ray from Screen Position Source: https://caspervg.github.io/sc4-render-services-dll/cIGZS3DCameraService_8h_source Retrieves the origin and direction of the eye ray originating from a specific screen position. This is essential for raycasting and picking operations. Requires a camera handle, the screen position, and output parameters for the ray origin and direction. ```cpp virtual void GetEyeRay(S3DCameraHandle handle, const cS3DVector2 &screenPos, cS3DVector3 &outRayOrigin, cS3DVector3 &outRayDirection)=0 ``` -------------------------------- ### cIGZDrawService - Transparency and Callbacks Source: https://caspervg.github.io/sc4-render-services-dll/cIGZDrawService_8h_source Methods for managing transparency effects and registering/unregistering draw pass callbacks. ```APIDOC ## cIGZDrawService - Transparency and Callbacks ### Description Manages transparency settings and allows for the registration and unregistration of callbacks for different render passes. ### Methods #### SetTransparency * **Description**: Sets the transparency mode. * **Signature**: `virtual void SetTransparency(SC4DrawContextHandle handle) = 0;` #### ResetTransparency * **Description**: Resets the transparency settings. * **Signature**: `virtual void ResetTransparency(SC4DrawContextHandle handle) = 0;` #### UnregisterDrawPassCallback * **Description**: Unregisters a previously registered draw pass callback using its token. * **Parameters**: * `token` (uint32_t) - Required - The token of the callback to unregister. * **Signature**: `virtual void UnregisterDrawPassCallback(uint32_t token)=0;` ``` -------------------------------- ### SC4 Render Services DLL - Object Lifecycle Source: https://caspervg.github.io/sc4-render-services-dll/functions Details about the lifecycle management of ImGui objects. ```APIDOC ## ImGui Object Lifecycle ### Description Destructor functions for ImGui objects. ### Methods - ~ImGuiPanel() - ~ImGuiTexture() ### Parameters (Not applicable for destructor descriptions) ### Request Example (Not applicable for destructor descriptions) ### Response (Not applicable for destructor descriptions) ``` -------------------------------- ### ImGuiTexture RAII Wrapper Source: https://caspervg.github.io/sc4-render-services-dll/md__2home_2runner_2work_2sc4-render-services-dll_2sc4-render-services-dll_2README Recommended usage of the `ImGuiTexture` class for automatic texture lifetime management, including creation and retrieval of texture IDs. ```APIDOC ## ImGuiTexture RAII Wrapper ### Description Provides an RAII wrapper for managing `ImGuiTexture` objects, simplifying texture creation, lifetime management, and handling device loss. ### Method Constructor/Destructor for lifetime management. `Create()` for initialization, `GetID()` for retrieving the texture identifier. ### Endpoint N/A (Class-based API) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp #include "public/ImGuiTexture.h" class MyPanel { cIGZImGuiService* service_; ImGuiTexture myTexture_; void OnInit() { // Generate RGBA32 pixel data (4 bytes per pixel) std::vector pixels(128 * 128 * 4); // ... fill pixel data ... // Create texture - automatically manages lifetime if (!myTexture_.Create(service_, 128, 128, pixels.data())) { // Handle error } } void OnRender() { // Get texture ID - returns nullptr if device was lost void* texId = myTexture_.GetID(); if (texId) { ImGui::Image(texId, ImVec2(128, 128)); } else { ImGui::TextUnformatted("Texture unavailable"); } } // Texture is automatically released in destructor }; ``` ### Response #### Success Response (200) `ImGuiTexture::Create()` returns `true` on success, `false` on failure. `ImGuiTexture::GetID()` returns a `void*` texture identifier on success, or `nullptr` if the device was lost or the texture is unavailable. #### Response Example ```json { "textureId": "pointer_to_texture_data" } ``` ### Error Handling - `Create()` returns `false` if texture creation fails. - `GetID()` returns `nullptr` if the device has been reset or lost. ```