Drawing border around objects in 3d

Started by
0 comments, last by BionicBytes 14 years, 8 months ago
Hello, I have 3D objects that I want to draw a thin line around some of their edges. A simple way to do that which I thought of would be to draw all the polygons normally, and then redraw some of the edges of the same polygons but using glBegin(GL_LINES); instead. My problem is that those lines are still depth tested and will appear randomly. I can probably turn off depth testing and sort the geometry, but I was wondering if there is perhaps some other solution? EDIT: I came up with something different. Draw the geometry without sorting but with depth testing, and then turn depth testing off and simply draw the lines, my question here is do lines obey rules like triangles do? That is, by giving coordinates in proper way can I have lines be visible from one side but not from the other? Like culling or how was that called for triangles when you could specify to draw them both sides or only one side. This would solve my problem, as the back facing lines would not be drawn. I'm not exactly sure if a line has a back side though...doesnt seem so? EDIT 2: Ok, i think i solved it myself :). Im off to coding to test it, in case someone got better idea how to do it, please post it here. I'm gonna use the method with back face culling. Doesnt matter those are lines, they come from a triangle after all, so I can test that triangle's face. [Edited by - nef123 on July 24, 2009 5:36:32 AM]
Advertisement
I think the simplest solution is to:

(a) render the scene as per normal
(b) Render the objects using lines. That is use glBegin(GL_LINES)
and ensure your lines have some thickness to them, glLineWidth(4.0) and disable
depth testing glDisable (GL_DEPTH_TEST)
(c) restore previous opengl state



This topic is closed to new replies.

Advertisement