lundi 25 novembre 2019

How to use class private varibles in a array

I want my array to have class members as input data and use it in class functions.

GLfloat verticesRect[] = {
        // Positions        // Normal Coords          // Texture Coords
        width,  height, 0.0f,    0.0 , 0.0, 1.0 ,     1.0f, 0.0f,   // Top Right
        width, -height, 0.0f,    0.0 , 0.0, 1.0 ,     1.0f, 1.0f,   // Bottom Right
              -width, -height, 0.0f,    0.0 , 0.0, 1.0 ,     0.0f, 1.0f,   // Bottom Left
             -width,  height, 0.0f,    0.0 , 0.0, 1.0 ,     0.0f, 0.0f    // Top Left 
    };

currently i am declaring the array as local variable in all the functions , can i just declare once and than use it.

class test
{
  private:
    width;
    height;

public:
   init();  // this function will use the vertices
   getMesh() // this function will use the vertices

};

Aucun commentaire:

Enregistrer un commentaire