
.. _program_listing_file_Src_GraphicsEngineOpenGL_scene_Vertex.ixx:

Program Listing for File Vertex.ixx
===================================

|exhale_lsh| :ref:`Return to documentation for file <file_Src_GraphicsEngineOpenGL_scene_Vertex.ixx>` (``Src/GraphicsEngineOpenGL/scene/Vertex.ixx``)

.. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS

.. code-block:: cpp

   module;
   
   #define GLM_ENABLE_EXPERIMENTAL
   #include <functional>
   #include <glm/glm.hpp>
   #include <glm/gtx/hash.hpp>
   
   export module kataglyphis.opengl.vertex;
   
   export struct Vertex
   {
     public:
       glm::vec3 position;
       glm::vec3 normal;
       glm::vec3 color;
       glm::vec2 texture_coords;
   
       Vertex()
       {
           this->position = glm::vec3(0);
           this->normal = glm::vec3(0);
           this->color = glm::vec3(0);
           this->texture_coords = glm::vec2(0);
       }
   
       Vertex(glm::vec3 pos, glm::vec3 normal, glm::vec3 color, glm::vec2 texture_coords)
       {
           this->position = pos;
           this->normal = normal;
           this->color = color;
           this->texture_coords = texture_coords;
       };
   
       glm::vec3 get_position() const { return position; }
   
       glm::vec3 get_normal() const { return normal; }
   
       glm::vec3 get_color() const { return color; }
   
       glm::vec2 get_tex_coors() const { return texture_coords; }
   
       bool operator==(const Vertex &other) const
       {
           return position == other.position && normal == other.normal && texture_coords == other.texture_coords
                  && color == other.color;
       }
   };
   
   export namespace std {
   
   template<> struct hash<Vertex>
   {
       size_t operator()(Vertex const &vert) const
       {
           size_t h1 = hash<glm::vec3>()(vert.position);
           size_t h2 = hash<glm::vec3>()(vert.normal);
           size_t h3 = hash<glm::vec2>()(vert.texture_coords);
   
           return ((h1 ^ (h2 << 1)) >> 1) ^ h3;
       }
   };
   }// namespace std
