Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Allocate an OpenGL vertex array object.
- OpenGL->glGenVertexArrays(1, &m_vertexArrayId);
- // Bind the vertex array object to store all the buffers and vertex attributes we create here.
- OpenGL->glBindVertexArray(m_vertexArrayId);
- // Generate an ID for the vertex buffer.
- OpenGL->glGenBuffers(1, &m_vertexBufferId);
- // Bind the vertex buffer and load the vertex (position and color) data into the vertex buffer.
- OpenGL->glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferId);
- OpenGL->glBufferData(GL_ARRAY_BUFFER, m_vertexCount * sizeof(VertexType), vertices, GL_STATIC_DRAW);
- // Enable the two vertex array attributes.
- OpenGL->glEnableVertexAttribArray(0); // Vertex position.
- OpenGL->glEnableVertexAttribArray(1); // Vertex color.
- // Specify the location and format of the position portion of the vertex buffer.
- OpenGL->glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferId);
- OpenGL->glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(VertexType), 0);
- // Specify the location and format of the color portion of the vertex buffer.
- OpenGL->glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferId);
- OpenGL->glVertexAttribPointer(1, 3, GL_FLOAT, false, sizeof(VertexType), (unsigned char*)NULL + (3 * sizeof(float)));
- // Generate an ID for the index buffer.
- OpenGL->glGenBuffers(1, &m_indexBufferId);
- // Bind the index buffer and load the index data into it.
- OpenGL->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferId);
- OpenGL->glBufferData(GL_ELEMENT_ARRAY_BUFFER, m_indexCount* sizeof(unsigned int), indices, GL_STATIC_DRAW);
Advertisement
Add Comment
Please, Sign In to add comment