Iphone OpenGL精灵在渲染时轻微颤抖

Iphone OpenGL精灵在渲染时轻微颤抖,iphone,opengl-es,textures,sprite,Iphone,Opengl Es,Textures,Sprite,我制作了一个类,通过使用opengl es管理iphone应用程序中的精灵。 渲染效果很好,但是当精灵表很大(超过512x512px)并且精灵有一个不移动的部分时,该部分似乎会轻微抖动(就像每个帧的抗锯齿计算方式不同一样)。 这是正常的还是我代码中的错误 代码如下: //set bounds of the cell int t_x1 = position.x; int t_y1 = MAX_SPRITE_HEIGHT - position.y; int t_x2 = t_x1 + width;

我制作了一个类,通过使用opengl es管理iphone应用程序中的精灵。 渲染效果很好,但是当精灵表很大(超过512x512px)并且精灵有一个不移动的部分时,该部分似乎会轻微抖动(就像每个帧的抗锯齿计算方式不同一样)。 这是正常的还是我代码中的错误

代码如下:

//set bounds of the cell
int t_x1 = position.x;
int t_y1 = MAX_SPRITE_HEIGHT - position.y;
int t_x2 = t_x1 + width;
int t_y2 = t_y1 - height;

//set vertices position
GLshort verticesBuffer[4*3];
verticesBuffer[0] = t_x1;
verticesBuffer[1] = t_y1;
verticesBuffer[2] = depth;

verticesBuffer[3] = t_x1;
verticesBuffer[4] = t_y2;
verticesBuffer[5] = depth;

verticesBuffer[6]  = t_x2;
verticesBuffer[7] = t_y1;
verticesBuffer[8] = depth;

verticesBuffer[9] = t_x2;
verticesBuffer[10] = t_y2;
verticesBuffer[11] = depth;

//set texture coordinates
GLfloat texCoordBuffer[2*4]
texCoordBuffer[0] =    a_cellLayer.origin.x / CGImageGetWidth(texture.textureImage);
texCoordBuffer[1] =    a_cellLayer.origin.y / CGImageGetHeight(texture.textureImage);

texCoordBuffer[2] =    texCoordBuffer[0];
texCoordBuffer[3] = texCoordBuffer[1] + (float)(t_y1-t_y2) / CGImageGetHeight(texture.textureImage);

texCoordBuffer[4] =    texCoordBuffer[6];
texCoordBuffer[5] = texCoordBuffer[1];

texCoordBuffer[6] =    texCoordBuffer[0] + (float)(t_x2-t_x1) / CGImageGetWidth(texture.textureImage);
texCoordBuffer[7] = texCoordBuffer[3];

//set texture
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, [texture getTexture]);

//set vertices
glVertexPointer(3, GL_SHORT, 0, verticesBuffer);
glEnableClientState(GL_VERTEX_ARRAY);

//apply texture
glTexCoordPointer(2, GL_FLOAT, 0, texCoordBuffer);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

//render
glColor4f(1.0, 1.0, 1.0, 1.0); // R V B Alpha

glNormal3f(0.0f, 0.0f, 1.0f);

glDrawArrays(GL_TRIANGLE_STRIP, 0, 4*nbOfXSudivisions*nbOfYSudivisions);
我试图用GL_FIXED更改纹理坐标的类型,但它没有改变任何东西


有人有主意吗

我不使用深度缓冲区,我已将投影矩阵设置为:

const GLfloat zNear = 100, zFar = 1000, fieldOfView = 22.5; 

glMatrixMode(GL_PROJECTION); 

GLfloat size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0); 

CGRect rect = oGLView.bounds; 

glFrustumf(-size, size, -size / (rect.size.width / rect.size.height), size / 
           (rect.size.width / rect.size.height), zNear, zFar); 

glViewport(0, 0, rect.size.width, rect.size.height);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity(); 

//set perspective
gluLookAt(PAGE_WIDTH/2, PAGE_HEIGHT/2, PAGE_WIDTH/2.0f/(tanf(DEGREES_TO_RADIANS(fieldOfView/2.0f))),
          PAGE_WIDTH/2, PAGE_HEIGHT/2, 0,
          0, 1, 0); 

很难说。你在使用深度缓冲区吗?你的投影矩阵是什么样的?nbOfXSudivisions和nbOfYSudivisions设置为1吗?是的nbOfXSudivisions和nbOfYSudivisions设置为1。非常有趣。。。颤抖的精灵!!!