MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
starfield.cpp File Reference
#include "mxvk/argz.hpp"
#include "mxvk/mxvk.hpp"
#include "mxvk/mxvk_exception.hpp"
#include "mxvk/mxvk_point_sprite_batch.hpp"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <format>
#include <iostream>
#include <random>
#include <string>
#include <vector>
#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

struct  anonymous_namespace{starfield.cpp}::LayerConfig
struct  anonymous_namespace{starfield.cpp}::Particle
class  example::StarfieldWindow

Namespaces

namespace  anonymous_namespace{starfield.cpp}
namespace  example

Enumerations

enum class  anonymous_namespace{starfield.cpp}::StarType {
  anonymous_namespace{starfield.cpp}::NORMAL , anonymous_namespace{starfield.cpp}::BRIGHT , anonymous_namespace{starfield.cpp}::BLUE , anonymous_namespace{starfield.cpp}::ORANGE ,
  anonymous_namespace{starfield.cpp}::RED , anonymous_namespace{starfield.cpp}::YELLOW
}

Functions

int main (int argc, char **argv)
float anonymous_namespace{starfield.cpp}::random_float (float min, float max)
StarType anonymous_namespace{starfield.cpp}::random_star_type ()
glm::vec4 anonymous_namespace{starfield.cpp}::star_color (StarType type, float brightness)

Variables

constexpr std::array< LayerConfig, NUM_LAYERSanonymous_namespace{starfield.cpp}::LAYERS
constexpr int anonymous_namespace{starfield.cpp}::NUM_LAYERS = 3
constexpr int anonymous_namespace{starfield.cpp}::NUM_PARTICLES = 50000
constexpr int anonymous_namespace{starfield.cpp}::WARP_TRAIL_SEGMENTS = 5

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 343 of file starfield.cpp.

343 {
344 try {
345 const Arguments args = proc_args(argc, argv);
346 const std::string root = args.path.empty() ? std::string(STARFIELD_ASSET_DIR) : args.path;
347 example::StarfieldWindow window(root + "/data", args.width, args.height, args.fullscreen, args.enable_vsync);
348 window.loop();
349 } catch (mxvk::Exception &e) {
350 std::cerr << std::format("mxvk: Exception: {}\n", e.text());
351 return EXIT_FAILURE;
352 } catch (ArgException<std::string> &e) {
353 std::cerr << std::format("mxvk: Argument Exception: {}\n", e.text());
354 return EXIT_FAILURE;
355 }
356
357 return EXIT_SUCCESS;
358}
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 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