开发者

OpenGL Polygon Render order

As you can see: http://i.stack.imgur.com/ztM0v.png, certain polygons are simply being rendered over the other ones. Does anyone have any suggestions or related readi开发者_Python百科ng on rendering these in the correct order so that they do not overlap?


For opaque faces render order is not important as long as you use the depth buffer.

NeHe has a tutorial covering all the basics. Start here http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=02

See also Opengl Depth buffer and Culling and Depth Buffer in OpenGL .


You need to enable depth testing. Make sure that

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); //Maybe not this line but try it anyway, GL_DEPTH_TEST is the important one

is in your initialisation code.


You should make sure that you have set the matrix mode in projection view or 3d and work with 3d always.

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(p, (double) w / (double) h, arg1, arg2);

Then make sure you enable depths by this:

glEnable(GL_DEPTH_TEST);

Next, render using GL...3f or GL...3d to render through 3d, where ... is whatever function you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜