title: How do I pass vertices[] to a constructor?
body: <p>I am using C++ and OpenGL. I'm trying to do some mock design of a model loader and renderer. </p>
  
  <p>Here is where I'm getting stuck:</p>
  
  <p>I have been drawing to the screen with my renderer class and window class, no problems there.
  I'm using a generic model class that until now was hard coded to take vertices[108] and colors[108] and draw a cube. This works and I could instance hundreds of cubes just fine. However, I was always creating the model(s) by using vertices[108] and colors[108]. </p>
  
  <p>Now I want to ditch the [108] and just pass vertices and colors of any sizes into the model constructor. </p>
  
  <p>Right now it looks like in pseudo code:</p>
  
  <pre><code>//this is in main.cpp
  GLfloat vertices[108] = {
  //vertices here
  };
  GLfloat colors[108] = {
  //colors
  };
  mynamespace::Model::cube(vertices,colors);
  </code></pre>
  
  <p>That is how I a have been using this and within the model class:</p>
  
  <pre><code>`//this is in model class declaration
  GLfloat vertices_[108];
  GLfloat colors_[108];
  //then in the constructor definition
  Model::Model(vertices,colors) {
  //loop through, i&lt;108, and assign vertices,colors to vertices_,colors_
  }
  `
  </code></pre>
  
  <p>This has worked fine for learning purposes. I now would like to start creating various size vertices[] and sending them along to the Model constructor. (The number of vertices and colors will match - will check that). But I am having a hard time removing that hard coded index, e.g. vertices[108], and just sending along vertices[unknown until it arrives].</p>
  
  <p>I thought, worst case,  I could send a vertices[] through and then in the constructor defn, receive the vertices, check the sizeof() and divide by 4 and assign values by loop if nothing else would work. However, when I send any size vertices[] through and print out the sizeof() to check it, I always get 4 bytes...and nothing draws of course.</p>
  
  <p>To be clear, I'm not getting errors in my code and I don't have a particular code I want to debug so I'm not pasting an existing code sample to solve anything. This is meant to be here is what I'm trying to do, what are some recommendations from experienced folks. </p>
  
  <p>What is a good practice for doing this type of thing? </p>
  
  <p>After this, I want to start loading mesh from files but first I want to understand how I am supposed to pass along various amounts of vertices and make a model so I can send models to the renderer. </p>