27 lines
1.1 KiB
C++
27 lines
1.1 KiB
C++
#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();
|
|
}
|
|
}
|