Implement GLFW window system #20
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Window Management with GLFW
Summary
This pr adds a new window management system to the Cyfra project, under the
io.computenode.cyfra.windowpackage. The main goal is to separate window handling from the Vulkan rendering logic and give us a consistent way to manage windows across platforms.The initial version includes a general
WindowSystemtrait for abstraction, and a working GLFW-based implementation calledGLFWWindowSystem.Features
GLFWWindowSystemprovides a good implementation using the GLFW library.WindowHandle(specificallyGLFWWindowHandle) is designed for easy Vulkan surface creation, exposing the native window pointer (nativePtr) required to create aVkSurfaceKHR.WindowSystemTestto demonstrate the system's functionality.Implementation Details
1. Architecture
WindowSystemtrait defining methods likecreateWindow,pollEvents, andshouldWindowClose.GLFWWindowSystemhandles all GLFW-specific stuff like initializing the library, setting platform hints, and wiring up callbacks.WindowHandle(implemented asGLFWWindowHandle) gives access to the raw window pointer, which is needed for Vulkan surface creation.GLFWSystemthat handles GLFW init and error checks, and ensures Vulkan compatibility.2. Event System
GLFWKeyCallback,GLFWCursorPosCallback) are registered withinGLFWWindowSystem.setupCallbacks.ConcurrentLinkedQueue.pollEventsmethod callsGLFW.glfwPollEvents()to trigger callbacks, then queue is drained and events are returned as a list to process (assumes single-threaded usage).3. Vulkan Integration
GLFW_CLIENT_APItoGLFW_NO_APIso Vulkan can handle rendering.WindowHandle.nativePtrprovides the underlyingGLFWwindowpointer, essential for creating the VulkanVkSurfaceKHRviaglfwCreateWindowSurface, which connects the window to Vulkan’s rendering system (swapchain).Testing
WindowSystemTest, a runnable standalone test/demo application.sbt "runMain io.computenode.cyfra.window.WindowSystemTest".Potential Issues & Limitations
GLFWWindowSystem) is implemented and supported.Future Work
This provides a base for window management in Cyfra.