7 VK_IOWindow::VK_IOWindow(
const std::string &path,
const std::string &title,
const int width,
const int height,
const bool fullscreen,
const bool enableVsync) :
mxvk::
VK_Window(title, width, height, fullscreen,
MXVK_VALIDATION, enableVsync) {
8 const std::string base_path = path;
9 console.attach(*
this, base_path +
"/data/font.ttf", 20);
10 console.setSpriteYOriginTopLeft(
true);
12 console.printLine(
"Press F3 to open/close the console.");
13 console.printLine(
"Type 'help' for built-in commands.");
14 console.setCommandCallback([
this](
mxvk::VK_Window &,
const std::vector<std::string> &args, std::ostream &out) {
19 if (args[0] ==
"help") {
20 out <<
"Built-in commands:\n"
21 <<
" help Show this help message\n"
22 <<
" clear Clear the console output\n"
23 <<
" echo <text> Print text to the console\n"
24 <<
" about Show sample/about information\n"
25 <<
" quit | exit Close the current window";
30 if (args[0] ==
"echo") {
31 for (std::size_t i = 1; i < args.size(); ++i) {
40 if (args[0] ==
"quit" || args[0] ==
"exit") {
41 out <<
"Closing window...";
46 if (args[0] ==
"about") {
47 out <<
"console_demo: MXVK Vulkan console sample.\n(C) 2026 LostSideDead Software\n";
60 [[maybe_unused]] std::ostream &out) {
68 const bool is_escape_down = (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_ESCAPE);
69 const bool was_console_visible =
console.isVisible();
70 if (is_escape_down && was_console_visible && SDL_GetWindowRelativeMouseMode(
getSDLWindow())) {
77 if (is_escape_down && was_console_visible && !
console.isVisible()) {
virtual void appendConsoleHelp(std::ostream &out) const
Append app-specific help lines to the console help output.
virtual void console_event(SDL_Event &e)=0
virtual void console_proc()=0
virtual bool handleConsoleCommand(const std::vector< std::string > &args, std::ostream &out)
Handle app-specific console commands.
void event(SDL_Event &e) override
Handle one SDL event.
void print(const std::string &text, SDL_Color col={255, 255, 255, 255})
void proc() override
Execute one processing/update step.
VK_IOWindow(const std::string &path, const std::string &title, const int width, const int height, const bool fullscreen, const bool enableVsync=false)
Main Vulkan window wrapper for MXVK.
SDL_Window * getSDLWindow() const noexcept
Get the underlying SDL window handle.
void exit()
Request loop termination.
VK_Window()=default
Construct an empty window object.
Utilities for loading and saving PNG images.