Reputation: 1097
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_SRC_COLOR);
glShadeModel(GL_SMOOTH); // Разрешить плавное сглаживание
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Черный фон
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Сглаживание линий
glEnable(GL_BLEND); // Разрешить смешивание
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
//set the format and location for verticies
glVertexPointer(3, GL_FLOAT, 0, vertices);
glNormalPointer(GL_FLOAT, 0, normals);
glCullFace(GL_FRONT);
glDepthFunc(GL_LEQUAL);
//draw the triangles
glDrawArrays(GL_TRIANGLES, 0, numberOfVertices);
Here is my code, and now I have no idea why code doesn't work. I'll be very grateful for advice.
Upvotes: 2
Views: 1135
Reputation: 26925
It seems like you don't have proper understanding of the term smooth in this context.
First, the GL_LINE_SMOOTH_HINT
only affects lines. Furthermore, I refer to the documentation.
Second, glShadeModel()
sets the type of shading your next primitive should have. GL_SMOOTH
will make the vertices' colors interpolated in each resulting pixel fragment. GL_FLAT
, however, only take one computed color of a vertex and automatically assign it to each pixel fragment that your primitive represents. Furthermore, I refer to the documentation.
Your understanding of smooth is not, like you think, applicable on triangles. If you really want a smooth model you should increase the number of polygons in the model.
Upvotes: 1