MXVK Vulkan Framework 0.35.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
skeleton.cpp
Go to the documentation of this file.
1#include "mxvk/argz.hpp"
2#include "mxvk/mxvk.hpp"
4#include <SDL3/SDL.h>
5#include <format>
6#include <iostream>
7
8namespace skeleton {
10 public:
11 SkeletonWindow(int width, int height, bool full, bool enable_vsync) : mxvk::VK_Window(" -[ MXVK Skeleton ] - ", width, height, full, MXVK_VALIDATION, enable_vsync) { std::cout << "skeleton: started example.\n"; }
12 void event(SDL_Event &e) override {
13 switch (e.type) {
14 case SDL_EVENT_KEY_DOWN:
15 if (e.key.key == SDLK_ESCAPE) {
16 exit();
17 return;
18 }
19 break;
20 case SDL_EVENT_QUIT:
21 exit();
22 return;
23 }
24 }
25 void proc() override {
26 // drawing commands
27 }
28 };
29} // namespace skeleton
30
31int main(int argc, char **argv) {
32 try {
33 Arguments args = proc_args(argc, argv);
34 skeleton::SkeletonWindow window(args.width, args.height, args.fullscreen, args.enable_vsync);
35 window.loop();
36 } catch (mxvk::Exception &e) {
37 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
38 return EXIT_FAILURE;
39 } catch (ArgException<std::string> &e) {
40 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
41 return EXIT_FAILURE;
42 }
43 return EXIT_SUCCESS;
44}
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.
Definition argz.hpp:854
Exception thrown by Argz::proc() on unrecognised or malformed options.
Definition argz.hpp:169
std::string text() const
Main Vulkan window wrapper for MXVK.
Definition mxvk.hpp:39
void loop()
Run the main event/render loop.
Definition mxvk.cpp:651
void exit()
Request loop termination.
Definition mxvk.cpp:1378
VK_Window()=default
Construct an empty window object.
SkeletonWindow(int width, int height, bool full, bool enable_vsync)
Definition skeleton.cpp:11
void proc() override
Execute one processing/update step.
Definition skeleton.cpp:25
void event(SDL_Event &e) override
Handle one SDL event.
Definition skeleton.cpp:12
#define MXVK_VALIDATION
Definition mxvk.hpp:28
int main()
Definition main.py:165
Utilities for loading and saving PNG images.
Definition mxvk.hpp:31
Plain data structure returned by proc_args() with all common libmx2 CLI options.
Definition argz.hpp:718
bool fullscreen
Whether fullscreen mode was requested.
Definition argz.hpp:724
bool enable_vsync
Enable FIFO present mode / v-sync (--enable-vsync).
Definition argz.hpp:738
int height
Viewport height in pixels (default: 720).
Definition argz.hpp:721
int width
Viewport width in pixels (default: 1280).
Definition argz.hpp:720