Hello, I have this problem: there is a dynamic scene (the viewpoint changes over time), I display a number of sprites (translucent with texture). If they are all at a fairly close distance from each other (for example, along a chain with a very small step) and I approach one of them (in particular, the first one), then the FPS drops dramatically, the effect is that I look at the hay almost all the sprites at once. Maybe the term multiple mixing here is appropriate? How to get around this place? I turn off the depth test during drawing. If it is left on, the FPS stops falling, but the conclusion of this whole case becomes incorrect. I sort the objects in the hay.
So I calculate the coordinates of the sprite:
double ModelViewMatrix[16]; glGetDoublev(GL_MODELVIEW_MATRIX, ModelViewMatrix); // Построим вектора вверх и вправо Right.x = (float)ModelViewMatrix[0]; Right.y = (float)ModelViewMatrix[4]; Right.z = (float)ModelViewMatrix[8]; Up.x = (float)ModelViewMatrix[1]; Up.y = (float)ModelViewMatrix[5]; Up.z = (float)ModelViewMatrix[9]; // Вычислим четыре координаты спрайта Coo[0].x = (-Right.x-Up.x); Coo[0].y = (-Right.y-Up.y); Coo[0].z = (-Right.z-Up.z); Coo[1].x = (Right.x-Up.x); Coo[1].y = (Right.y-Up.y); Coo[1].z = (Right.z-Up.z); Coo[2].x = (Right.x+Up.x); Coo[2].y = (Right.y+Up.y); Coo[2].z = (Right.z+Up.z); Coo[3].x = (-Right.x+Up.x); Coo[3].y = (-Right.y+Up.y); Coo[3].z = (-Right.z+Up.z);
So I paint the sprite myself:
void sprit(float x, float y, float z, float Size, float r, float g, float b, float bind){ forsprit(); glColor4ub(r,g,b,bind); glTranslatef(x,y,z); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex3f(Size*Coo[0].x,Size*Coo[0].y, Size*Coo[0].z); glTexCoord2f(1,0); glVertex3f(Size*Coo[1].x,Size*Coo[1].y, Size*Coo[1].z); glTexCoord2f(1,1); glVertex3f(Size*Coo[2].x,Size*Coo[2].y, Size*Coo[2].z); glTexCoord2f(0,1); glVertex3f(Size*Coo[3].x,Size*Coo[3].y, Size*Coo[3].z); glEnd(); glTranslatef(-x,-y,-z); }
Well, actually drawing in general
void star(float x, float y, float z, float Size, float r, float g, float b, int num) { glDisable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_ONE,GL_ONE); glBindTexture(GL_TEXTURE_2D, texture[0]); sprit(x,y,z,Size, r*255,g*255,b*255,255); sprit(x,y,z,Size*0.65, 255,255,255,255); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); }