<commit_before>#include "atlas/primitives/Primitive.hpp"

namespace atlas
{
    namespace primitives
    {
        Primitive::Primitive() :
            mVao(),
            mDataBuffer(GL_ARRAY_BUFFER),
            mIndexBuffer(GL_ELEMENT_ARRAY_BUFFER)
        { }

        Primitive::~Primitive()
        { }

        void Primitive::createBuffers()
        { 
            USING_ATLAS_MATH_NS;

            // Compile all the data into a single vector.
            std::vector<float> data;

            // Interleave vector and normal data.
            for (size_t i = 0; i < mVertices.size(); ++i)
            {
                data.push_back(mVertices[i].x);
                data.push_back(mVertices[i].y);
                data.push_back(mVertices[i].z);

                data.push_back(mNormals[i].x);
                data.push_back(mNormals[i].y);
                data.push_back(mNormals[i].z);
            }

            mVao.bindVertexArray();

            mDataBuffer.bindBuffer();
            mDataBuffer.bufferData(data.size() * sizeof(float),
                data.data(), GL_DYNAMIC_DRAW);

            // Vertices go in location 0.
            mDataBuffer.vertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,
                STRIDE(6, float), BUFFER_OFFSET(0));

            // Normals go in location 1.
            mDataBuffer.vertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE,
                STRIDE(6, float), BUFFER_OFFSET(3 * sizeof(float)));

            mIndexBuffer.bindBuffer();
            mIndexBuffer.bufferData(mIndices.size() * sizeof(GLuint),
                mIndices.data(), GL_DYNAMIC_DRAW);

            mVao.enableVertexAttribArray(0);
            mVao.enableVertexAttribArray(1);

            mVao.unBindVertexArray();
        }

        void Primitive::updateBuffers()
        {
            USING_ATLAS_MATH_NS;

            // Compile all the data into a single vector.
            std::vector<float> data;

            // Interleave vector and normal data.
            for (size_t i = 0; i < mVertices.size(); ++i)
            {
                data.push_back(mVertices[i].x);
                data.push_back(mVertices[i].y);
                data.push_back(mVertices[i].z);

                data.push_back(mNormals[i].x);
                data.push_back(mNormals[i].y);
                data.push_back(mNormals[i].z);
            }

            mVao.bindVertexArray();

            mDataBuffer.bindBuffer();
            mDataBuffer.bufferSubData(0, data.size() * sizeof(float), data.data());

            mIndexBuffer.bindBuffer();
            mIndexBuffer.bufferSubData(0, mIndices.size() * sizeof(GLuint),
                mIndices.data());
        }

        void Primitive::drawPrimitive()
        {
            mVao.bindVertexArray();
            glDrawElements(GL_TRIANGLES, (int)mIndices.size(),
                GL_UNSIGNED_INT, (void*)0);
            mVao.unBindVertexArray();
        }

        void Primitive::drawPrimitive(GLenum mode)
        {
            mVao.bindVertexArray();
            glDrawElements(mode, (int)mIndices.size(), GL_UNSIGNED_INT,
                BUFFER_OFFSET(0));
            mVao.unBindVertexArray();
        }

        std::vector<atlas::math::Point>& Primitive::getVertices()
        {
            return mVertices;
        }

        std::vector<atlas::math::Normal>& Primitive::getNormals()
        {
            return mNormals;
        }

        std::vector<GLuint>& Primitive::getIndeces()
        {
            return mIndices;
        }
    }
}<commit_msg>[brief] Updates Buffer macro usage.<commit_after>#include "atlas/primitives/Primitive.hpp"

namespace atlas
{
    namespace primitives
    {
        Primitive::Primitive() :
            mVao(),
            mDataBuffer(GL_ARRAY_BUFFER),
            mIndexBuffer(GL_ELEMENT_ARRAY_BUFFER)
        { }

        Primitive::~Primitive()
        { }

        void Primitive::createBuffers()
        { 
            USING_ATLAS_MATH_NS;

            // Compile all the data into a single vector.
            std::vector<float> data;

            // Interleave vector and normal data.
            for (size_t i = 0; i < mVertices.size(); ++i)
            {
                data.push_back(mVertices[i].x);
                data.push_back(mVertices[i].y);
                data.push_back(mVertices[i].z);

                data.push_back(mNormals[i].x);
                data.push_back(mNormals[i].y);
                data.push_back(mNormals[i].z);
            }

            mVao.bindVertexArray();

            mDataBuffer.bindBuffer();
            mDataBuffer.bufferData(data.size() * sizeof(float),
                data.data(), GL_DYNAMIC_DRAW);

            // Vertices go in location 0.
            mDataBuffer.vertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,
                STRIDE(6, float), BUFFER_OFFSET(0, float));

            // Normals go in location 1.
            mDataBuffer.vertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE,
                STRIDE(6, float), BUFFER_OFFSET(3, float));

            mIndexBuffer.bindBuffer();
            mIndexBuffer.bufferData(mIndices.size() * sizeof(GLuint),
                mIndices.data(), GL_DYNAMIC_DRAW);

            mVao.enableVertexAttribArray(0);
            mVao.enableVertexAttribArray(1);

            mVao.unBindVertexArray();
        }

        void Primitive::updateBuffers()
        {
            USING_ATLAS_MATH_NS;

            // Compile all the data into a single vector.
            std::vector<float> data;

            // Interleave vector and normal data.
            for (size_t i = 0; i < mVertices.size(); ++i)
            {
                data.push_back(mVertices[i].x);
                data.push_back(mVertices[i].y);
                data.push_back(mVertices[i].z);

                data.push_back(mNormals[i].x);
                data.push_back(mNormals[i].y);
                data.push_back(mNormals[i].z);
            }

            mVao.bindVertexArray();

            mDataBuffer.bindBuffer();
            mDataBuffer.bufferSubData(0, data.size() * sizeof(float), data.data());

            mIndexBuffer.bindBuffer();
            mIndexBuffer.bufferSubData(0, mIndices.size() * sizeof(GLuint),
                mIndices.data());
        }

        void Primitive::drawPrimitive()
        {
            mVao.bindVertexArray();
            glDrawElements(GL_TRIANGLES, (int)mIndices.size(),
                GL_UNSIGNED_INT, (void*)0);
            mVao.unBindVertexArray();
        }

        void Primitive::drawPrimitive(GLenum mode)
        {
            mVao.bindVertexArray();
            glDrawElements(mode, (int)mIndices.size(), GL_UNSIGNED_INT,
                BUFFER_OFFSET(0, GLuint));
            mVao.unBindVertexArray();
        }

        std::vector<atlas::math::Point>& Primitive::getVertices()
        {
            return mVertices;
        }

        std::vector<atlas::math::Normal>& Primitive::getNormals()
        {
            return mNormals;
        }

        std::vector<GLuint>& Primitive::getIndeces()
        {
            return mIndices;
        }
    }
}
{'fraction_non_alphanumeric': 0.11725601131541726, 'fraction_numerical': 0.005091937765205092, 'mean_word_length': 1.657271702367531, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3000200', 'n_tokens_mistral': 2175, 'n_tokens_neox': 2072, 'n_words': 310}