MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
anonymous_namespace{starfield.cpp} Namespace Reference

Classes

struct  LayerConfig
struct  Particle

Enumerations

enum class  StarType {
  NORMAL , BRIGHT , BLUE , ORANGE ,
  RED , YELLOW
}

Functions

float random_float (float min, float max)
StarType random_star_type ()
glm::vec4 star_color (StarType type, float brightness)

Variables

constexpr std::array< LayerConfig, NUM_LAYERSLAYERS
constexpr int NUM_LAYERS = 3
constexpr int NUM_PARTICLES = 50000
constexpr int WARP_TRAIL_SEGMENTS = 5

Enumeration Type Documentation

◆ StarType

enum class anonymous_namespace{starfield.cpp}::StarType
strong

Function Documentation

◆ random_float()

float anonymous_namespace{starfield.cpp}::random_float ( float min,
float max )
nodiscard

Definition at line 66 of file starfield.cpp.

66 {
67 static std::random_device rd;
68 static std::default_random_engine engine(rd());
69 std::uniform_real_distribution<float> dist(min, max);
70 return dist(engine);
71 }

◆ random_star_type()

StarType anonymous_namespace{starfield.cpp}::random_star_type ( )
nodiscard

Definition at line 73 of file starfield.cpp.

73 {
74 const float r = random_float(0.0f, 1.0f);
75 if (r < 0.50f) {
76 return StarType::NORMAL;
77 }
78 if (r < 0.65f) {
79 return StarType::BLUE;
80 }
81 if (r < 0.75f) {
82 return StarType::YELLOW;
83 }
84 if (r < 0.85f) {
85 return StarType::ORANGE;
86 }
87 if (r < 0.92f) {
88 return StarType::RED;
89 }
90 return StarType::BRIGHT;
91 }
float random_float(float min, float max)
Definition starfield.cpp:66

◆ star_color()

glm::vec4 anonymous_namespace{starfield.cpp}::star_color ( StarType type,
float brightness )
nodiscard

Definition at line 93 of file starfield.cpp.

93 {
94 switch (type) {
95 case StarType::BLUE:
96 return glm::vec4(0.6f * brightness, 0.8f * brightness, 1.0f * brightness, 1.0f);
98 return glm::vec4(1.0f * brightness, 0.7f * brightness, 0.3f * brightness, 1.0f);
99 case StarType::RED:
100 return glm::vec4(1.0f * brightness, 0.4f * brightness, 0.4f * brightness, 1.0f);
101 case StarType::YELLOW:
102 return glm::vec4(1.0f * brightness, 1.0f * brightness, 0.6f * brightness, 1.0f);
103 case StarType::BRIGHT:
104 return glm::vec4(1.0f * brightness, 1.0f * brightness, 1.0f * brightness, 1.0f);
105 case StarType::NORMAL:
106 default:
107 return glm::vec4(0.9f * brightness, 0.9f * brightness, 1.0f * brightness, 1.0f);
108 }
109 }

Variable Documentation

◆ LAYERS

std::array<LayerConfig, NUM_LAYERS> anonymous_namespace{starfield.cpp}::LAYERS
constexpr
Initial value:
{{
{-12.0f, -6.0f, 0.2f, 0.6f, 28000},
{-6.0f, -3.0f, 0.5f, 1.0f, 14000},
{-3.0f, -1.0f, 1.0f, 1.6f, 8000},
}}

Definition at line 60 of file starfield.cpp.

60 {{
61 {-12.0f, -6.0f, 0.2f, 0.6f, 28000},
62 {-6.0f, -3.0f, 0.5f, 1.0f, 14000},
63 {-3.0f, -1.0f, 1.0f, 1.6f, 8000},
64 }};

◆ NUM_LAYERS

int anonymous_namespace{starfield.cpp}::NUM_LAYERS = 3
constexpr

Definition at line 57 of file starfield.cpp.

◆ NUM_PARTICLES

int anonymous_namespace{starfield.cpp}::NUM_PARTICLES = 50000
constexpr

Definition at line 56 of file starfield.cpp.

◆ WARP_TRAIL_SEGMENTS

int anonymous_namespace{starfield.cpp}::WARP_TRAIL_SEGMENTS = 5
constexpr

Definition at line 58 of file starfield.cpp.