MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
viewer.cpp File Reference
#include "mxvk/argz.hpp"
#include "mxvk/mxvk.hpp"
#include "mxvk/mxvk_abstract_model.hpp"
#include "mxvk/mxvk_exception.hpp"
#include "mxvk/mxvk_stopwatch.hpp"
#include <SDL3/SDL.h>
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <iostream>
#include <memory>
#include <string>
#include <glm/ext/matrix_clip_space.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <glm/glm.hpp>

Go to the source code of this file.

Classes

class  viewer::ModelViewerWindow

Namespaces

namespace  viewer

Macros

#define VIEWER_ASSET_DIR   "."
#define VIEWER_SHADER_DIR   "."

Functions

int main (int argc, char **argv)

Macro Definition Documentation

◆ VIEWER_ASSET_DIR

#define VIEWER_ASSET_DIR   "."

Definition at line 25 of file viewer.cpp.

◆ VIEWER_SHADER_DIR

#define VIEWER_SHADER_DIR   "."

Definition at line 29 of file viewer.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 408 of file viewer.cpp.

408 {
409 std::cout.setf(std::ios::unitbuf);
410 std::cerr.setf(std::ios::unitbuf);
411 setvbuf(stdout, nullptr, _IONBF, 0);
412 setvbuf(stderr, nullptr, _IONBF, 0);
413
414 try {
415 Arguments args = proc_args(argc, argv);
416 if (args.benchmark && !args.resolutionSpecified) {
417 args.width = 320;
418 args.height = 180;
419 std::cout << "viewer: benchmark resolution defaults to 320x180; use -r or --resolution to override\n";
420 }
421 viewer::ModelViewerWindow window(args);
422 window.loop();
423 } catch (const mxvk::Exception &e) {
424 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
425 return EXIT_FAILURE;
426 } catch (const ArgException<std::string> &e) {
427 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
428 return EXIT_FAILURE;
429 } catch (const std::exception &e) {
430 std::cerr << std::format("viewer: Exception: {}\n", e.what());
431 return EXIT_FAILURE;
432 }
433 return EXIT_SUCCESS;
434}
Arguments proc_args(int &argc, char **argv)
Parse standard libmx2 command-line options from main()'s argv.
Definition argz.hpp:872
Exception thrown by Argz::proc() on unrecognised or malformed options.
Definition argz.hpp:178
String text() const
Definition argz.hpp:182
std::string text() const
Plain data structure returned by proc_args() with all common libmx2 CLI options.
Definition argz.hpp:730
bool resolutionSpecified
Whether -r/–resolution was provided.
Definition argz.hpp:734
int height
Viewport height in pixels (default: 720).
Definition argz.hpp:733
bool benchmark
Enable application benchmark mode (--benchmark).
Definition argz.hpp:753
int width
Viewport width in pixels (default: 1280).
Definition argz.hpp:732