MXVK Vulkan Framework 0.35.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_LAYERS > LAYERS
constexpr int NUM_LAYERS = 3
constexpr int NUM_PARTICLES = 50000
constexpr int WARP_TRAIL_SEGMENTS = 5

Enumeration Type Documentation

◆ StarType

Function Documentation

◆ random_float()

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

Definition at line 59 of file starfield.cpp.

59 {
60 static std::random_device rd;
61 static std::default_random_engine engine(rd());
62 std::uniform_real_distribution<float> dist(min, max);
63 return dist(engine);
64 }

◆ random_star_type()

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

Definition at line 66 of file starfield.cpp.

66 {
67 const float r = random_float(0.0f, 1.0f);
68 if (r < 0.50f) {
69 return StarType::NORMAL;
70 }
71 if (r < 0.65f) {
72 return StarType::BLUE;
73 }
74 if (r < 0.75f) {
75 return StarType::YELLOW;
76 }
77 if (r < 0.85f) {
78 return StarType::ORANGE;
79 }
80 if (r < 0.92f) {
81 return StarType::RED;
82 }
83 return StarType::BRIGHT;
84 }
float random_float(float min, float max)
Definition starfield.cpp:59

◆ star_color()

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

Definition at line 86 of file starfield.cpp.

86 {
87 switch (type) {
88 case StarType::BLUE:
89 return glm::vec4(0.6f * brightness, 0.8f * brightness, 1.0f * brightness, 1.0f);
91 return glm::vec4(1.0f * brightness, 0.7f * brightness, 0.3f * brightness, 1.0f);
92 case StarType::RED:
93 return glm::vec4(1.0f * brightness, 0.4f * brightness, 0.4f * brightness, 1.0f);
95 return glm::vec4(1.0f * brightness, 1.0f * brightness, 0.6f * brightness, 1.0f);
97 return glm::vec4(1.0f * brightness, 1.0f * brightness, 1.0f * brightness, 1.0f);
99 default:
100 return glm::vec4(0.9f * brightness, 0.9f * brightness, 1.0f * brightness, 1.0f);
101 }
102 }

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 53 of file starfield.cpp.

◆ NUM_LAYERS

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

Definition at line 50 of file starfield.cpp.

◆ NUM_PARTICLES

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

Definition at line 49 of file starfield.cpp.

◆ WARP_TRAIL_SEGMENTS

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

Definition at line 51 of file starfield.cpp.