Extract standalone Playground SDK source foundation

This commit is contained in:
CRTkafa 2026-10-02 16:54:36 +00:00
commit d49c22a06c
3567 changed files with 1657902 additions and 0 deletions

27
examples/hello.cpp Normal file
View file

@ -0,0 +1,27 @@
#include "platform/display.h"
#include "ui/controls.h"
#include <SDL3/SDL.h>
#include <string>
int main() {
playground::Display display;
std::string error;
if (!display.open("Playground SDK example", 800, 600, &error)) return 1;
playground::Rollover button({300, 250, 200, 100});
bool running = true;
while (running) {
playground::Event event;
while (display.poll(event)) {
if (event.type == playground::Event::Type::Quit) running = false;
if (event.type == playground::Event::Type::MouseMove) button.move(event.x, event.y);
if (event.type == playground::Event::Type::MouseDown) button.down(event.x, event.y);
if (event.type == playground::Event::Type::MouseUp && button.up(event.x, event.y)) running = false;
}
display.beginFrame();
auto* renderer = display.renderer();
SDL_SetRenderDrawColor(renderer, button.hovered() ? 240 : 150, 120, 70, 255);
const SDL_FRect rect{300, 250, 200, 100};
SDL_RenderFillRect(renderer, &rect);
display.endFrame();
}
}