I have a "terrain" class with a "draw" method. I have the following protected member variables & pointers (that apply to this problem):
unsigned int width, height;
GLfloat ** verts;
GLfloat ** texs;
...and in my constructor, I allocate memory like so:
verts = new GLfloat * [width * 2];
for(unsigned int i = 0; i < width * 2; i++)
{
verts[i] = new GLfloat[3];
}
texs = new GLfloat * [width * 2];
for(i = 0; i < width * 2; i++)
{
texs[i] = new GLfloat[2];
}
Later, in my draw() function, I do this:
glVertexPointer (3, GL_FLOAT, 0, verts);
glTexCoordPointer(2, GL_FLOAT, 0, texs);
And then, later in the draw function, an access violation is produced at the following line of code:
glDrawArrays(GL_TRIANGLE_STRIP, 0, width * 2);
I figure I must be doing something wrong. Could anybody tell me what that thing is?