Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 1, 2026

EGE currently only supports Windows via GDI. This PR adds the foundation for cross-platform support by introducing a multi-backend rendering architecture with an opt-in OpenGL backend.

Changes

New INIT_OPENGL flag

  • Added INIT_OPENGL = 0x200 to initmode_flag enum in both ege.h and ege.zh_CN.h

Backend abstraction layer (src/backend/)

  • render_backend.h - Abstract interface for rendering backends
  • render_backend.cpp - Backend factory and lifecycle management
  • gdi_backend.h/.cpp - GDI wrapper (stubs with TODOs for integration)
  • opengl_backend.h/.cpp - OpenGL 2.1 implementation using GLFW/GLAD

CMake configuration

  • New EGE_ENABLE_OPENGL option (OFF by default)
  • GLFW/GLAD detection with fallback to 3rdparty/ submodules

Demo and docs

  • demo/graph_opengl_test.cpp - Usage example
  • docs/CROSS_PLATFORM.md - Bilingual documentation

Usage

cmake .. -DEGE_ENABLE_OPENGL=ON
// Opt-in to OpenGL backend
ege::initgraph(640, 480, ege::INIT_OPENGL);

// Default GDI backend unchanged
ege::initgraph(640, 480, ege::INIT_DEFAULT);

Next steps

  • Add GLFW/GLAD as submodules
  • Wire backend into initgraph()
  • Implement full GDI backend delegation
Original prompt

任务: 执行 EGE (Easy Graphics Engine) 软件重构, 支持跨平台。
目前 EGE 这个项目主要基于 GDI 这种陈旧的后端实现, 虽然名义上宣传跨平台, 实际上只支持 Windows 平台, 在 Mac/Linux 等平台需要用 wine 以及 mingw-w64 才行, 并不能真正的跨平台。
我希望重构这个项目, 保证基础功能不变的情况下, 能够跨平台。
我希望使用 OpenGL 来作为新的后端实现, 以支持 Windows、 MacOS、 Linux 等主流操作系统。
对于窗口创建, 我觉得可以直接使用 GLFW 这个跨平台的库来实现。而 GLFW 本身还依赖了 GLAD 来加载 OpenGL 函数, 这两个库都能很好地支持跨平台。
此外, EGE 目前的代码结构比较混乱, 需要进行模块化重构, 提高代码的可维护性和可扩展性。
软件的向前兼容性是一个重要因素, demo 目录有很多对于此项目的调用, 可以部分验证项目的兼容性。
为了保障向前兼容, 以及缩小第一个版本的上线风险, 我希望可以在 initmode_flag 中增加一个 INIT_OPENGL 模式, 支持用户主动开启 OpenGL 渲染后端。 如果用户不启用该模式, 则继续使用现有的 GDI 渲染后端。 换句话说, 这个项目跟渲染有关的部分, 需要同时支持 GDI 和 OpenGL 两种后端实现。你需要在接口层进行抽象, 以支持多后端的渲染实现。
请先分析整个项目, 确认项目的改动范围, 以及改动的工作量。
然后根据项目的整体技术栈, 给出跨平台的重构分析和建议。
最后, 给出重构的计划, 重构的计划最好足够详细, 之后按照重构的计划一步步进行重构


💡 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.

@coderabbitai
Copy link

coderabbitai bot commented Jan 1, 2026

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits January 1, 2026 09:13
Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
… add proper documentation

Co-authored-by: wysaid <1430725+wysaid@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor EGE software for true cross-platform support Add OpenGL backend infrastructure for cross-platform EGE support Jan 1, 2026
Copilot AI requested a review from wysaid January 1, 2026 09:21
@wysaid wysaid closed this Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants