samedi 23 mai 2020

How can assign values to a array after initialization

I am initializing an array

float 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 
    };

after initializing i can again write values to the array using array index operator []

verticesRect[0] = 3;

but to change all the values i would have to go through all the indices , can i do something like this ?

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

Aucun commentaire:

Enregistrer un commentaire