title: c++ & OpenGl: How do you create a mesh object instance from within a class
body: <p>I'm a <code>c++</code> beginner , trying to build my first application with <code>openGL</code>. </p>
  
  <p>I'm trying to create a Room class that will take parameters like width, length and height to create a mesh object which I then want to draw from the main function.</p>
  
  <p>At the moments I'm not trying to initialize Room with any parameters, just trying to create a basic mesh from within room, CPP rather than from main.</p>
  
  <p>I'm having trouble creating a mesh object as a private variable within the class room, and then defining a method to draw it by calling it from main.</p>
  
  <p>I'm using Benny's awesome tutorial and have his exact GitHub files on my visual studio solution.</p>
  
  <p>Im posting it here, they include the mesh.h and mesh. CPP which are probably where the problem is coming from <a href="https://github.com/BennyQBD/ModernOpenGLTutorial" rel="nofollow">this link</a>.</p>
  
  <p>Here is the current code (I've included everything I include in main, just to make sure)</p>
  
  <p><strong>----Room.h ---------------</strong></p>
  
  <pre><code>#pragma once
  
  #include &lt;iostream&gt;
  #include &lt;SDL2/SDL.h&gt;
  #include "display.h"
  #include "mesh.h"
  #include "shader.h"
  #include "texture.h"
  #include "transform.h"
  #include "camera.h"
  
  
  class Room
  {
  public:
   Room();
   ~Room();
   void drawRoom();
  
  private:
   Mesh* mesh;
  
  };
  </code></pre>
  
  <p>----Room.cpp ---------------</p>
  
  <pre><code>#include "Room.h"
  #include &lt;iostream&gt;
  #include &lt;SDL2/SDL.h&gt;
  #include "display.h"
  #include "mesh.h"
  #include "shader.h"
  #include "texture.h"
  #include "transform.h"
  #include "camera.h"
  
  
  Room::Room()
  { 
   Vertex vertices[] =
   {
    Vertex(glm::vec3(-1, -1, -1), glm::vec2(1, 0), glm::vec3(0, 0, -1)),
    Vertex(glm::vec3(-1, 1, -1), glm::vec2(0, 0), glm::vec3(0, 0, -1)),
    Vertex(glm::vec3(1, 1, -1), glm::vec2(0, 1), glm::vec3(0, 0, -1)),
    Vertex(glm::vec3(1, -1, -1), glm::vec2(1, 1), glm::vec3(0, 0, -1)),
  
    Vertex(glm::vec3(-1, -1, 1), glm::vec2(1, 0), glm::vec3(0, 0, 1)),
    Vertex(glm::vec3(-1, 1, 1), glm::vec2(0, 0), glm::vec3(0, 0, 1)),
    Vertex(glm::vec3(1, 1, 1), glm::vec2(0, 1), glm::vec3(0, 0, 1)),
    Vertex(glm::vec3(1, -1, 1), glm::vec2(1, 1), glm::vec3(0, 0, 1)),
  
    Vertex(glm::vec3(-1, -1, -1), glm::vec2(0, 1), glm::vec3(0, -1, 0)),
    Vertex(glm::vec3(-1, -1, 1), glm::vec2(1, 1), glm::vec3(0, -1, 0)),
    Vertex(glm::vec3(1, -1, 1), glm::vec2(1, 0), glm::vec3(0, -1, 0)),
    Vertex(glm::vec3(1, -1, -1), glm::vec2(0, 0), glm::vec3(0, -1, 0)),
  
    Vertex(glm::vec3(-1, 1, -1), glm::vec2(0, 1), glm::vec3(0, 1, 0)),
    Vertex(glm::vec3(-1, 1, 1), glm::vec2(1, 1), glm::vec3(0, 1, 0)),
    Vertex(glm::vec3(1, 1, 1), glm::vec2(1, 0), glm::vec3(0, 1, 0)),
    Vertex(glm::vec3(1, 1, -1), glm::vec2(0, 0), glm::vec3(0, 1, 0)),
  
    Vertex(glm::vec3(-1, -1, -1), glm::vec2(1, 1), glm::vec3(-1, 0, 0)),
    Vertex(glm::vec3(-1, -1, 1), glm::vec2(1, 0), glm::vec3(-1, 0, 0)),
    Vertex(glm::vec3(-1, 1, 1), glm::vec2(0, 0), glm::vec3(-1, 0, 0)),
    Vertex(glm::vec3(-1, 1, -1), glm::vec2(0, 1), glm::vec3(-1, 0, 0)),
  
    Vertex(glm::vec3(1, -1, -1), glm::vec2(1, 1), glm::vec3(1, 0, 0)),
    Vertex(glm::vec3(1, -1, 1), glm::vec2(1, 0), glm::vec3(1, 0, 0)),
    Vertex(glm::vec3(1, 1, 1), glm::vec2(0, 0), glm::vec3(1, 0, 0)),
    Vertex(glm::vec3(1, 1, -1), glm::vec2(0, 1), glm::vec3(1, 0, 0)),
   };
  
   unsigned int indices[] = { 0, 1, 2,
    0, 2, 3,
  
    6, 5, 4,
    7, 6, 4,
  
    10, 9, 8,
    11, 10, 8,
  
    12, 13, 14,
    12, 14, 15,
  
    16, 17, 18,
    16, 18, 19,
  
    22, 21, 20,
    23, 22, 20
   };
  
   mesh = new Mesh(vertices, sizeof(vertices) / sizeof(vertices[0]), indices, sizeof(indices) / sizeof(indices[0]));
  
  }
  
  Room::~Room()
  {
  }
  
  void Room::drawRoom()
  {
      mesh.Draw();
  }
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <p>Error   C2228   left of '.Draw' must have class/struct/union    ArchProgramer   c:\users\nuno bártolo\documents\visual studio 2015\projects\archprogramer\archprogramer\room.cpp    78  </p>
  
  <p>Thank very much you for your help!</p>