Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned int offset = 0;
- unsigned int multiplier = 3;
- if (hasTextCoord) {
- multiplier += 2;
- }
- if (hasNormCoord) {
- multiplier += 3;
- }
- if (normalMapping) {
- multiplier += 6;
- }
- glGenVertexArrays(1, &VAO);
- glGenBuffers(1, &VBO);
- glBindVertexArray(VAO);
- glBindBuffer(GL_ARRAY_BUFFER, VBO);
- glBufferData(GL_ARRAY_BUFFER, meshData.amountVertices * sizeof(GLfloat), &meshData.vertices[0], GL_STATIC_DRAW);
- // set the vertices
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, multiplier * sizeof(GLfloat), (GLvoid*)offset);
- glEnableVertexAttribArray(0);
- offset += 3;
- // set the textCoordinates
- if (hasTextCoord && enableTextCoord) {
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, multiplier * sizeof(GLfloat), (GLvoid*)(offset * sizeof(GLfloat)));
- glEnableVertexAttribArray(1);
- offset += 2;
- }
- else if (hasTextCoord && !enableTextCoord) {
- offset += 2;
- }
- // set the normalCoordinates
- if (hasNormCoord && enableNormCoord) {
- glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, multiplier * sizeof(GLfloat), (GLvoid *)(offset * sizeof(GLfloat)));
- glEnableVertexAttribArray(2);
- offset += 3;
- }
- else if (hasNormCoord && !enableNormCoord) {
- offset += 3;
- }
- if (normalMapping) {
- // set the tangent
- glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, multiplier * sizeof(GLfloat), (GLvoid *)(offset * sizeof(GLfloat)));
- glEnableVertexAttribArray(3);
- offset += 3;
- // set the bitangent
- glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, multiplier * sizeof(GLfloat), (GLvoid *)(offset * sizeof(GLfloat)));
- glEnableVertexAttribArray(4);
- offset += 3;
- }
- glBindVertexArray(0);
- this->amountVertices = meshData.amountVertices;
- delete meshData.vertices;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement