Extract standalone Playground SDK source foundation
This commit is contained in:
commit
d49c22a06c
3567 changed files with 1657902 additions and 0 deletions
5
examples/consumer/CMakeLists.txt
Normal file
5
examples/consumer/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.24)
|
||||
project(playground_consumer LANGUAGES CXX)
|
||||
find_package(Playground CONFIG REQUIRED)
|
||||
add_executable(playground_consumer main.cpp)
|
||||
target_link_libraries(playground_consumer PRIVATE Playground::playground_core Playground::playground_ui Playground::playground_lua)
|
||||
14
examples/consumer/main.cpp
Normal file
14
examples/consumer/main.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "core/vfs.h"
|
||||
#include "ui/controls.h"
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
}
|
||||
|
||||
int main() {
|
||||
playground::Rollover button({0, 0, 10, 10});
|
||||
if (!button.down(5, 5) || !button.up(5, 5)) return 1;
|
||||
lua_State* state = lua_open();
|
||||
if (!state) return 2;
|
||||
lua_close(state);
|
||||
return playground::normalizePath("A\\B") == "a/b" ? 0 : 3;
|
||||
}
|
||||
27
examples/hello.cpp
Normal file
27
examples/hello.cpp
Normal 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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue