### Key Callback Implementation Example (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox An example implementation of a key callback function. This function is triggered by keyboard events and can be used to perform actions based on specific key presses, such as activating a feature when the 'E' key is pressed. ```c void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { if (key == GLFW_KEY_E && action == GLFW_PRESS) activate_airship(); } ``` -------------------------------- ### Example Gamepad Mapping Format (Unparsed) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox An example of a gamepad mapping line, demonstrating the structure for GUID, name, platform, button mappings, and axis mappings. This format is defined by SDL and SDL_GameControllerDB. ```unparsed 78696e70757401000000000000000000,XInput Gamepad (GLFW),platform:Windows,a:b0, b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,back:b6,start:b7,leftstick:b8, rightstick:b9,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4, righttrigger:a5,dpup:h0.1,dpright:h0.2,dpdown:h0.4,dpleft:h0.8, ``` -------------------------------- ### Load and Use OpenGL Extension Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/context.dox This comprehensive example combines checking for extension support, fetching the function pointer, and then conditionally calling the extension function. It includes defining the function pointer type and a flag to track support. ```c #define GLFW_INCLUDE_GLEXT #include #define glGetDebugMessageLogARB pfnGetDebugMessageLog PFNGLGETDEBUGMESSAGELOGARBPROC pfnGetDebugMessageLog; // Flag indicating whether the extension is supported int has_ARB_debug_output = 0; void load_extensions(void) { if (glfwExtensionSupported("GL_ARB_debug_output")) { pfnGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGARBPROC) glfwGetProcAddress("glGetDebugMessageLogARB"); has_ARB_debug_output = 1; } } void some_function(void) { if (has_ARB_debug_output) { // Now the extension function can be called as usual glGetDebugMessageLogARB(...); } } ``` -------------------------------- ### Window Minimize/Maximize Example Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/TODO.txt Adds support for window minimize and maximize functionality to the examples. This demonstrates how to handle standard window state changes. ```c++ // examples: window minimize, maximize (#583) ``` -------------------------------- ### Virtual Scrolling Example Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/TODO.txt Includes an example demonstrating virtual scrolling. This showcases how to implement efficient scrolling for large datasets. ```c++ // demo: add a virtual scrolling example? ``` -------------------------------- ### Zero-Framerate/Idle Example Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/TODO.txt Provides an example application that runs at zero framerate or idles. This is useful for testing performance and resource usage under low-activity conditions. ```c++ // examples: provide a zero-framerate/idle example. ``` -------------------------------- ### Initialize and Terminate GLFW Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/quick.dox Demonstrates the initialization and termination of the GLFW library. Initialization must occur before most GLFW functions can be used, returning GLFW_TRUE on success and GLFW_FALSE on failure. Termination releases all GLFW resources and must be followed by re-initialization if further GLFW functions are needed. ```c if (!glfwInit()) { // Initialization failed } ``` ```c glfwTerminate(); ``` -------------------------------- ### Define Example Executables Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/examples/CMakeLists.txt Defines multiple example executables for GLFW, specifying their source files, icon, and platform-specific bundle options. This allows for building and running various GLFW demos. ```cmake set(GLAD "${GLFW_SOURCE_DIR}/deps/glad/glad.h" "${GLFW_SOURCE_DIR}/deps/glad.c") set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" "${GLFW_SOURCE_DIR}/deps/getopt.c") set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" "${GLFW_SOURCE_DIR}/deps/tinycthread.c") add_executable(boing WIN32 MACOSX_BUNDLE boing.c ${ICON} ${GLAD}) add_executable(gears WIN32 MACOSX_BUNDLE gears.c ${ICON} ${GLAD}) add_executable(heightmap WIN32 MACOSX_BUNDLE heightmap.c ${ICON} ${GLAD}) add_executable(offscreen offscreen.c ${ICON} ${GLAD}) add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD} ${GETOPT} ${GLAD}) add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD}) add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD}) add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD}) ``` -------------------------------- ### Get Current Context (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/context.dox Demonstrates how to retrieve the window whose OpenGL or OpenGL ES context is current for the calling thread. This is useful for querying the current context or ensuring the correct context is active. ```c GLFWwindow* window = glfwGetCurrentContext(); ``` -------------------------------- ### Retrieving Vulkan Functions Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/vulkan.dox Demonstrates how to retrieve Vulkan device-specific function pointers using `glfwGetInstanceProcAddress`. ```APIDOC ## GET glfwGetInstanceProcAddress ### Description Retrieves a Vulkan function pointer from an instance. Device-specific functions may offer performance benefits. ### Method GET ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr = (PFN_vkGetDeviceProcAddr) glfwGetInstanceProcAddress(instance, "vkGetDeviceProcAddr"); ``` ### Response #### Success Response (200) - **pfnGetDeviceProcAddr** (PFN_vkGetDeviceProcAddr) - Pointer to the requested Vulkan function. #### Response Example ```json { "example": "Pointer to vkGetDeviceProcAddr function" } ``` ``` -------------------------------- ### Viewport Setup with Framebuffer Size (GLFW 2 vs GLFW 3) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/moving.dox Shows how to set up the OpenGL viewport using window size in GLFW 2 versus using framebuffer size in GLFW 3. GLFW 3 separates window coordinates from pixel coordinates, requiring `glfwGetFramebufferSize` for accurate viewport dimensions. ```c glfwGetWindowSize(&width, &height); glViewport(0, 0, width, height); ``` ```c glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); ``` -------------------------------- ### Build on Mac OS X with Homebrew and sdl2-config Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/examples/sdl_opengl3_example/README.md Builds the project on Mac OS X after installing SDL2 via Homebrew. It uses `sdl2-config` for compiler and linker flags and links against the OpenGL and CoreFoundation frameworks. Ensure Homebrew and SDL2 are installed. ```bash brew install sdl2 c++ `sdl2-config --cflags` -I ../.. -I ../libs/gl3w main.cpp imgui_impl_sdl_gl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -framework OpenGl -framework CoreFoundation -o sdl2example ``` -------------------------------- ### Create GLFW Window and Context Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/quick.dox Creates a window and its associated OpenGL context using glfwCreateWindow. The function takes dimensions, title, and optional monitor and share parameters. It returns a handle to the window or NULL if creation fails. Window and context creation can be influenced by setting GLFW window hints before calling this function. ```c GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); if (!window) { // Window or OpenGL context creation failed } ``` ```c glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); if (!window) { // Window or context creation failed } ``` -------------------------------- ### Installing GLFW Project Files (CMake) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/CMakeLists.txt This CMake block defines the installation rules for the GLFW project when the `GLFW_INSTALL` option is enabled. It installs header files, configuration files, export targets, pkgconfig files, and generates an uninstall target. ```cmake if (GLFW_INSTALL) install(DIRECTORY include/GLFW DESTINATION include FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h) install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake" "${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake" DESTINATION "${GLFW_CONFIG_PATH}") install(EXPORT glfwTargets FILE glfw3Targets.cmake EXPORT_LINK_INTERFACE_LIBRARIES DESTINATION "${GLFW_CONFIG_PATH}") install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" DESTINATION "lib${LIB_SUFFIX}/pkgconfig") if (NOT TARGET uninstall) configure_file(cmake_uninstall.cmake.in cmake_uninstall.cmake IMMEDIATE @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${GLFW_BINARY_DIR}/cmake_uninstall.cmake") endif() endif() ``` -------------------------------- ### Monitor and Context Creation Hints Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Hints related to monitor refresh rates for fullscreen windows and the client API for context creation. ```APIDOC ## Monitor and Context Creation Hints ### Description These hints configure monitor-specific settings for fullscreen windows and specify the client API for which the OpenGL context should be created. ### Method N/A (Configuration hints) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ## Window Hint Details: - **GLFW_REFRESH_RATE** (int) - Desired refresh rate for fullscreen windows. `GLFW_DONT_CARE` for the highest available. Ignored for windowed mode. - **GLFW_CLIENT_API** (int) - Specifies the client API for the context. Possible values: `GLFW_OPENGL_API`, `GLFW_OPENGL_ES_API`, `GLFW_NO_API`. (Hard constraint) - **GLFW_CONTEXT_CREATION_API** (int) - Specifies the context creation API. Possible values: `GLFW_NATIVE_CONTEXT_API`, `GLFW_EGL_CONTEXT_API`, `GLFW_OSMESA_CONTEXT_API`. (Hard constraint, ignored if no client API is requested) ``` -------------------------------- ### Buffer Swapping API Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Documentation for functions related to buffer swapping, including `glfwSwapBuffers` and `glfwSwapInterval`. ```APIDOC ## Buffer Swapping ### Description Manages the swapping of front and back rendering buffers to display rendered frames and controls the timing of these swaps. ### `glfwSwapBuffers` Swaps the back buffer with the front buffer to display the rendered content. #### Usage ```cglfwSwapBuffers(window); ``` ### `glfwSwapInterval` Sets the minimum number of monitor refreshes to wait before swapping buffers after `glfwSwapBuffers` is called. #### Parameters - **interval** (integer) - The minimum number of refresh intervals to wait. A value of 0 means the swap will occur immediately. A value of 1 waits for one refresh cycle, avoiding tearing. #### Usage ```cglfwSwapInterval(1); ``` **Note:** The behavior of `glfwSwapInterval` may be overridden by system-specific driver settings. ``` -------------------------------- ### Get Timer Value Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/quick.dox Retrieves the value of the GLFW timer, which returns the number of seconds since initialization. This is useful for creating smooth animations and time-based events. ```c double time = glfwGetTime(); ``` -------------------------------- ### Time Input API Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Provides functions to get and set the high-resolution timer value in seconds. ```APIDOC ## GET /time ### Description Retrieves the current value of the high-resolution timer in seconds. ### Method GET ### Endpoint /time ### Response #### Success Response (200) - **seconds** (double) - The number of seconds since the timer was started. #### Response Example ```json { "seconds": 12345.6789 } ``` ## PUT /time ### Description Sets the reference time of the high-resolution timer to a specified value. ### Method PUT ### Endpoint /time ### Parameters #### Request Body - **seconds** (double) - Required - The time in seconds to set the timer to. ### Request Example ```json { "seconds": 4.0 } ``` ### Response #### Success Response (200) - **message** (string) - Indicates that the timer was set successfully. #### Response Example ```json { "message": "Timer set successfully." } ``` ## GET /timer/value ### Description Retrieves the raw timer value, measured in 1/frequency seconds. ### Method GET ### Endpoint /timer/value ### Response #### Success Response (200) - **value** (uint64_t) - The raw timer value. #### Response Example ```json { "value": 1234567890123456789 } ``` ## GET /timer/frequency ### Description Retrieves the frequency of the raw timer in Hz. ### Method GET ### Endpoint /timer/frequency ### Response #### Success Response (200) - **frequency** (uint64_t) - The timer frequency in Hz. #### Response Example ```json { "frequency": 1000000000 } ``` ``` -------------------------------- ### Basic Fullscreen Window Creation (GLFW 2 vs GLFW 3) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/moving.dox Compares the old method of opening a fullscreen window in GLFW 2 with the new method in GLFW 3. GLFW 3 uses `glfwCreateWindow` and requires explicit monitor selection. ```c glfwOpenWindow(640, 480, 8, 8, 8, 0, 24, 0, GLFW_FULLSCREEN); ``` ```c window = glfwCreateWindow(640, 480, "My Window", glfwGetPrimaryMonitor(), NULL); ``` -------------------------------- ### Get Raw Timer Frequency Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Queries the frequency of the raw timer in Hertz (Hz). This value indicates the resolution of the raw timer. ```c uint64_t freqency = glfwGetTimerFrequency(); ``` -------------------------------- ### Configure and Build Meteoros on Windows using CMake Source: https://github.com/amansachan1/meteoros/blob/master/INSTRUCTION.md This snippet details the steps to set up a build environment for the Meteoros project on Windows using CMake and Visual Studio. It involves creating a build directory, running CMake GUI to configure the project, and then generating a Visual Studio solution for building. ```bash mkdir build cd build cmake-gui .. # Or: "C:\Program Files (x86)\cmake\bin\cmake-gui.exe" .. # Follow on-screen instructions to configure and generate. ``` -------------------------------- ### Build on Windows with Visual Studio CLI Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/examples/allegro5_example/README.md Builds the project on Windows using Visual Studio's command-line interface. Requires setting the ALLEGRODIR environment variable and links against Allegro libraries. ```batch set ALLEGRODIR=path_to_your_allegro5_folder cl /Zi /MD /I %ALLEGRODIR%\include /I ..\.. main.cpp imgui_impl_a5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib ``` -------------------------------- ### Destroy GLFW Window Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/quick.dox Destroys the specified GLFW window and frees its resources. After destruction, the window handle becomes invalid and no more events will be delivered for it. ```c glfwDestroyWindow(window); ``` -------------------------------- ### Initialize and Run Renderer Pipeline (C++) Source: https://context7.com/amansachan1/meteoros/llms.txt Initializes the Renderer with necessary Vulkan components and manages the main render loop. It handles scene updates, frame rendering, and camera reprojection. Includes a callback for window resizing. ```cpp #include "Renderer.h" // Create renderer with all required components Renderer* renderer = new Renderer( device, // VulkanDevice for GPU operations physicalDevice, // VkPhysicalDevice for device queries swapChain, // Swap chain for presentation scene, // Scene with models and time data sky, // Sky object with cloud textures camera, // Current frame camera cameraOld, // Previous frame camera for reprojection 1920, // Window width 1080 // Window height ); // Main render loop while (!ShouldQuit()) { glfwPollEvents(); // Update scene uniforms scene->UpdateTime(); sky->UpdateSunAndSky(); // Render frame (handles compute + graphics + post-process) renderer->Frame(); // Update old camera for next frame's reprojection cameraOld->UpdateBuffer(camera); cameraOld->CopyToGPUMemory(); } // Handle window resize void resizeCallback(GLFWwindow* window, int width, int height) { if (width == 0 || height == 0) return; vkDeviceWaitIdle(device->GetVkDevice()); swapChain->Recreate(width, height); renderer->RecreateOnResize(width, height); } // Cleanup vkDeviceWaitIdle(device->GetVkDevice()); delete renderer; ``` -------------------------------- ### Get Gamepad Name Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the human-readable name provided by the gamepad mapping for a given joystick. This name may differ from the joystick's native name. ```c const char* name = glfwGetGamepadName(GLFW_JOYSTICK_7); ``` -------------------------------- ### Build on Linux/Unix with C++ and SDL2 Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/examples/sdl_opengl2_example/README.md This snippet demonstrates building the Meteoros project on Linux and similar Unix-like systems using the C++ compiler. It utilizes `sdl2-config` to fetch compiler and linker flags for SDL2 and OpenGL, outputting an executable named `sdl2example`. ```bash c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL -o sdl2example ``` -------------------------------- ### Get Key Name (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the keyboard layout-dependent name of a printable key. This function can use either a key code or a scancode to identify the key. ```c const char* key_name = glfwGetKeyName(GLFW_KEY_W, 0); show_tutorial_hint("Press %s to move forward", key_name); ``` -------------------------------- ### Get Raw Timer Value Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the raw timer value, measured in units of 1/frequency seconds. The frequency itself can vary depending on the available time sources on the machine. ```c uint64_t value = glfwGetTimerValue(); ``` -------------------------------- ### Compile and link GLFW with pkg-config and GLU (Unix) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/build.dox This command-line example demonstrates compiling and linking a C program with both GLFW and GLU using pkg-config on Unix-like systems. It includes flags for both libraries. ```sh cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --libs glfw3 glu` ``` ```sh cc `pkg-config --cflags glfw3 glu` -o myprog myprog.c `pkg-config --static --libs glfw3` `pkg-config --libs glu` ``` -------------------------------- ### Get High-Resolution Time Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the high-resolution time in seconds since the library was initialized. The underlying platform-specific time sources typically offer micro- or nanosecond resolution. ```c double seconds = glfwGetTime(); ``` -------------------------------- ### Initialize Vulkan Instance and Device Context (C++) Source: https://context7.com/amansachan1/meteoros/llms.txt Manages the Vulkan instance, physical device selection, and memory management. It handles device extensions, queue family indices, surface capabilities, and provides memory type querying for buffer allocation. This code snippet demonstrates creating a Vulkan instance, picking a physical device, creating a logical device, querying memory types, and retrieving surface capabilities. ```cpp #include "VulkanInstance.h" // Create Vulkan instance with required extensions unsigned int glfwExtensionCount = 0; const char** glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount); VulkanInstance* instance = new VulkanInstance("Meteoros", glfwExtensionCount, glfwExtensions); // Pick a physical device (GPU) with required capabilities instance->PickPhysicalDevice( { VK_KHR_SWAPCHAIN_EXTENSION_NAME }, // Required device extensions QueueFlagBit::GraphicsBit | QueueFlagBit::TransferBit | QueueFlagBit::ComputeBit | QueueFlagBit::PresentBit, // Required queue types surface // Window surface for presentation ); // Create logical device for GPU communication VulkanDevice* device = instance->CreateDevice( QueueFlagBit::GraphicsBit | QueueFlagBit::TransferBit | QueueFlagBit::ComputeBit | QueueFlagBit::PresentBit ); // Query memory type index for buffer allocation uint32_t memTypeIndex = instance->GetMemoryTypeIndex( memoryRequirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT ); // Get surface capabilities and formats for swap chain creation const VkSurfaceCapabilitiesKHR& capabilities = instance->GetSurfaceCapabilities(); const std::vector& formats = instance->GetSurfaceFormats(); const std::vector& presentModes = instance->GetPresentModes(); // Cleanup delete device; delete instance; ``` -------------------------------- ### Get Cursor Position (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the current cursor position within the window. This function polls the window's state for the cursor's X and Y coordinates. ```c double xpos, ypos;glfwGetCursorPos(window, &xpos, &ypos); ``` -------------------------------- ### Build and Run Meteoros on Linux Source: https://github.com/amansachan1/meteoros/blob/master/INSTRUCTION.md This snippet outlines the process for building and running the Meteoros project on a Linux system. It involves importing the project into an IDE (like Eclipse), building the project, and then running the generated binary. ```bash # Assuming an IDE like Eclipse is used: # File->Import...->General->Existing Projects Into Workspace # Select the Project 0 repository as the root directory. # Select the Meteoros project in the Project Explorer. # Right click the project. Select Build Project. # From the Run menu, Run. Select "Local C/C++ Application" and the `Meteoros` binary. ``` -------------------------------- ### Load Default Font in ImGui Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/extra_fonts/README.txt Loads the default embedded font provided by Dear ImGui. This is the simplest way to get started with text rendering. ```cpp ImGuiIO& io = ImGui::GetIO(); io.Fonts->AddFontDefault(); ``` -------------------------------- ### Set High-Resolution Timer Reference Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Sets the reference time for the high-resolution timer to a specified value in seconds. This function allows adjusting the timer's starting point. ```c glfwSetTime(4.0); ``` -------------------------------- ### Context Version Hints Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Specify the desired major and minor versions for the client API context. ```APIDOC ## Context Version Hints ### Description These hints allow you to specify the desired major and minor versions for the client API context. The exact behavior depends on the requested client API, but creation will fail if the context version is less than requested. ### Method N/A (Configuration hints) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ## Window Hint Details: - **GLFW_CONTEXT_VERSION_MAJOR** (int) - Desired major version of the client API context. - **GLFW_CONTEXT_VERSION_MINOR** (int) - Desired minor version of the client API context. **Note:** These are not hard constraints for OpenGL, but creation will fail if the context version is less than requested. For legacy code, version 1.0 is safe. ``` -------------------------------- ### Get Key State (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Polls the last reported state of a named key for a given window. The state can be either GLFW_PRESS or GLFW_RELEASE, and is useful for immediate input checks. ```c int state = glfwGetKey(window, GLFW_KEY_E); if (state == GLFW_PRESS) { activate_airship(); } ``` -------------------------------- ### Window Creation with Title Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/news.dox Create a window with an initial title. ```APIDOC ## POST /window ### Description Creates a window with the specified dimensions, title, and monitor configuration. ### Method POST ### Endpoint /window ### Parameters #### Request Body - **width** (int) - Required - The desired width, in screen coordinates, of the new window. - **height** (int) - Required - The desired height, in screen coordinates, of the new window. - **title** (string) - Required - The UTF-8 encoded window title. - **monitor** (MonitorHandle) - Optional - The monitor to make the window full screen on, or NULL to create a windowed mode window. - **share** (WindowHandle) - Optional - The window whose contexts, events and objects to share with the new window, or NULL to not share. ### Response #### Success Response (201) - **window** (WindowHandle) - A handle to the new window. #### Response Example ```json { "window": "0x1234567890abcdef" } ``` ``` -------------------------------- ### Set Viewport with Framebuffer Size Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/quick.dox Retrieves the dimensions of the framebuffer for the specified window and sets the OpenGL viewport accordingly. This is crucial for rendering correctly, especially when the window is resized. ```c int width, height;glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height); ``` -------------------------------- ### Build on Mac OS X with C++ and SDL2 Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/examples/sdl_opengl2_example/README.md This snippet shows how to build the Meteoros project on Mac OS X. It first installs SDL2 using Homebrew, then uses the C++ compiler with `sdl2-config` for SDL2 flags and links against the OpenGL framework, creating an executable named `sdl2example`. ```bash brew install sdl2 c++ `sdl2-config --cflags` -I ../.. main.cpp imgui_impl_sdl.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl -o sdl2example ``` -------------------------------- ### Get Gamepad State Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the current state of a joystick, interpreting it as a gamepad. This populates a GLFWgamepadstate struct with button and axis values. Returns true if the joystick is present and has a gamepad mapping. ```c GLFWgamepadstate state; if (glfwGetGamepadState(GLFW_JOYSTICK_3, &state)) { if (state.buttons[GLFW_GAMEPAD_BUTTON_A]) { input_jump(); } input_speed(state.axes[GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER]); } ``` -------------------------------- ### Build on Ubuntu with g++ Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/examples/allegro5_example/README.md Compiles the project on Ubuntu 14.04+ using g++. It includes necessary header paths for imgui and links against Allegro libraries. ```bash g++ -I ../imgui main.cpp imgui_impl_a5.cpp ../imgui/imgui*.cpp -lallegro -lallegro_primitives ``` -------------------------------- ### Get Joystick Name Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the human-readable, UTF-8 encoded name of a joystick. The returned string's lifetime is tied to the joystick's presence. Joystick names are not guaranteed to be unique. ```c const char* name = glfwGetJoystickName(GLFW_JOYSTICK_4); ``` -------------------------------- ### Creating a Vulkan Window Surface Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/vulkan.dox Provides instructions on how to create a Vulkan surface for a GLFW window using `glfwCreateWindowSurface`. ```APIDOC ## POST glfwCreateWindowSurface ### Description Creates a Vulkan surface (as defined by the `VK_KHR_surface` extension) for a given GLFW window. ### Method POST ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c VkSurfaceKHR surface; VkResult err = glfwCreateWindowSurface(instance, window, NULL, &surface); if (err) { // Window surface creation failed } ``` ### Response #### Success Response (200) - **surface** (VkSurfaceKHR) - A handle to the created Vulkan surface. - **err** (VkResult) - `VK_SUCCESS` if creation was successful, otherwise an error code. #### Response Example ```json { "surface": "VkSurfaceKHR handle", "err": "VK_SUCCESS" } ``` ### Notes - It is the application's responsibility to destroy the created surface using `vkDestroySurfaceKHR`. ``` -------------------------------- ### Get Joystick Axes States with GLFW Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the current positions of all axes for a specified joystick. The function returns an array of float values, each ranging from -1.0 to 1.0, and the count of axes. ```c int count; const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_5, &count); ``` -------------------------------- ### Querying Required Vulkan Extensions Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/vulkan.dox Explains how to query the Vulkan instance extensions required by GLFW for creating Vulkan surfaces. ```APIDOC ## GET glfwGetRequiredInstanceExtensions ### Description Queries the instance extensions required by GLFW to create Vulkan window surfaces. These extensions must be enabled during instance creation. ### Method GET ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c uint32_t count; const char** extensions = glfwGetRequiredInstanceExtensions(&count); ``` ### Response #### Success Response (200) - **count** (uint32_t) - The number of required extensions. - **extensions** (const char**) - An array of strings, where each string is the name of a required Vulkan extension. This array will always contain `VK_KHR_surface`. #### Response Example ```json { "count": 2, "extensions": [ "VK_KHR_surface", "VK_KHR_win32_surface" ] } ``` ### Notes - The returned array may contain additional extensions required by future GLFW versions. - Ensure no extension is specified more than once in `VkInstanceCreateInfo`. ``` -------------------------------- ### Get Monitor Position (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/monitor.dox Retrieves the virtual position (X and Y coordinates) of a monitor on the virtual desktop. Positions are specified in screen coordinates and define the monitor's placement relative to other monitors. ```c int xpos, ypos;glfwGetMonitorPos(monitor, &xpos, &ypos); ``` -------------------------------- ### Compile and link GLFW with pkg-config (Unix) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/build.dox This command-line example shows how to compile and link a C program with the GLFW library on Unix-like systems using pkg-config. It includes flags for both compile-time and link-time dependencies. ```sh cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --static --libs glfw3` ``` ```sh cc `pkg-config --cflags glfw3` -o myprog myprog.c `pkg-config --libs glfw3` ``` -------------------------------- ### Get Monitor Physical Size (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/monitor.dox Retrieves the physical dimensions (width and height) of a monitor in millimeters. This can be an estimation and is independent of the monitor's current resolution. It's useful for calculating DPI. ```c int widthMM, heightMM;glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM); ``` -------------------------------- ### Get Window Visibility State Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox This C code retrieves the current visibility state of a GLFW window using `glfwGetWindowAttrib` with the `GLFW_VISIBLE` attribute. A non-zero return value indicates the window is currently visible. ```c int visible = glfwGetWindowAttrib(window, GLFW_VISIBLE); ``` -------------------------------- ### Get Window Maximization State Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox This C code retrieves the current maximization state of a GLFW window using `glfwGetWindowAttrib` with the `GLFW_MAXIMIZED` attribute. A non-zero return value indicates the window is currently maximized. ```c int maximized = glfwGetWindowAttrib(window, GLFW_MAXIMIZED); ``` -------------------------------- ### Create a Full Screen Window Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Creates a full-screen window on the primary monitor with a specified size and title. This requires specifying the monitor to use. ```c GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", glfwGetPrimaryMonitor(), NULL); ``` -------------------------------- ### Get Window Frame Size Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Retrieves the extents of a window's title bar and frame in screen coordinates. The values represent the distance from the client area edges to the window edges and are always non-negative. ```c int left, top, right, bottom;glfwGetWindowFrameSize(window, &left, &top, &right, &bottom); ``` -------------------------------- ### Custom Font Loading and IME Support in Dear ImGui (C++) Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/README.md Demonstrates how to load custom TTF/OTF fonts, including support for UTF-8 characters like Japanese, and how to enable Microsoft IME for input positioning within Dear ImGui. ```cpp ImGuiIO& io = ImGui::GetIO(); io.Fonts->AddFontFromFileTTF("ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); // For Microsoft IME, pass your HWND to enable IME positioning: io.ImeWindowHandle = my_hwnd; ``` -------------------------------- ### Get Window Size Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Retrieves the current size of a window's client area in screen coordinates. Note that this is in screen coordinates, not pixels, and should not be directly used for pixel-based OpenGL calls like glViewport. ```c int width, height;glfwGetWindowSize(window, &width, &height); ``` -------------------------------- ### Include Glad and GLFW Headers (C/C++) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/build.dox This example demonstrates including the glad extension loader header before the GLFW header. This is necessary when using an OpenGL extension loading library like glad. ```c #include #include ``` -------------------------------- ### Get System Clipboard String Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the content of the system clipboard as a UTF-8 encoded string. Returns NULL if the clipboard is empty or its contents cannot be converted. The returned string's lifetime is managed by the library. ```c const char* text = glfwGetClipboardString(window); if (text) { insert_text(text); } ``` -------------------------------- ### Window Creation Hints Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Sets hints that affect window and context creation. These hints can be reset to defaults or set individually before window creation. ```APIDOC ## POST /window/hints ### Description Configures hints that influence the creation of windows and contexts. These hints can be set individually using `glfwWindowHint` or collectively using `glfwDefaultWindowHints`. Hints must be set before window creation. ### Method POST ### Endpoint /window/hints ### Parameters #### Request Body - **hint** (string) - Required - The hint to set (e.g., "GLFW_RESIZABLE", "GLFW_VISIBLE"). - **value** (integer/boolean) - Required - The value for the hint (e.g., `GLFW_TRUE`, `GLFW_FALSE`, `1`, `0`). ### Request Example ```json { "hint": "GLFW_RESIZABLE", "value": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation (e.g., "success"). #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get Monitor Name (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/monitor.dox Retrieves the human-readable, UTF-8 encoded name of a monitor. The returned string is a pointer to a null-terminated C-string whose lifetime is managed by GLFW. This provides a user-friendly identifier for the monitor. ```c const char* name = glfwGetMonitorName(monitor); ``` -------------------------------- ### Get Key Scancode and Set Mapping (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/input.dox Retrieves the platform-specific scancode for a named key and demonstrates setting a key mapping. This is useful for handling input that may vary across different operating systems. ```c const int scancode = glfwGetKeyScancode(GLFW_KEY_X); set_key_mapping(scancode, swap_weapons); ``` -------------------------------- ### Poll for Events in GLFW Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/quick.dox Processes all pending events that have already been received by GLFW and returns immediately. This method is suitable for applications that continuously render, such as games. It ensures the application remains responsive to the window system. ```c glfwPollEvents(); ``` -------------------------------- ### Include glad Header and Initialize OpenGL (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/context.dox Includes the glad header file before the GLFW header to ensure glad's definitions are used. Initializes glad by calling gladLoadGLLoader with a function pointer obtained from GLFW. ```c #include #include window = glfwCreateWindow(640, 480, "My Window", NULL, NULL); if (!window) { ... } glfwMakeContextCurrent(window); gladLoadGLLoader((GLADloadproc)glfwGetProcAddress); ``` -------------------------------- ### Get Window Focus State Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox This C code retrieves the current input focus state of a GLFW window using `glfwGetWindowAttrib` with the `GLFW_FOCUSED` attribute. A non-zero return value indicates the window currently has input focus. ```c int focused = glfwGetWindowAttrib(window, GLFW_FOCUSED); ``` -------------------------------- ### Get Window Iconification State Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox This C code snippet retrieves the current iconification state of a GLFW window. It uses the `glfwGetWindowAttrib` function with the `GLFW_ICONIFIED` attribute. The result is an integer where a non-zero value indicates the window is iconified. ```c int iconified = glfwGetWindowAttrib(window, GLFW_ICONIFIED); ``` -------------------------------- ### Share Context Objects Between Windows (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/context.dox Demonstrates how to create a new window and share its OpenGL or OpenGL ES context objects with an existing window. This allows textures, buffers, and other resources to be shared between contexts, improving efficiency. ```c GLFWwindow* second_window = glfwCreateWindow(640, 480, "Second Window", NULL, first_window); ``` -------------------------------- ### Build on Windows with Visual Studio CLI Source: https://github.com/amansachan1/meteoros/blob/master/external/imgui/examples/sdl_opengl2_example/README.md This snippet shows how to build the Meteoros project on Windows using the Visual Studio command-line interface. It requires setting the SDL2DIR environment variable to point to your SDL2 installation and links necessary libraries like SDL2, SDL2main, and opengl32. ```batch set SDL2DIR=path_to_your_sdl2_folder cl /Zi /MD /I %SDL2DIR%\include /I ..\.. main.cpp imgui_impl_sdl.cpp ..\..\imgui*.cpp /link /LIBPATH:%SDL2DIR%\lib SDL2.lib SDL2main.lib opengl32.lib /subsystem:console ``` -------------------------------- ### Query Vulkan Instance Function Pointers with glfwGetInstanceProcAddress Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/vulkan.dox Loads Vulkan core and extension function pointers. Pass NULL for the instance to load functions needed for instance creation, such as vkCreateInstance. After instance creation, use the instance to load other functions. ```c PFN_vkCreateInstance pfnCreateInstance = (PFN_vkCreateInstance) glfwGetInstanceProcAddress(NULL, "vkCreateInstance"); ``` ```c PFN_vkCreateDevice pfnCreateDevice = (PFN_vkCreateDevice) glfwGetInstanceProcAddress(instance, "vkCreateDevice"); ``` -------------------------------- ### Get Primary Monitor (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/monitor.dox Retrieves the primary monitor connected to the system. The primary monitor is typically the user's preferred display and hosts global UI elements. This function returns a pointer to a GLFWmonitor object. ```c GLFWmonitor* primary = glfwGetPrimaryMonitor(); ``` -------------------------------- ### Set Swap Interval to 1 in GLFW Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/quick.dox Sets the swap interval for the current GLFW context to 1. This is generally recommended to minimize input latency. The function acts on the current context and requires one to be active. ```c glfwSwapInterval(1); ``` -------------------------------- ### Window Related Hints Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/window.dox Configures window-specific attributes like resizability, visibility, decorations, focus, and maximization. ```APIDOC ## POST /window/hints/window ### Description Sets window-specific creation hints. These affect attributes like whether the window is resizable, initially visible, decorated, focused, floating, maximized, or has its cursor centered. ### Method POST ### Endpoint /window/hints/window ### Parameters #### Request Body - **hint** (string) - Required - The window hint to set. Accepted values include: - `GLFW_RESIZABLE`: Whether the windowed mode window will be resizable by the user. (GLFW_TRUE/GLFW_FALSE) - `GLFW_VISIBLE`: Whether the windowed mode window will be initially visible. (GLFW_TRUE/GLFW_FALSE) - `GLFW_DECORATED`: Whether the windowed mode window will have window decorations. (GLFW_TRUE/GLFW_FALSE) - `GLFW_FOCUSED`: Whether the windowed mode window will be given input focus when created. (GLFW_TRUE/GLFW_FALSE) - `GLFW_AUTO_ICONIFY`: Whether the full screen window will automatically iconify and restore the previous video mode on input focus loss. (GLFW_TRUE/GLFW_FALSE) - `GLFW_FLOATING`: Whether the windowed mode window will be floating above other regular windows. (GLFW_TRUE/GLFW_FALSE) - `GLFW_MAXIMIZED`: Whether the windowed mode window will be maximized when created. (GLFW_TRUE/GLFW_FALSE) - `GLFW_CENTER_CURSOR`: Whether the cursor should be centered over newly created full screen windows. (GLFW_TRUE/GLFW_FALSE) - `GLFW_TRANSPARENT`: Whether the window framebuffer will be transparent. (GLFW_TRUE/GLFW_FALSE) - **value** (boolean) - Required - The value for the hint. ### Request Example ```json { "hint": "GLFW_RESIZABLE", "value": false } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation (e.g., "success"). #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Create a Vulkan-Compatible Window (C) Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/docs/vulkan.dox Creates a GLFW window without an OpenGL or OpenGL ES context, suitable for use with Vulkan. This is achieved by setting the `GLFW_CLIENT_API` hint to `GLFW_NO_API`. ```c glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); GLFWwindow* window = glfwCreateWindow(640, 480, "Window Title", NULL, NULL); ``` -------------------------------- ### GLFW Build Options Configuration Source: https://github.com/amansachan1/meteoros/blob/master/external/GLFW/CMakeLists.txt Defines CMake options to control various aspects of the GLFW build, including shared libraries, examples, tests, documentation, installation, Vulkan static linking, and platform-specific features for Unix and Windows. ```cmake option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON) option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_VULKAN_STATIC "Use the Vulkan loader statically linked into application" OFF) option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) if (UNIX) option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF) endif() if (WIN32) option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF) endif() if (UNIX AND NOT APPLE) option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF) option(GLFW_USE_MIR "Use Mir for window creation" OFF) endif() if (MSVC) option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON) endif() ```