22 Image img = GenImageColor(width, height, BLANK);
23 for (
int y = 0; y < height; y++) {
24 float t =
static_cast<float>(y) / (height - 1);
25 unsigned char r =
static_cast<unsigned char>(10 * (1.0f - t));
26 unsigned char g =
static_cast<unsigned char>(5 * (1.0f - t));
27 unsigned char b =
static_cast<unsigned char>(20 * (1.0f - t));
28 ImageDrawRectangle(&img, 0, y, width, 1, {r, g, b, 255});
31 std::random_device rd;
32 std::mt19937 gen(rd());
33 std::uniform_int_distribution<> distX(0, width - 1);
34 std::uniform_int_distribution<> distY(0, height - 1);
35 std::uniform_int_distribution<> distIntensity(100, 255);
38 for (
int i = 0; i < 2000; ++i) {
42 int intensity = distIntensity(gen);
43 unsigned char c =
static_cast<unsigned char>(intensity);
45 ImageDrawPixel(&img, x, y, {c, c,
static_cast<unsigned char>(c > 200 ? 255 : c), 255});
58 Image img = GenImageColor(width, height, BLANK);
59 for (
int y = 0; y < height; y++) {
60 float t =
static_cast<float>(y) / (height - 1);
61 unsigned char r =
static_cast<unsigned char>(80 * (1.0f - t) + 180 * t);
62 unsigned char g =
static_cast<unsigned char>(150 * (1.0f - t) + 210 * t);
63 unsigned char b =
static_cast<unsigned char>(220 * (1.0f - t) + 240 * t);
64 ImageDrawRectangle(&img, 0, y, width, 1, {r, g, b, 255});
84 rlDisableBackfaceCulling();
92 float dayFactor = std::sin(
_timeOfDay * 2.0f * PI) * 0.5f + 0.5f;
94 if (dayFactor > 0.01f) {
95 unsigned char alpha =
static_cast<unsigned char>(dayFactor * 255.0f);
97 DrawModel(
_sphereModel, camera.position, 1.0f, {255, 255, 255, alpha});
101 rlEnableBackfaceCulling();
114 int numVertices = (rings + 1) * (slices + 1);
115 int numIndices = rings * slices * 6;
117 mesh.vertexCount = numVertices;
118 mesh.triangleCount = numIndices / 3;
119 mesh.vertices = (
float*)MemAlloc(numVertices * 3 *
sizeof(
float));
120 mesh.texcoords = (
float*)MemAlloc(numVertices * 2 *
sizeof(
float));
121 mesh.normals = (
float*)MemAlloc(numVertices * 3 *
sizeof(
float));
122 mesh.indices = (
unsigned short*)MemAlloc(numIndices *
sizeof(
unsigned short));
125 for (
int i = 0; i <= rings; i++) {
126 float v =
static_cast<float>(i) / rings;
129 for (
int j = 0; j <= slices; j++) {
130 float u =
static_cast<float>(j) / slices;
131 float theta = u * PI * 2.0f;
133 float x = std::cos(theta) * std::sin(phi);
134 float y = std::cos(phi);
135 float z = std::sin(theta) * std::sin(phi);
137 mesh.vertices[vIndex * 3 + 0] = radius * x;
138 mesh.vertices[vIndex * 3 + 1] = radius * y;
139 mesh.vertices[vIndex * 3 + 2] = radius * z;
141 mesh.normals[vIndex * 3 + 0] = x;
142 mesh.normals[vIndex * 3 + 1] = y;
143 mesh.normals[vIndex * 3 + 2] = z;
145 mesh.texcoords[vIndex * 2 + 0] = u;
146 mesh.texcoords[vIndex * 2 + 1] = v;
152 for (
int i = 0; i < rings; i++) {
153 for (
int j = 0; j < slices; j++) {
154 int current = i * (slices + 1) + j;
155 int next = current + slices + 1;
157 mesh.indices[iIndex++] = current;
158 mesh.indices[iIndex++] = next;
159 mesh.indices[iIndex++] = current + 1;
161 mesh.indices[iIndex++] = current + 1;
162 mesh.indices[iIndex++] = next;
163 mesh.indices[iIndex++] = next + 1;
167 UploadMesh(&mesh,
false);