u/EliAndrewt

▲ 29 r/pygame

Wiping out the bloat: Re-engineering my Python/C graphics engine from scratch using Modern OpenGL 3.3 Core Profile (~1000+ FPS)

Right now, I am rewriting the entire engine from scratch to maximize performance, eliminate architectural bloat, and transition to a modern, bug-free rendering pipeline. I will try to make it modular so that other developers can easily drop Pyforge into their own projects and use it as a hardware-accelerated backend.

After getting some awesome, direct technical feedback from the community on my initial immediate mode blueprint, I went back to the drawing board and completely refactored the core:

🚫 Banned OpenGL 1.0 Removed all legacy deprecated functions and completely stripped out fixed functions like `glBegin()` and `glEnd()`.

🛡️ Enforced Core Profile: Locked the backend down to a strict OpenGL 3.3 Core Profile context.

📦 GPU Instanced Streaming* Replaced slow individual entity loops with single-burst memory array streaming (`glDrawArraysInstanced`) over the C-extension bridge exactly once per frame.

🔄 Hardware Delegated Rotations: Offloaded heavy trigonometry calculations (`sin`/`cos` transformation matrices) completely onto the GPU's parallel processing cores.

Here is a quick 4-second showcase running 100 large mixed primitives (Triangles, Squares, and high-fidelity 32-sided Circles) floating, bouncing, and spinning with sub-pixel drift. By moving 100% of the memory layout and rendering steps to C and the GPU, the interpreter thread is completely unburdened and hits thousands of frames per second unthrottled.

Would love to hear your thoughts on this modern rewrite direction!

u/EliAndrewt — 6 days ago
▲ 9 r/gameenginedevs+1 crossposts

I wanted a fast 2D engine without software rendering bloat, so I built an open-source C/OpenGL framework wrapped in Python. Looking for contributors!

I wanted to create a fast 2D game engine that is easy to use, so I built pyforge-engine.

The heavy graphics loop, shapes, and audio are written in compiled C using OpenGL and OpenAL, then wrapped in simple Python. You get the raw speed of C but the simplicity of Python without dealing with complex boilerplate. It is live on PyPI and GitHub.

The engine has for now:

  • Draw Shapes with automatic optimization: You just call pyforge.shape(36) for a circle, and it pre-calculates the geometry mesh directly on the GPU so it draws instantly.
  • In-Memory Fonts: It automatically scans your computer's OS font folder and slices character textures straight into RAM, meaning you don't need to bundle font files with your code.
  • Fast Particles: Spawns physics-tracked explosion effect shards directly on the hardware layer so it doesn't cause frame lag.
  • Audio Streaming: Decodes and streams both WAV and MP3 files filelessly via native OpenAL sound card channels.
  • Simple Setup: You can open an accelerated window, clear the screen with a color gradient, and run a game loop in under 10 lines of code.

It is still an MVP, but it is already running smooth Flappy Bird and grid-based Snake games. I also used AI to generate dense code comments explaining the low-level math and memory steps for full transparency.

If you are interested, I am looking for contributors! I just opened some "Good First Issues" on the GitHub dashboard—my classmate is already jumping in to help optimize the Python FPS counter using a rolling average window.

If you like messing with C, OpenGL, or Python wrappers, come help build it.

GitHub Link: https://github.com/EliAndrewTebcherany/pyforge-engine

u/EliAndrewt — 8 days ago