# OpenGL clipped triangles produce unwanted new edges

This topic is 5221 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I feel like a newb asking this question, but I guess we all have to be newbs at something. I am using OpenGL to draw triangles to the screen. They are outlined rather than filled polygons. When I get to the edge of the screen they are clipped and produce a new line along the edge of the screen. I don't want that line to appear. So a triangle like this:
|\
| \
|  \
|  /
| /
|/

becomes:
|\
| \
|  |
|  |
| /
|/

and I want it to be:
|\
| \
|
|
| /
|/

What ways are there to achieve this? Thanks for any help or pointers, even keywords for google. Pete

##### Share on other sites
I don't know any method to achieve this when you draw outlined triangles. Maybe you could fake the effect by drawing one big black hollow "frame" around the viewport after rendering the outlined tris to would cover the unwanted edges.

But I would actually do the following: Just draw lines (glBegin(GL_LINE_STRIP) or glBegin(GL_LINES)) instead of outlined triangles. You probably have to change the order of vertices you send to the GL (e.g. to draw a triangle (v1-v2-v3) you would send v1->v2->v3->v1 with glVertex for a line strip instead of v1->v2->v3 for a triangle), but you won't have problems with the unwanted edges then.

##### Share on other sites
Thanks, Lutz.

The problem is I don't have any control over what the users of my library have put into their display lists.

Also, I am actually capturing the rendered elements in the feedback buffer and converting them to windows GDI calls and sending them to the printer (not that you need to know that). I don't think putting a clipping border around the frame would stop the edges getting captured in the feedback buffer.

I could check to see whether the line is on the edge and not render it. That's getting a little complicated and convoluted. Also there may be edges which genuinely should be drawn.

I thought OpenGL would have a method of dealing with it as it seems to me to be a reasonable thing to want to eliminate.

bump

anyone?

##### Share on other sites
I've never noticed this problem when drawing outlined triangles (with glPolygonMode(GL_FRONT_AND_BACK,GL_LINE)) so I guess this depends on the OpenGL implementation..?
Anyway, what you could do is manually clip the lines before you send them to the printer. Define a rectangle that contains most of the screen, just leaving out thin areas at the sides, bottom and top, and then clip against this.
Not an optimal solution, maybe, but at least you'd get rid of those extra lines.

##### Share on other sites
Further details about what I'm doing.

I'm rendering to a bitmap which is only a fraction of the whole size of the printed page. So I'm rendering tiles and capturing the results, converting them to page coordinates and drawing to the printer. So I have a whole grid of extra edges being drawn for each tile; it's not just round the edge of the page.

Hope that makes sense. I probably can do what you're both suggesting on a tile by tile basis. I was hoping there was a more straight forward way though.

Thanks again.

Pete

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633701
• Total Posts
3013441
×