Renderering problem with flat terrain

i was testing out my game engine last night, but stumbled across this unexpected result. Here is a picture:

As it appears, it is renderering 1 triangle and not renderering the other triangles. I believe it is a problem with either the renderer or, least suspecting, the terrain generation. But, on that note it was rendering the some obj models with no problem. i have checked alot of things, E.G the renderer, the model3D class, buffers and the terrain generation code.

Code time!

one of the model3D constructors:

            pr_VAO = new buffers::VertexArray();

glActiveTexture(GL_TEXTURE0);
texture::Texture texture("res/images/grass.png");
texture.bind();

pr_IBO = new buffers::IndexBuffer(indices, sizeof(indices));


The IndexBuffer constructor:

    IndexBuffer::IndexBuffer(GLuint* data, GLsizei count) : pr_Count(count) {
glGenBuffers(1, &pr_BufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pr_BufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(GLuint), data, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}


The Buffer class:

    Buffer::Buffer(GLfloat* data, GLsizei count, GLuint componentCount) : pr_ComponentCount(componentCount) {
glGenBuffers(1, &pr_BufferID);
glBindBuffer(GL_ARRAY_BUFFER, pr_BufferID);
glBufferData(GL_ARRAY_BUFFER, count * sizeof(GLfloat), &data[0], GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}


And finally, the renderer:

while (!pr_Models.empty()) {
const Model3D* model = pr_Models.front();

model->getVAO()->bind();
model->getIBO()->bind();

glm::mat4 matrix;
glm::translate(matrix, model->getPosition());

glDrawElements(GL_TRIANGLES, model->getIBO()->getCount(), GL_UNSIGNED_INT, 0);

model->getIBO()->unbind();
model->getVAO()->unbind();

pr_Models.pop_front();
}


Thank you very much for your time and understanding

EDIT Sorry forgot to add terrain generation code:

int VERTEX_COUNT = 128;
int SIZE = 800;

const int count = 128 * 128;
GLfloat temp_vertices[(count) * 3];
GLfloat temp_normals[(count) * 3];
GLfloat temp_textureCoords[(count) * 2];
GLuint temp_indices[6 * (128 - 1)*(128 * 1)];

int vertexPointer = 0;
for (int i = 0; i<VERTEX_COUNT; i++) {
for (int j = 0; j<VERTEX_COUNT; j++) {
temp_vertices[vertexPointer * 3] = (float)j / ((float)VERTEX_COUNT - 1) * SIZE;
temp_vertices[vertexPointer * 3 + 1] = 1.0;
temp_vertices[vertexPointer * 3 + 2] = (float)i / ((float)VERTEX_COUNT - 1) * SIZE;
temp_normals[vertexPointer * 3] = 0;
temp_normals[vertexPointer * 3 + 1] = 1;
temp_normals[vertexPointer * 3 + 2] = 0;
temp_textureCoords[vertexPointer * 2] = (float)j / ((float)VERTEX_COUNT - 1);
temp_textureCoords[vertexPointer * 2 + 1] = (float)i / ((float)VERTEX_COUNT - 1);
vertexPointer++;
}
}
int pointer = 0;
for (int gz = 0; gz<VERTEX_COUNT - 1; gz++) {
for (int gx = 0; gx<VERTEX_COUNT - 1; gx++) {
int topLeft = (gz*VERTEX_COUNT) + gx;
int topRight = topLeft + 1;
int bottomLeft = ((gz + 1)*VERTEX_COUNT) + gx;
int bottomRight = bottomLeft + 1;
temp_indices[pointer++] = topLeft;
temp_indices[pointer++] = bottomLeft;
temp_indices[pointer++] = topRight;
temp_indices[pointer++] = topRight;
temp_indices[pointer++] = bottomLeft;
temp_indices[pointer++] = bottomRight;
}
}


EDIT__2: Turns out that models are not working either anymore. i must have accedentally changed something i shouldnt have of.

EDIT__3: sorry managed to get the model rendering working. terrain still not rendering though

• I can't see any of your opengl calls because they are hidden by functions. I wrote this a while ago if it helps at all: gamedev.stackexchange.com/questions/111875/… – mythos May 15 '16 at 13:04
• A guess: I had a similar problem a long time ago, make sure your sending the vertex count, not the polygon count to glDrawElements/glDrawArrays. – JavaProphet May 15 '16 at 16:06