How to draw polygons in OpenGL with an outline drawn with a black pen and a different fill color

How can I draw such a form in OpenGL?

enter image description here
I mean, I know how to draw polygons in OpenGL. I want to know how to make the outline black and the fill color (for example) yellow?

+4
source share
2 answers

You have 5 peaks. Draw a GL_POLYGON with them, and then a GL_LINE_LOOP .

Please note that GL_POLYGON is only valid for convex polygons.

+7
source

I would cheat. I would create polygons in a 3d set in the form of meshes and create different meshes for the borders. Then draw the polygon first and then the border using the same transforms using glDepthFunc(GL_LEQUAL) .
In this way, you can also give the border a nice outfit: you can make them look like they were drawn with a pen or pencil, or something else. In addition, this solution is well suited for modern OpenGL, and when using GL_POLYGON not .

+1
source

Source: https://habr.com/ru/post/1502137/


All Articles