/** * Copyright (c) 2026 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "display/mesh/mesh.h" #include "display/color.h" #define SPHERE_STACKS 8 #define SPHERE_SECTORS 16 #define SPHERE_VERTEX_COUNT (SPHERE_STACKS * SPHERE_SECTORS * 6) #define SPHERE_PRIMITIVE_TYPE MESH_PRIMITIVE_TYPE_TRIANGLES extern mesh_t SPHERE_MESH_SIMPLE; extern meshvertex_t SPHERE_MESH_SIMPLE_VERTICES[SPHERE_VERTEX_COUNT]; /** * Initializes the simple unit sphere mesh centered at (0,0,0) with radius 0.5. * * @return Error for initialization of the sphere mesh. */ errorret_t sphereInit(); /** * Buffers a UV sphere into the provided vertex array. * Writes stacks * sectors * 6 vertices (CCW winding). * * @param vertices Vertex array to write into (must hold stacks*sectors*6). * @param center Center position of the sphere. * @param radius Radius of the sphere. * @param stacks Number of horizontal rings (latitude bands). * @param sectors Number of vertical segments (longitude slices). * @param color Color applied to all vertices. */ void sphereBuffer( meshvertex_t *vertices, const vec3 center, const float_t radius, const int32_t stacks, const int32_t sectors #if MESH_ENABLE_COLOR , const color_t color #endif );