-
Notifications
You must be signed in to change notification settings - Fork 30
Replace GLFW and nativefiledialog with SDL3 + Create layered renderer architecture with GPU API #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Added SDL3 as submodule - Removed GLFW and nativefiledialog dependencies - Updated CMakeLists.txt to use SDL3 - Ported application.cpp to use SDL3 APIs - Added SDL3 backend for ImGui (imgui_impl_sdl3.cpp/h) - Replaced file dialog implementation with SDL3's native dialogs - Updated .gitmodules to reflect dependency changes Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
- Changed dialog state from static to local to avoid race conditions - Added validation for extension length before allocation - Improved event loop to use SDL_WaitEventTimeout for better efficiency - Added bounds checking for filter extension parsing Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
|
@copilot I have updated imgui and implot in the current version. I want you to investigate and transition all of the rendering code within the codebase and move it into a stand alone renderer such that no OpenGL calls are made from within main.cpp or any other portion of the code base and all of it occurs within this renderer. This includes rendering molecular representations and immediate 2D drawing. MDlib is still in charge of rendering molecules and is using OpenGL. That can remain so for now. Only make changes within viamd for now. |
I'll create a standalone renderer module to encapsulate all rendering code. This will move OpenGL calls out of main.cpp into a dedicated renderer that handles molecular representations, immediate 2D drawing, and post-processing. I'll create:
Working on this now... |
…dering - Created renderer.h/cpp to encapsulate all rendering operations - Moved rendering functions from main.cpp to renderer module: * fill_gbuffer * apply_postprocessing * draw_representations_opaque/transparent/lean_and_mean - Removed ~578 lines of rendering code from main.cpp - Updated main.cpp to use renderer API instead of direct OpenGL calls - Fixed ImGui 1.92.5 API compatibility (SetPlatformImeDataFn signature change) - Made frame_alloc/persistent_alloc non-static for renderer access - All OpenGL calls for molecular representations and post-processing now isolated in renderer module - MDlib rendering remains unchanged as requested Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
|
@copilot I updated the backends to the officially provided backends from ImGui. |
I'll extend the renderer architecture to move all OpenGL code from components into the renderer, and create a layered architecture: High-level renderer (renderer.h/cpp): Molecule drawing, immediate mode, postprocessing operations I'll refactor:
Working on this now... |
- Added gpu.h/cpp providing low-level GPU API abstraction - Texture management: create, update, destroy, bind - Shader management: create, destroy, use, set uniforms - Framebuffer management: create, destroy, bind, attach textures - VAO management: create, destroy, bind - Rendering state: viewport, scissor, blend, depth test, cull face - Draw operations: draw_arrays, draw_elements - Prepares for layered architecture with high-level renderer on top Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
- Updated rama_rep_init() to use gpu::create_texture_2d() - Updated rama_rep_free() to use gpu::destroy_texture() - Replaced glGenFramebuffers with gpu::create_framebuffer() - Replaced glGenVertexArrays with gpu::create_vertex_array() - Fixed gpu::create_texture_2d() to use glTexStorage2D for immutable storage - Ramachandran texture creation now uses abstracted GPU API layer - Prepares component for full OpenGL removal Co-authored-by: scanberg <706523+scanberg@users.noreply.github.com>
Consolidates windowing and file dialog dependencies from GLFW + nativefiledialog into SDL3, reducing dependency footprint and leveraging SDL3's native cross-platform file dialogs. Additionally refactors all rendering code into a layered renderer architecture with a standalone low-level GPU API to prepare for future SDL-GPU transition.
Changes
Dependency Management
Core Migration (
src/app/application.cpp)glfwCreateWindow→SDL_CreateWindow,glfwMakeContextCurrent→SDL_GL_MakeCurrentglfwPollEvents→SDL_PollEventwith native SDL event handlingNFD_OpenDialog/SaveDialog→SDL_ShowOpenFileDialog/ShowSaveFileDialogwith async callbacksglfwGetTime→SDL_GetTicksImGui Backend
imgui_impl_sdl3.{cpp,h}from ImGui 1.90.5, patched for SDL3 API changes:keysymstruct → flatkey/scancode/modfieldsSDLK_a→SDLK_A,SDL_SYSTEM_CURSOR_ARROW→SDL_SYSTEM_CURSOR_DEFAULTSDL_SetTextInputRect→SDL_SetTextInputArea(window, rect, cursor)SetPlatformImeDataFn→platform_io.Platform_SetImeDataFnimgui_impl_glfw.{cpp,h}Layered Renderer Architecture
Low-Level GPU API (
src/gfx/gpu.{h,cpp})NEW: Created abstraction layer for all GPU operations:
create_texture_2d/3d(),update_texture(),destroy_texture(),bind_texture()create_shader(),destroy_shader(),use_shader(),set_uniform()(multiple type overloads)create_framebuffer(),destroy_framebuffer(),bind_framebuffer(),attach_texture_to_framebuffer()create_vertex_array(),destroy_vertex_array(),bind_vertex_array()set_viewport(),set_scissor(),enable_blend(),enable_depth_test(),enable_cull_face(),set_depth_mask(),set_color_mask(),clear_color(),clear()draw_arrays(),draw_elements()High-Level Renderer Module (
src/gfx/renderer.{h,cpp})main.cppto renderer modulefill_gbuffer()- Molecular representation rendering to GBufferapply_postprocessing()- All post-processing effects (SSAO, TAA, DoF, etc.)draw_representations_opaque()- Opaque molecular renderingdraw_representations_transparent()- Volume rendering (orbitals, electron density)draw_representations_opaque_lean_and_mean()- Optimized rendering for selections/highlightsmain.cppnow usesrenderer::*()calls instead of direct OpenGLComponent Refactoring
NEW: Started migrating components to use GPU API:
gpu::create_texture_2d()andgpu::destroy_texture()glGenFramebuffers/glGenVertexArrayswithgpu::create_framebuffer()andgpu::create_vertex_array()glTexStorage2Dvia GPU API for immutable texture storageFile Dialog Implementation
Security & Quality
SDL_Delay(10)→SDL_WaitEventTimeout(&event, 10)Architecture Improvement
The new layered architecture provides clean separation of concerns:
Benefits:
md_gl_draw()) remains unchanged as requestedProgress
Notes
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.