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_math.h"
#include <SDL3/SDL.h>
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <format>
#include <fstream>
#include <iostream>
#include <memory>
#include <random>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  anonymous_namespace{main.cpp}::Cell
struct  anonymous_namespace{main.cpp}::CubeInstance
struct  anonymous_namespace{main.cpp}::FaceDraw
struct  anonymous_namespace{main.cpp}::GridCubePlacement
class  anonymous_namespace{main.cpp}::HighScores
struct  anonymous_namespace{main.cpp}::Layout
class  example::MasterPieceWindow
struct  anonymous_namespace{main.cpp}::Piece
struct  anonymous_namespace{main.cpp}::ScoreEntry
class  anonymous_namespace{main.cpp}::SurfaceDeleter

Namespaces

namespace  anonymous_namespace{main.cpp}
namespace  example

Enumerations

enum class  anonymous_namespace{main.cpp}::Screen {
  anonymous_namespace{main.cpp}::Intro , anonymous_namespace{main.cpp}::Menu , anonymous_namespace{main.cpp}::Game , anonymous_namespace{main.cpp}::Scores ,
  anonymous_namespace{main.cpp}::Credits , anonymous_namespace{main.cpp}::NameEntry , anonymous_namespace{main.cpp}::Intro , anonymous_namespace{main.cpp}::Menu ,
  anonymous_namespace{main.cpp}::Game , anonymous_namespace{main.cpp}::Scores , anonymous_namespace{main.cpp}::Credits , anonymous_namespace{main.cpp}::NameEntry
}

Functions

SurfacePtr anonymous_namespace{main.cpp}::createFrameSurface (int width, int height)
bool anonymous_namespace{main.cpp}::hasResolutionArgument (int argc, char **argv)
int main (int argc, char **argv)
std::filesystem::path anonymous_namespace{main.cpp}::resolveAssetRoot (const std::string &path)
std::filesystem::path anonymous_namespace{main.cpp}::resolvePuzzleAssetRoot (const std::filesystem::path &asset_root)
std::filesystem::path anonymous_namespace{main.cpp}::scorePath (const std::filesystem::path &asset_root)

Variables

constexpr int anonymous_namespace{main.cpp}::base_height = 1080
constexpr int anonymous_namespace{main.cpp}::base_width = 1440
constexpr int anonymous_namespace{main.cpp}::board_cols = 8
constexpr int anonymous_namespace{main.cpp}::board_rows = 18
constexpr int anonymous_namespace{main.cpp}::flash_time_ms = 180
constexpr int anonymous_namespace{main.cpp}::game_base_height = 480
constexpr int anonymous_namespace{main.cpp}::game_base_width = 640
constexpr int anonymous_namespace{main.cpp}::game_block_height = 14
constexpr int anonymous_namespace{main.cpp}::game_block_spacing = 1
constexpr int anonymous_namespace{main.cpp}::game_block_width = 31
constexpr int anonymous_namespace{main.cpp}::game_board_start_x = 184
constexpr int anonymous_namespace{main.cpp}::game_board_start_y = 78
constexpr int anonymous_namespace{main.cpp}::game_next_panel_x = 450
constexpr int anonymous_namespace{main.cpp}::game_next_panel_y = 180
constexpr float anonymous_namespace{main.cpp}::GRID_DEFAULT_CAMERA_DISTANCE = 2.45f
constexpr float anonymous_namespace{main.cpp}::GRID_MAX_CAMERA_DISTANCE = 9.0f
constexpr float anonymous_namespace{main.cpp}::GRID_MAX_PITCH = 70.0f
constexpr float anonymous_namespace{main.cpp}::GRID_MIN_CAMERA_DISTANCE = 1.65f
constexpr float anonymous_namespace{main.cpp}::GRID_MIN_PITCH = -70.0f
constexpr float anonymous_namespace{main.cpp}::GRID_PITCH_SPEED = 90.0f
constexpr int anonymous_namespace{main.cpp}::GRID_VERTICAL_GAP = 5
constexpr float anonymous_namespace{main.cpp}::GRID_YAW_SPEED = 115.0f
constexpr float anonymous_namespace{main.cpp}::GRID_ZOOM_SPEED = 3.2f
constexpr Uint32 anonymous_namespace{main.cpp}::joy_repeat_delay_ms = 180
constexpr Sint16 anonymous_namespace{main.cpp}::joystick_dead_zone = 16000
constexpr int anonymous_namespace{main.cpp}::lines_per_speedup = 10
constexpr int anonymous_namespace{main.cpp}::max_name_length = 16
constexpr int anonymous_namespace{main.cpp}::max_scores = 8
constexpr int anonymous_namespace{main.cpp}::menu_item_count = 4
constexpr int anonymous_namespace{main.cpp}::piece_height = 3
constexpr int anonymous_namespace{main.cpp}::score_points_per_match = 6
constexpr int anonymous_namespace{main.cpp}::title_screen_time_ms = 1500
constexpr mxvk::MXCOLOR anonymous_namespace{main.cpp}::transparent_black = 0x00000000U

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 1603 of file main.cpp.

1603 {
1604 try {
1605 const bool explicit_resolution = hasResolutionArgument(argc, argv);
1606 Arguments args = proc_args(argc, argv);
1607 if (!explicit_resolution) {
1608 args.width = base_width;
1609 args.height = base_height;
1610 }
1611
1612 example::MasterPieceWindow window(args.path, args.width, args.height, args.fullscreen, args.enable_vsync, args.framebuffer);
1613 window.loop();
1614 } catch (mxvk::Exception &e) {
1615 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
1616 return EXIT_FAILURE;
1617 } catch (ArgException<std::string> &e) {
1618 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
1619 return EXIT_FAILURE;
1620 }
1621
1622 return EXIT_SUCCESS;
1623}
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 int base_width
Definition main.cpp:34
bool hasResolutionArgument(int argc, char **argv)
Definition main.cpp:128
constexpr int base_height
Definition main.cpp:35
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 fullscreen
Whether fullscreen mode was requested.
Definition argz.hpp:736
bool enable_vsync
Enable FIFO present mode / v-sync (--enable-vsync).
Definition argz.hpp:750
int height
Viewport height in pixels (default: 720).
Definition argz.hpp:733
std::string path
Asset root; proc_args() defaults it to the executable directory.
Definition argz.hpp:735
int width
Viewport width in pixels (default: 1280).
Definition argz.hpp:732