This is less a plea for help over the problem, and another question about something peculiar, discovered after solving the problem. I worked on my OpenGL game for beginners and tried to write a friendly OOP file. All vbo data was stored in the model class, where it was loaded and buffered in the constructor.
The greatly simplified structure of this from main will look something like this:
int main(){
vector <Model> Models;
Graphics.GLInit();
Models.push_back(Model(vertices,texcoords,36,0));
Graphics.EnableAttributePointers();
main loop
{
Graphics.draw(Models,Textures,Entities);
}
return 0;
}
The constructor looked like this:
Model::Model(vector <vec3> &vertices,vector <vec2> &texcoords,int NumVertices,int StartVertex)
{
iNumVertices=NumVertices;
iStartVertex=StartVertex;
Vertices=vertices;
Texcoords=texcoords;
glGenBuffers(1,&vboVertex);
glGenBuffers(1,&vboTexcoord);
glBindBuffer(GL_ARRAY_BUFFER,vboVertex);
glBufferData(GL_ARRAY_BUFFER,Vertices.size()*12,Vertices.data(),GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER,vboTexcoord);
glBufferData(GL_ARRAY_BUFFER,TexCoord.size()*8,TexCoord.data(),GL_STATIC_DRAW);
}
After calling glDrawArrays in the drawing function, a segmentation error will occur:
0xC0000005 cannot access 0x00000000 yadda yadda.
, , , . , , . . , - Model, , . .
, , , , ; GLInit. , , OpenGL - . ++ - , ?