11 std::string current_path =
".";
14 ExampleWindow(
const std::string path,
const std::string &text,
int width,
int height,
bool fullscreen,
bool enable_vsync) :
mxvk::
VK_Window(text, width, height, fullscreen,
MXVK_VALIDATION, enable_vsync) {
15 current_path = path.empty() ? std::string(text_example_ASSET_DIR) : path;
16 setFont(current_path +
"/data/font.ttf", 24);
19 void event(SDL_Event &e)
override {
20 if (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_ESCAPE) {
26 printText(
"Hello World", 15, 15, SDL_Color{255, 255, 255, 255});
31int main(
int argc,
char **argv) {
37 std::cerr << std::format(
"mxvk: Exception: {}\n", e.
text());
40 std::cerr << std::format(
"mxvk: Argument Exception: {}\n", e.
text());
Lightweight, header-only, template command-line argument parser.
Arguments proc_args(int &argc, char **argv)
Parse standard libmx2 command-line options from main()'s argv.
Exception thrown by Argz::proc() on unrecognised or malformed options.
void event(SDL_Event &e) override
Handle one SDL event.
void proc() override
Execute one processing/update step.
ExampleWindow(const std::string path, const std::string &text, int width, int height, bool fullscreen, bool enable_vsync)
void loop()
Run the main event/render loop.
void exit()
Request loop termination.
VK_Window()=default
Construct an empty window object.
void setFont(const std::string &fontPath, int fontSize=24)
Set the active text-render font.
void printText(const std::string &text, int x, int y, const SDL_Color &col)
Queue a text string for rendering during the current frame.
Utilities for loading and saving PNG images.
Plain data structure returned by proc_args() with all common libmx2 CLI options.
bool fullscreen
Whether fullscreen mode was requested.
bool enable_vsync
Enable FIFO present mode / v-sync (--enable-vsync).
int height
Viewport height in pixels (default: 720).
std::string path
Asset root; proc_args() defaults it to the executable directory.
int width
Viewport width in pixels (default: 1280).