cangine is a lightweight C++ engine built on OpenGL. Open a window, render quads & text, play audio, build UIs, and compose objects with a clean component system — no bloat, no ceremony.
#include "cangine/cangine.hpp"
using namespace cangine;
class MyApp : public CangineApp {
public:
MyApp() : CangineApp(800, 600, "My Game") {}
void onFirstFrame() override {
Label* hello = instantiateObject<Label>("Hello, world!");
// Z index 80+ is the UI layer
Transform::posFor(hello, Vector3(hello->getSize() / -2, 80));
}
void onFrame(double dt) override {
// per-frame game logic
}
};
int main() { MyApp().run(); }
A focused toolkit — rendering, audio, input, UI and a component system — assembled so you can ship a prototype today and grow it tomorrow.
Attach & detach Transform, renderers and your own components on any GameObject at runtime.
Colored & textured quads, triangles and FreeType text, batched through a clean OpenGL pipeline.
Label, Button, InputField & Panel with click / return handlers, placeholders and styling.
Load & control sounds via AudioManager — play, pause, seek, volume & looping, powered by miniaudio.
SAT-based rect overlap and point-in-rect checks — fully aware of rotation and scale.
Frame-accurate keyboard (getKey/Down/Up) and rich mouse events: click, move, scroll, enter.
A movable Camera object you control with custom components, plus a simple Z-index layering model.
getFPS(), getInstantFPS() and getDeltaTime() right on the window for smooth, framerate-independent motion.
Minimal-boilerplate GLSL shader management and PNG/JPEG texture loading through stb_image.
The Makefile wraps CMake, so a single command builds the engine or runs any bundled example.
GLFW, GLAD, FreeType & fontconfig — only stb_image & miniaudio ship in-tree.
One git clone and you have the engine plus nine examples.
make engineBuilds the static library via CMake into build/.
CangineAppOverride onFirstFrame() / onFrame(dt) and call .run().
# 1 · install dependencies
$ sudo apt install libglfw3-dev libfreetype-dev \
libepoxy-dev libfontconfig-dev
# 2 · clone & build the engine
$ git clone https://github.com/huseyinhealth/cangine.git
$ cd cangine && make engine
# 3 · build & run any example
$ make example EXAMPLE=sandbox
→ launching sandbox… 60 FPS ✓
// A clickable button
Button* btn = instantiateObject<Button>("Click me!");
btn->registerOnClickEvent([&](const MouseEvent* e){
score++;
});
// A text input with a submit handler
InputField* field = instantiateObject<InputField>();
field->setPlaceholder("Name?");
field->setOnReturn([&](std::string v){ name = v; });
// Load once, control anytime
audioMan->add("./music.mp3", "bgm");
audioMan->play("bgm", true); // looping
audioMan->setVolume("bgm", 0.5f);
audioMan->seek("bgm", 10.0f); // seconds
bool on = audioMan->isPlaying("bgm");
// Held down this frame
if (Input::getKey(Key::A)) player.x -= speed * dt;
// Pressed exactly this frame
if (Input::getKeyDown(Key::Space)) jump();
// Released this frame
if (Input::getKeyUp(Key::Escape)) pause();
// Point-in-rect — respects rotation & scale
bool hit = Rectangle::containsPoint(rect, tf, mousePos);
// Rect vs rect — SAT, transform-aware
bool col = Rectangle::overlaps(a, tfA, b, tfB);
if (col) onCollision();
Each subsystem lives behind a small, readable interface — engine, platform, render and audio, cleanly separated.
stb_image & miniaudio ship in-tree — the rest are system packages (one apt command, below).
From a one-screen hello world to complete mini-games — every subsystem demonstrated in real, runnable code.
The minimal CangineApp — a window with centered text.
Buttons, labels and containers wired up with event handlers.
A complete click-the-target mini-game with scoring.
Movement, spawning and collision in a survival loop.
A draggable camera panning across a world of quads.
The full-featured test scene exercising the whole engine.
cangine is free, open source under MIT, and ready to clone right now.