Im currently trying to figure out how VBO stuff is working which results in horrible problems sadly : /
im loading the data from an .obj file (see: http://pastebin.com/B8uibDvV for the .obj file)
and (trying to) put it into a VBO
my code to bind the data looks like this:
//Generate Buffers
glGenBuffers(1, &this->glVerticesBufferID);
glGenBuffers(1, &this->glIndexBufferID);
//bind the buffers to set the data
glBindBuffer(GL_ARRAY_BUFFER, this->glVerticesBufferID);
glBufferData(GL_ARRAY_BUFFER, this->verticesList.size() * sizeof(GLfloat), 0, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->glIndexBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->indexList.size() * sizeof(GLshort), 0, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, this->verticesList.size(), this->verticesList.data());
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, this->indexList.size(), this->indexList.data());
//Clear binds
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
at the end im rendering everything with this:
glBindBuffer(GL_ARRAY_BUFFER, this->glVerticesBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->glIndexBufferID);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawElements(GL_TRIANGLES, this->indexList.size(), GL_UNSIGNED_SHORT, this->indexList.data());
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
and at the end i get the access violation message in the output of VisualStudio 2010
0xC0000005: Access violation reading location 0x0147fbd8.
So my question is
how to fix this? (or how to do it right if im that wrong)
---------------EDIT 1---------------
http://pastebin.com/DEbZH9iy
Bind data
glGenBuffers(1, &this->glVerticesBufferID);
glBindBuffer(GL_ARRAY_BUFFER, this->glVerticesBufferID);
glBufferData(GL_ARRAY_BUFFER, (this->verticesList.size() + this->textureCoordList.size() + this->normalsList.size()) * sizeof(GLfloat), 0, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER,
0,
this->verticesList.size() * sizeof(GLfloat),
this->verticesList.data()
);
glBufferSubData(
GL_ARRAY_BUFFER,
this->verticesList.size() * sizeof(GLfloat),
this->normalsList.size() * sizeof(GLfloat),
this->normalsList.data()
);
glBufferSubData(
GL_ARRAY_BUFFER,
(this->verticesList.size() + this->normalsList.size()) * sizeof(GLfloat),
this->textureCoordList.size() * sizeof(GLfloat),
this->textureCoordList.data()
);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &this->glIndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->glIndexBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, this->indexList.size() * sizeof(GLushort), this->indexList.data(), GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
pub_glVerticesBufferID = glVerticesBufferID;
pub_glIndexBufferID = glIndexBufferID;
Render part:
glBindBuffer(GL_ARRAY_BUFFER, this->glVerticesBufferID);
glVertexPointer(3, GL_FLOAT, 3 * sizeof(GLfloat), (GLvoid*)0);
glNormalPointer(GL_FLOAT, 3 * sizeof(GLfloat), (GLvoid*)(this->verticesList.size() * sizeof(GLfloat)));
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), (GLvoid*)((this->normalsList.size() + this->verticesList.size()) * sizeof(GLfloat)));
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->glIndexBufferID);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
You probably didn't initialize the entry points for functionality introduced after OpenGL-1.1. In Windows only the OpenGL-1.1 entry points are specified, everything beyond must be initialized at runtime. Otherwise you get an access violation. Have a look at GLEW for a convenient way to do that tedious task with just 3 lines of code.
That being said, your code still got mistakes:
You need to tell OpenGL where where from the buffer exactly it shall take it's elements. This done by calling the gl…Pointer functions with the data elements being a byte offset into the buffer. Your code misses that. Also glDrawElements no longer expects are pointer put an offset as well.
But with buffer objects being bound this shouldn't cause a segfault/access violation.
Related
I'm trying to draw a textured cube in OpengL.
At first, I initialize VBO and VAO in the class constructor as follows.
Block::Block(...)
{
glGenBuffers(1, &VBO);
glGenVertexArrays(1, &VAO);
//glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBindVertexArray(VAO);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(3 *
sizeof(float)));
glEnableVertexAttribArray(1);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(6 *
sizeof(float)));
glEnableVertexAttribArray(2);
}
and in the method called renderBlock(), I render the cube like this
void Block::renderBlock()
{
setMatrix();
shader.use();
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBindVertexArray(VAO);
glActiveTexture(GL_TEXTURE0);
shader.setInt("tex", 0);
shader.use();
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glBindTexture(GL_TEXTURE_2D, texture);
glBindVertexArray(VAO);
glDrawArrays(GL_TRIANGLES, 0, 6);
}
and if I call the block.renderBlock(), the program will crash at glDrawArrays(GL_TRIANGLES, 0, 6);. The error message says that 0xC0000005: Access conflict occurred at read position 0x0000000000000000.. But if I uncomment the //glBindBuffer(GL_ARRAY_BUFFER, VBO); in constructer, the program will run successfully. It's very confusing to me. Why should I bind the VBO before I edit the VAO. Is there any connection between them?Any advice would be greatly appreciated.
You must bind the VBO before calling glVertexAttribPointer. When glVertexAttribPointer is called, the buffer currently bound to the GL_ARRAY_BUFFER target is associated with the specified attribute index and the ID of the buffer object is stored in the state vector of the currently bound VAO. Therefore, the VAO and the VBO must be bound before calling glVertexAttribPointer.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I'm trying to display two shapes in OpenGL.
First I got the vertices,uvs, normals,indices from an obj file and texture form DDS and stored them in an array of struct Shape.
Then I indexed the vertices, uvs, normals and indices for all the shapes in 4 respective array, also storing the number of total number of vertices, uvs , normals and indices in another vector.
Then I initialized the VBOs.
Then I creates vertex array objects for the two shapes and set them up giving respective VertexAttribPointer. (I think the problem is in this step)
Finally I bind the respective VAOs and display them but only one shape is being displayed.
Where exactly am I going wrong.
Code for VBOindexing :
std::vector<glm::vec4> elecount;
long long int endind = 0,endver=0,enduv=0,endnr=0;
std::vector<unsigned short> indices;
std::vector<glm::vec3> indexed_vertices;
std::vector<glm::vec2> indexed_uvs;
std::vector<glm::vec3> indexed_normals;
for (int i = 0;i < componentcount ;i++)
{
endver = endind = enduv = endnr = 0;
indexVBO(component[i].vertices, component[i].uvs, component[i].normals, indices, indexed_vertices, indexed_uvs, indexed_normals);
endind = indices.size();
endver = indexed_vertices.size();
enduv = indexed_uvs.size();
endnr = indexed_normals.size();
elecount.push_back(glm::vec4(endver, enduv, endnr, endind));
}
Code for VBOs :
GLuint vertexbuffer;
glGenBuffers(1, &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, indexed_vertices.size() * sizeof(glm::vec3), &indexed_vertices[0], GL_STATIC_DRAW);
GLuint uvbuffer;
glGenBuffers(1, &uvbuffer);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glBufferData(GL_ARRAY_BUFFER, indexed_uvs.size() * sizeof(glm::vec2), &indexed_uvs[0], GL_STATIC_DRAW);
GLuint normalbuffer;
glGenBuffers(1, &normalbuffer);
glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
glBufferData(GL_ARRAY_BUFFER, indexed_normals.size() * sizeof(glm::vec3), &indexed_normals[0], GL_STATIC_DRAW);
GLuint elementbuffer;
glGenBuffers(1, &elementbuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(unsigned short), &indices[0], GL_STATIC_DRAW);
Code for VAOs :
GLuint CubeVertexArrayID, SphereVertexArrayID;
glGenVertexArrays(1, &CubeVertexArrayID);
glGenVertexArrays(1, &SphereVertexArrayID);
glBindVertexArray(CubeVertexArrayID);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer);
glBindVertexArray(SphereVertexArrayID);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void *)(sizeof(glm::vec3) * ((int)elecount[0][0])));
glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)(sizeof(glm::vec2) * ((int)elecount[0][1])));
glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (void*)(sizeof(glm::vec3) * ((int)elecount[0][2])));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer);
Code for displaying :
glBindVertexArray(CubeVertexArrayID);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, component[0].Texture);
glUniform1i(TextureID, 0);
glDrawElements(GL_TRIANGLES,(int)elecount[0][3],GL_UNSIGNED_SHORT,(void*)0);
glm::mat4 ModelMatrix2 = glm::mat4(1.0);
ModelMatrix2 = glm::translate(ModelMatrix2, glm::vec3(2.0f, 0.0f, 0.0f));
glm::mat4 MVP2 = ProjectionMatrix * ViewMatrix * ModelMatrix2;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP2[0][0]);
glUniformMatrix4fv(ModelMatrixID, 1, GL_FALSE, &ModelMatrix2[0][0]);
glUseProgram(shaderProg);
glBindVertexArray(SphereVertexArrayID);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, component[1].Texture);
glUniform1i(TextureID, 0);
glDrawElements(GL_TRIANGLES, (int)(elecount[1][3]-elecount[0][3]), GL_UNSIGNED_SHORT,(void*)(sizeof(unsigned short) * ((int)elecount[0][3])));
There's nothing wrong in the code you posted, so it's hard to say for sure where's the problem. However my best guess is that indexVBO (that you didn't show) pushes the absolute indices within indexed_* arrays. Combined with the offset glVertexAttribPointer of SphereVertexArrayID this causes out-of-bound reads.
You could fix your indexVBO code. However, since both VAOs reference the same buffer, the simplest solution (and I would say, the correct solution) is to use a single VAO for both components. If my hypothesis is correct, it is as simple as changing the
glBindVertexArray(SphereVertexArrayID);
to
glBindVertexArray(CubeVertexArrayID);
when you're drawing the 2nd component. Then you can get rid of SphereVertexArrayID completely.
I'm trying to draw multiple objects with a (the same) basic shader program. The objects have vertex buffers that I intend to draw using associated index buffers by calling glDrawElements. I've set up a VAO for each object and thought I'd associated the index buffer and vertex buffer with the VAO, but when I draw the second (and any additional objects) they are drawn using the wrong vertices.
Here's my (pseudoish) code for setting up the VBO's and EBO's:
glGenBuffers(1, &vboCube);
glBindBuffer(GL_ARRAY_BUFFER, vboCube);
glBufferData(GL_ARRAY_BUFFER, getNumSphereVertices() * sizeof(Vertex), &data[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &iboCube);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboCube);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, getNumCubeIndices() * sizeof(uint32), &data[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glGenBuffers(1, &vboSphere);
glBindBuffer(GL_ARRAY_BUFFER, vboSphere);
glBufferData(GL_ARRAY_BUFFER, getNumSphereVertices() * sizeof(Vertex), &data[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenBuffers(1, &iboSphere);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboSphere);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, getNumSphereIndices() * sizeof(uint32), &data[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
Edit:
These have been updated to use DSA equivalents and the problem persists. DSA code as per:
glCreateBuffers(1, &vboCube);
glBindBuffer(GL_ARRAY_BUFFER, vboCube);
glNamedBufferData(vboCube, getNumCubeVertices() * sizeof(Vertex), &data[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
Next linking my program attributes:
glUseProgram(programID);
uint32 vaoCube;
glCreateVertexArrays(1, &vaoCube);
glBindVertexArray(vaoCube);
i = 0
for each attribute:
uint32 attribIndex = glGetAttribLocation(program, name.c_str());
glVertexArrayVertexBuffer(vaoCube, i, vboCube, 0, stride);
glEnableVertexArrayAttrib(vaoCube, attribIndex);
glVertexArrayAttribFormat(vaoCube, attribIndex, numCells, dataType, normalise, offset);
glVertexArrayAttribBinding(vaoCube, attribIndex, i);
glVertexArrayBindingDivisor(vaoCube, i, divisor);
i++
glBindVertexArray(0);
glBindVertexArray(vaoCube);
glVertexArrayElementBuffer(vaoCube, iboCube);
glBindVertexArray(0);
uint32 vaoSphere;
glCreateVertexArrays(1, &vaoSphere);
glBindVertexArray(vaoSphere);
i = 0
for each attribute:
uint32 attribIndex = glGetAttribLocation(program, name.c_str());
glVertexArrayVertexBuffer(vaoSphere, i, vboSphere, 0, stride);
glEnableVertexArrayAttrib(vaoSphere, attribIndex);
glVertexArrayAttribFormat(vaoSphere, attribIndex, numCells, dataType, normalise, offset);
glVertexArrayAttribBinding(vaoSphere, attribIndex, i);
glVertexArrayBindingDivisor(vaoSphere, i, divisor);
i++
glBindVertexArray(0);
glBindVertexArray(vaoSphere);
glVertexArrayElementBuffer(vaoSphere, iboSphere);
glBindVertexArray(0);
And finally drawing the objects:
glBindVertexArray(vaoCube);
glDrawElements(GL_TRIANGLES, getNumCubeIndices(), GL_UNSIGNED_INT, (GLvoid*)0);
glBindVertexArray(0);
glBindVertexArray(vaoSphere);
glDrawElements(GL_TRIANGLES, getNumSphereIndices(), GL_UNSIGNED_INT, (GLvoid*)0);
glBindVertexArray(0);
Finally the result:
Is the VAO setup incorrect?
If you are using ARB_direct_state_access/OpenGL 4.5, you should do so consistently and entirely. So all of that stuff in "my (pseudoish) code for setting up the VBO's and EBO's:" is wrong. You should be using glCreateBuffer, glNamedBufferData and the like.
This is important because while GL_ARRAY_BUFFER is part of context state, GL_ELEMENT_ARRAY_BUFFER is part of VAO state. And if you're using core OpenGL and don't have a VAO bound... that means there is no element array buffer state. So your glBindBuffer call should have errored out, and your subsequent attempts to use them would similarly fail.
The problem was external to the code shown above. The above code actually works.
I am attempting to create a simple graphics system using modern (3.3) OpenGL for use in a game. Dynamic objects will have dynamic geometry and VBOs will be updated whenever there is a change. This part was very easy to implement. While everything works well so long as only one VAO is used, further calls to glGenVertexArrays don't create another object (printing the ID for the first and the second both returns 1) and something in the VAO initialization for the new objects renders the first one unable to perform any edits. Every "modern OpenGL" tutorial either only uses one object or has some pretty significant conflicts (most often the use of glVertexAttribPointer). The following code is involved with the graphics system of the objects. (Don't know how important this is, but I am using glfw3 for window and and context creation).
Init Game Object (graphics snippet)
glGenVertexArrays(1, &vertexArrayID);
glBindVertexArray(vertexArrayID);
glGenBuffers(1, &vertexCoordBufferID);
glBindBuffer(GL_ARRAY_BUFFER, vertexCoordBufferID);
glBufferData(GL_ARRAY_BUFFER, 2000 * 3 * sizeof(float), nullptr, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glEnableVertexAttribArray(0);
allocatedVerticies = 2000;
Update Mesh
//generate mesh
std::vector<float> vertices;
vertices.reserve(voxels.size() * 3 * 12);
//Vertices are added to the vector. This part works. Removed this code for clarity.
vertexCount = vertices.size() / 3;
glBindVertexArray(vertexArrayID);
glBindBuffer(GL_ARRAY_BUFFER, vertexCoordBufferID);
if (allocatedVerticies < vertexCount)
{
//reallocate the buffers
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
allocatedVerticies = vertexCount;
}
else
{
/////////////////////////////
//reallocate the buffers- originally a reallocation was not going to be used, but glBufferSubData does not work
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
allocatedVerticies = vertexCount;
////////////////////////////////////////this does not work for some reason
//reset data
//glBufferSubData(GL_ARRAY_BUFFER, 0, vertices.size() * sizeof(float), vertices.data());
}
edited = false;
Render Object
glBindVertexArray(vertexArrayID);
glDrawArrays(GL_TRIANGLES, 0, vertexCount);
If anyone more experienced with OpenGL could point out my mistake, (or some other problem) that would be fantastic.
In code that you provided I see nothing that can cause such a behaviour. Maby you should provide your entire solution that is connected with your rendering for better understanding what is going on in your program?
By the way: if you already defined glVertexAttribPointer() for your buffor you don't have to do it every time you update the data you stored in your vertexCoordBufferID if of course you don't change the data layout and its type. Instead of:
vertexCount = vertices.size() / 3;
glBindVertexArray(vertexArrayID);
glBindBuffer(GL_ARRAY_BUFFER, vertexCoordBufferID);
if (allocatedVerticies < vertexCount)
{
//reallocate the buffers
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
allocatedVerticies = vertexCount;
}
You can use just:
vertexCount = vertices.size() / 3;
glBindBuffer(GL_ARRAY_BUFFER, vertexCoordBufferID);
if (allocatedVerticies < vertexCount)
{
//reallocate the buffers
glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(float), vertices.data(), GL_DYNAMIC_DRAW);
allocatedVerticies = vertexCount;
}
I'm familiar with IBO, VBO and VAO, while passing vertices, uvs and normals in one buffer. Though there are cases, when it's a little bit difficult to combine them in one buffer.
Therefore I came up with this piece of code:
glGenBuffers(2, &iboID[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID[0]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, vertInd.size() * sizeof(unsigned int), &vertInd[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, uvInd.size() * sizeof(unsigned int), &uvInd[0], GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glGenBuffers(2, &vboID[0]);
glBindBuffer(GL_ARRAY_BUFFER, vboID[0]);
glBufferData(GL_ARRAY_BUFFER, tempV.size() * sizeof(glm::vec3), &tempV[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, vboID[1]);
glBufferData(GL_ARRAY_BUFFER, tempUV.size() * sizeof(glm::vec2), &tempUV[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glGenVertexArrays(1, &vaoID[0]);
glBindVertexArray(vaoID[0]);
glBindBuffer(GL_ARRAY_BUFFER, vboID[0]);
glVertexAttribPointer(_shader->attrib("vert"), 3, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(_shader->attrib("vert"));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID[0]);
outputError();
glBindBuffer(GL_ARRAY_BUFFER, vboID[1]);
glVertexAttribPointer(_shader->attrib("vertTexCoord"), 2, GL_FLOAT, GL_FALSE, 0, 0);
glEnableVertexAttribArray(_shader->attrib("vertTexCoord"));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iboID[1]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindVertexArray(0);
So my question is : Is this the right way of doing this? (because at the moment I see nothing drawn to the screen)
You are trying to specify different element arrays (in separate IBOs), each for a vertex attribute. This is not going to work. Defining separate VBOs for each attribute is fine, but the GL can only have one element array, indexing all the currently enabled attribute arrays at the same time.