MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
main.cpp File Reference
#include "mxvk/argz.hpp"
#include "mxvk/mxvk.hpp"
#include "mxvk/mxvk_exception.hpp"
#include "mxvk/mxvk_stopwatch.hpp"
#include "mxvk/mxvk_math.h"
#include "mxvk/mxvk_png.hpp"
#include <SDL3/SDL.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <iostream>
#include <limits>
#include <memory>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>

Go to the source code of this file.

Classes

struct  anonymous_namespace{main.cpp}::FaceDraw
class  example::Math3DModelLoaderWindow
struct  anonymous_namespace{main.cpp}::MipLevel
class  anonymous_namespace{main.cpp}::SurfaceDeleter
struct  anonymous_namespace{main.cpp}::Texture

Namespaces

namespace  anonymous_namespace{main.cpp}
namespace  example

Functions

SurfacePtr anonymous_namespace{main.cpp}::create_frame_surface (int width, int height)
bool anonymous_namespace{main.cpp}::crosses_horizontal_texture_seam (const std::array< mxvk::vec2D, 3 > &texcoords)
mxvk::MXCOLOR anonymous_namespace{main.cpp}::interpolate_color (mxvk::MXCOLOR first, mxvk::MXCOLOR second, float fraction)
Texture anonymous_namespace{main.cpp}::load_texture (const std::string &filename, const std::string &asset_path, bool generate_mipmaps)
int main (int argc, char **argv)
std::filesystem::path anonymous_namespace{main.cpp}::model_path (const std::string &filename, const std::string &asset_path)
mxvk::MXCOLOR anonymous_namespace{main.cpp}::pack_color (std::uint32_t red, std::uint32_t green, std::uint32_t blue, std::uint32_t alpha)
std::filesystem::path anonymous_namespace{main.cpp}::texture_path (const std::string &filename, const std::string &asset_path)
std::array< mxvk::vec2D, 3 > anonymous_namespace{main.cpp}::unwrap_horizontal_texcoords (std::array< mxvk::vec2D, 3 > texcoords)

Variables

constexpr std::string_view anonymous_namespace{main.cpp}::APP_NAME = "3dmath_plg_loader"
constexpr std::string_view anonymous_namespace{main.cpp}::BACKEND_NAME = "native"
constexpr mxvk::MXCOLOR anonymous_namespace{main.cpp}::BACKGROUND_COLOR = mxvk::MXVK_RGB(3, 4, 8)
constexpr float anonymous_namespace{main.cpp}::CAMERA_ZOOM_STEP = 0.45f
constexpr std::string_view anonymous_namespace{main.cpp}::DEFAULT_MODEL = "sphere.plg"
constexpr float anonymous_namespace{main.cpp}::MAX_CAMERA_DISTANCE = 12.0f
constexpr float anonymous_namespace{main.cpp}::MAX_PITCH_DEGREES = 89.0f
constexpr float anonymous_namespace{main.cpp}::MIN_CAMERA_DISTANCE = 2.5f
constexpr std::string_view anonymous_namespace{main.cpp}::MODEL_FORMAT = "PLG"
constexpr float anonymous_namespace{main.cpp}::MODEL_SCALE = 2.0f
constexpr float anonymous_namespace{main.cpp}::MOUSE_ROTATION_SENSITIVITY = 0.35f
constexpr std::string_view anonymous_namespace{main.cpp}::WINDOW_TITLE = "MXVK 3D Math PLG Loader"

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 1056 of file main.cpp.

1056 {
1057 try {
1058 Arguments args = proc_args(argc, argv);
1059 FramebufferDimensions framebuffer = args.framebuffer;
1060 if (args.benchmark && !args.framebufferSpecified) {
1061 framebuffer = {320, 180};
1062 std::cout << APP_NAME << ": benchmark framebuffer defaults to 320x180; use --framebuffer to override\n";
1063 }
1064 example::Math3DModelLoaderWindow window(args.filename, args.texture, args.path, std::string(WINDOW_TITLE), args.width, args.height, args.fullscreen, args.enable_vsync, args.repeat, args.nowarpfix, args.disable_mipmap, args.mip_bias, framebuffer, args.benchmark, args.wireframe);
1065 window.loop();
1066 } catch (mxvk::Exception &e) {
1067 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
1068 return EXIT_FAILURE;
1069 } catch (ArgException<std::string> &e) {
1070 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
1071 return EXIT_FAILURE;
1072 }
1073 return EXIT_SUCCESS;
1074}
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
constexpr std::string_view WINDOW_TITLE
Definition main.cpp:41
constexpr std::string_view APP_NAME
Definition main.cpp:38
Plain data structure returned by proc_args() with all common libmx2 CLI options.
Definition argz.hpp:730
FramebufferDimensions framebuffer
Software framebuffer size requested by --framebuffer.
Definition argz.hpp:758
bool framebufferSpecified
Whether --framebuffer was provided.
Definition argz.hpp:759
bool fullscreen
Whether fullscreen mode was requested.
Definition argz.hpp:736
float mip_bias
Mipmap level-of-detail bias requested by --mip-bias.
Definition argz.hpp:757
bool enable_vsync
Enable FIFO present mode / v-sync (--enable-vsync).
Definition argz.hpp:750
bool nowarpfix
Disable perspective-correct texture mapping (--nowarpfix).
Definition argz.hpp:755
std::string texture
Optional texture file path (--texture).
Definition argz.hpp:764
int height
Viewport height in pixels (default: 720).
Definition argz.hpp:733
bool repeat
Enable repeat behavior such as playback looping or wrapped textures.
Definition argz.hpp:747
std::string filename
Optional input filename (--filename).
Definition argz.hpp:738
std::string path
Asset root; proc_args() defaults it to the executable directory.
Definition argz.hpp:735
bool benchmark
Enable application benchmark mode (--benchmark).
Definition argz.hpp:753
bool wireframe
Render supported 3D models as wireframes (--wireframe).
Definition argz.hpp:754
int width
Viewport width in pixels (default: 1280).
Definition argz.hpp:732
bool disable_mipmap
Disable mipmap generation and selection (--disable-mipmap).
Definition argz.hpp:756
Parsed software framebuffer dimensions.
Definition argz.hpp:721