#pragma once #include "GLFunctions.hpp" #include #include namespace planetarium { // ----------------------------------------------------------------------- // Mesh // // Owns a VAO/VBO/(optional)EBO describing an interleaved // position+normal+uv vertex stream, plus static factory methods that // procedurally build a few common primitive shapes (spheres, rings, // circles) so a project has no dependency on external model files. // ----------------------------------------------------------------------- struct Vertex { glm::vec3 position; glm::vec3 normal; glm::vec2 uv; }; class Mesh { public: Mesh() = default; ~Mesh(); Mesh(const Mesh&) = delete; Mesh& operator=(const Mesh&) = delete; Mesh(Mesh&& other) noexcept; Mesh& operator=(Mesh&& other) noexcept; void upload(const std::vector& vertices, const std::vector& indices); void uploadLineStrip(const std::vector& points); void draw() const; void drawLineStrip() const; static Mesh createUVSphere(int stacks, int slices); static Mesh createRing(float innerRadius, float outerRadius, int segments); static Mesh createOrbitCircle(int segments); // unit circle in XZ private: void release(); GLuint vao_ = 0; GLuint vbo_ = 0; GLuint ebo_ = 0; GLsizei indexCount_ = 0; GLsizei vertexCount_ = 0; bool isLineStrip_ = false; }; } // namespace planetarium