First of all:
- Developing on OSX with Xcode 4.3.1.
- For iOS 5.1.
- With OpenGL ES 2.0/GLUT.
- Language: Objective-C.
I've run into a very strange error when learning programming in opengl es.
I've made a class which stores every information belongs to a sprite (vectors, normals, tex coords, textures and an ID).
The first two sprites are loaded successfully, but after them the top-right point of my squares starts to move/deform.
At firts I've tried to NSLog the coordinates, and they are fine, AAAND the 3. object is being drawn right. I've figured out, that if I insert for cycles (objects count-2), then every object drawn right, no matter how the for cycles are written.
My corresponding code (for 4 objects):
GLfloat gCubeVertexData[48];
for (unsigned int i = 0; 48>i;i++)
{
gCubeVertexData[i] = [tempSprite getVector:i];
}
for (unsigned int i = 1; 2>i;i++)
{
}
for (unsigned int i = 1; 2>i;i++)
{
}
GLuint vertexArrayPointer;
GLuint vertexBufferPointer;
glGenVertexArraysOES(objectArray.count, &vertexArrayPointer);
[tempSprite setVertexArray:vertexArrayPointer];
[tempSprite setVertexBuffer:vertexBufferPointer];
vertexBufferPointer = [tempSprite getVertexBuffer];
glBindVertexArrayOES([tempSprite getVertexArray]);
glGenBuffers(objectArray.count, &vertexBufferPointer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBufferPointer);
glBufferData(GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW);
glEnableVertexAttribArray(GLKVertexAttribPosition);
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(0));
glEnableVertexAttribArray(GLKVertexAttribNormal);
glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(12));
glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(24));
glActiveTexture(GL_TEXTURE0);
glBindVertexArrayOES(objectArray.count-1);
I had also tried sleep (maybe it just needs time), but the error still there.
Thanks for any kind of help!






