MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / genBuffers

Method genBuffers

src/Scene/Track.cpp:85–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85bool Track::genBuffers() {
86 glGenVertexArrays(1, &VertexArrayID);
87 glBindVertexArray(VertexArrayID);
88 // 1st attribute buffer : Vertices
89 glGenBuffers(1, &vertexbuffer);
90 glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
91 glBufferData(GL_ARRAY_BUFFER, m_vertices.size() * sizeof(glm::vec3), &m_vertices[0], GL_STATIC_DRAW);
92 glVertexAttribPointer(
93 0, // attribute
94 3, // size
95 GL_FLOAT, // type
96 GL_FALSE, // normalized?
97 0, // stride
98 (void *) 0 // array buffer offset
99 );
100 glEnableVertexAttribArray(0);
101 // 2nd attribute buffer : UVs
102 glGenBuffers(1, &uvbuffer);
103 glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
104 glBufferData(GL_ARRAY_BUFFER, m_uvs.size() * sizeof(glm::vec2), &m_uvs[0], GL_STATIC_DRAW);
105 glVertexAttribPointer(
106 1, // attribute
107 2, // size
108 GL_FLOAT, // type
109 GL_FALSE, // normalized?
110 0, // stride
111 (void *) 0 // array buffer offset
112 );
113 glEnableVertexAttribArray(1);
114 // 3rd attribute buffer : Track Normals
115 glGenBuffers(1, &normalBuffer);
116 glBindBuffer(GL_ARRAY_BUFFER, normalBuffer);
117 glBufferData(GL_ARRAY_BUFFER, m_normals.size() * sizeof(glm::vec3), &m_normals[0], GL_STATIC_DRAW);
118 glVertexAttribPointer(
119 2, // attribute
120 3, // size
121 GL_FLOAT, // type
122 GL_FALSE, // normalized?
123 0, // stride
124 (void *) 0 // array buffer offset
125 );
126 glEnableVertexAttribArray(2);
127 // 4th attribute buffer : Texture Indices
128 glGenBuffers(1, &textureIndexBuffer);
129 glBindBuffer(GL_ARRAY_BUFFER, textureIndexBuffer);
130 glBufferData(GL_ARRAY_BUFFER, m_texture_indices.size() * sizeof(unsigned int), &m_texture_indices[0], GL_STATIC_DRAW);
131 glVertexAttribIPointer(
132 3,
133 1,
134 GL_UNSIGNED_INT,
135 0,
136 (void *) 0
137 );
138 glEnableVertexAttribArray(3);
139 // 5th attribute buffer : NFS Shading Data
140 glGenBuffers(1, &shadingBuffer);
141 glBindBuffer(GL_ARRAY_BUFFER, shadingBuffer);
142 glBufferData(GL_ARRAY_BUFFER, m_shading_data.size() * sizeof(glm::vec4), &m_shading_data[0], GL_STATIC_DRAW);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected