<p>The general principle of OpenGL is using the GPU and a so called rendering pipeline where you can program parts of it on your own, called &quot;shader&quot;.</p>
<p>The input model you want to draw (render) is stored in a so called VertexBufferObject (VBO). This buffer is simple memory, where you can add information what ever you need.</p>
<p>Before rendering, you define how your data is defined... Here one set of data represents one &quot;Vertex&quot;. Usually it is a 3d vector. But you can add several information per vertex, for example a additional normal direction, texture coordinates, color, etc.
The vertices are stored continuously.</p>
<p>Then you can use a 2nd buffer if you like. This buffer is called index buffer object or element Buffer object. This buffer is optional.
When using this buffer, you can store the vertex indices which should be combined to for example a triangle, line, triangle strip etc...</p>
<p>When doing a draw call, you tell Opengl what type of primitives you want to draw. You can use point, line, triangle and different combinations how they should be connected to the following points. For example, when drawing simple triangles, Opengl uses the first 3 vertices to span a triangle and the next 3 vertices for the next triangle. You can also use triangle strips, there the next vertex will be connected this the last two vertices...</p>
<p>Now let's go back to the shaders.
The simplest setup is to use a vertex shader in combination with a fragment shader. The vertex shader code will be executed for each vertex. And is usually used to rotate/scale/translate the vertex position and add a projection. Additionally you can calculate everything else which is vertex based. You can pass data from vertex shader to fragment shader as well... But between vertex stage and fragment stage there is the &quot;Rasterizer&quot;. Each primitive will be clipped and culled with respect to the normalized device coordinates. The resulting primitives can hit pixels on your viewport. Then each hit Pixel calls the fragment shader. The data which will be passed from vertex to fragment shader will be interpolated...</p>
<p>This is a very basic and absolutely not complete description, of how OpenGL works with your data. A lot of things are missing here, like depthbuffer, frameBufferObjects, rasterizer settings, blendings, textures, vertexArray and a lot more! But this would be way too much.</p>
<p>After learning the very basics (draw a triangle) you can take a deeper look at other shader stages (Tessellation control, Tessellation evaluation, geometry) and for general purpos calculations you can use compute shader.</p>
<p>You asked for brushes... In general I would say no, but when drawing lines, you can define the line width.
But brushes must be implemented using shaders on your own</p>
<p>Raster images can be stored to text files. You can move images from GPU to CPU and back. Afterwards you can write code to store it to files. For example as BMP.</p>
<p>BTW: in case of choosing Opengl, I would recommend buying the book &quot;opengl super Bible&quot;. It is for beginners and has a math chapter which is very helpful. At the end they also show how different techniques like normal mapping can be implemented.</p>

CC BY-SA 4.0
2022-10-28T20:52:04.000Z
For a private project the easiest way is to use engines like "unity" or "unreal". They do a lot of work for you. To learn opengl you need a lot of time and nerves... Same like direct3d
Thomas
CC BY-SA 4.0
2022-10-28T20:54:03.560Z
In case you want to use it for commercial projects, the best idea is to hire someone who is familiar with it instead of telling an employee to learn it
Thomas
CC BY-SA 4.0
2022-10-28T22:04:03.347Z
There are times to jump on the wheel and head out to the event and there are other times where the wheel (as well as mode of transportation) must be redefined because the occasion seems to be taking place across a lake of lava, spiked terrains, underneath sea currents or across space or on the moon. In other words, Yes @Thomas I aam quite aware of the many vast options but as is the case whenever the wheel is the subject of reinvention... These Engines as amazing and profound as there are do not fit my use case scenario. They lack in Fundamental Principles of Representation hence why I need to
AncientTides
CC BY-SA 4.0
2022-10-28T22:08:53.473Z
Not to worry, **I** am the fortunate employee who will be surfing this treacherous waters solo... I truly feel for myself
AncientTides
CC BY-SA 4.0
2022-10-28T22:11:15.927Z
3D Pipeline - 
**The process of 3D graphics can be divided into three-stages: tessellation, geometry, and rendering. In the tessellation stage, a described model of an object is created, and the object is then converted to a set of polygons. The geometry stage includes transformation, lighting, and setup. The rendering stage, which is critical for 3D image quality, creates a two dimensional display from the polygons created in the geometry stage.** I have few problems with this illuminating definition.....
AncientTides
CC BY-SA 4.0
2022-10-28T22:12:05.247Z
**1.** - Why would the object have to be converted to a set of polygons?
AncientTides
CC BY-SA 4.0
2022-10-28T22:13:44.397Z
**2.** What are the spaces inbetween the polygons made of?
AncientTides
CC BY-SA 4.0
2022-10-28T22:25:07.917Z
In response to a line within your answer(where **Rasterizer** is mentioned), why can't a definitive border be placed around surface area of drawn vertex so as to prevent clipping of any kind? Textures and other effects/shaders to be called should be able to work within that finite area provided to them
AncientTides
CC BY-SA 4.0
2022-10-28T22:36:51.553Z
Major thanks for the OpenGL book recommendation, I'll be sure to get it. And in regards to your answer **(even though it tried to scramble my brain a little bit....)**... Thank You
AncientTides
CC BY-SA 4.0
2022-10-28T22:45:54.823Z
@AncientTides: Please **stop** randomly inserting **bold-face** text **into your** posts. It makes reading your text harder, especially when what you are emphasizing does not need to be emphasized. If you need to quote something, use "" marks.
Nicol Bolas
CC BY-SA 4.0
2022-10-28T23:10:38.420Z
StackOverflow needs a **highlight** feature @NicolBolas
AncientTides
CC BY-SA 4.0
2022-10-29T09:33:03.550Z
To only enable rendering in specific regions (pixels), you can use the stencil buffer... This is a buffer as big as your FBO (the image you render to) where each pixel can hold a value. You can clear this stencil with 0 and only store a 1 to the pixels, which should be able to change during the rendering (stencil test).
Thomas
CC BY-SA 4.0
2022-10-29T10:30:30.080Z
2: what are the spaces in between polygon are made of: there is no need to put something in.... For example 3 vertices define a triangle. After doing the calculation of rotation, scale etc. The rasterizer uses barycentric coordinates to do interpolation of so called varyings (data you pass from vertex to fragment shader) and for each pixel within this triangle there will be a fragment shader call...
Thomas
CC BY-SA 4.0
2022-10-28T20:40:52.730Z
2022-10-28T21:07:14.503Z
2022-10-28T21:07:14.503Z
Thomas
<p>Trying to understand how OpenGL generates what is seen as images &amp; graphics and these questions come up.</p>
<ol>
<li><p>Are 3D lines (which should be drawn using vectors) drawn using triangles or polygons? Or are they drawn using vector values?</p>
</li>
<li><p>Are the triangles drawn using vectors or smaller triangles?</p>
</li>
<li><p>Can raster pixel data be isolated horizontally and or vertically?</p>
</li>
<li><p>Can raster pixel data be exported into text files?</p>
</li>
<li><p>Can lines be drawn using custom raster brush/draw tool?</p>
</li>
</ol>
<p>I haven't tried anything yet as there really isn't anything to try. These are questions out of curiosity of knowing how 3D lines, shapes &amp; objects are drawn in OpenGL.</p>
<p>Hopefully the answers provided will help me decide on the framework, libraries and tools to adopt within project. I would appreciate helpful answers or guides to articles that shed some light into these questions.</p>
<p><strong>Questions asked are applicable to 2D canvas and 3D space.</strong></p>
<p>P.S - I am absolutely new to Graphics Development &amp; Programming... Be nice, Thanks</p>
<hr />
<p>PLEASE NOTE: Each question can easily be answered using basic straightforward approach of Yes/No followed by a brief explanation stating reason for answer being Yes or No</p>

CC BY-SA 4.0
2022-10-28T19:46:03.667Z
"*drawn using vector values*" What would that mean? "*triangles drawn using vectors or smaller triangles*" Again, I'm unsure what you're asking about here.
Nicol Bolas
CC BY-SA 4.0
2022-10-28T21:08:38.777Z
Welcome to computer graphics stack exchange. I think it would be helpful to clarify what you mean by small examples. Nevertheless I wrote a small answer for you to give you an overview over the opengl workflow
Thomas
CC BY-SA 4.0
2022-10-28T21:48:56.827Z
@NicolBolas - **drawn using vector values** as in are they **drawn using any form of bezier curve vector algorithm?** **Are they drawn using vectors, rasters, shaped polygons & triangles?** .... That sort of vector.
AncientTides
CC BY-SA 4.0
2022-10-28T22:00:09.780Z
@Thomas - Thank you for the warm welcome. I'll be going through your answer now. Much appreciated
AncientTides
CC BY-SA 4.0
2022-10-28T22:22:42.960Z
This question is too broad. Each of the questions from the original poste would require an entire answer. I recommend closing this question and posting a new question picking only 1 of the subjects here at a time.
pmw1234
CC BY-SA 4.0
2022-10-28T22:27:23.383Z
@pmw1234 - I don't agree....  Each question can easily be answered using basic straightforward approach of **YES/NO** followed by a brief explanation stating reason for answer being **Yes** or **No**
AncientTides
CC BY-SA 4.0
2022-10-28T22:35:42.120Z
Answers: 1) simultaneously none of the above, all of the above and no 2) none of these, 3) this question makes no sense 4) again the question make no sense but bizarrely you could stick .txt at the end of the file so yes? that felt weird. 5) no
pmw1234
CC BY-SA 4.0
2022-10-28T22:35:56.453Z
@AncientTides: "*Each question can easily be answered using basic straightforward approach of YES/NO*" Your first question is of the form "Are lines drawn with X or Y?" Neither "yes" nor "no" is a valid answer to that question. Same goes for your second and third questions.
Nicol Bolas
CC BY-SA 4.0
2022-10-28T22:47:34.487Z
@NIcolBolas - Incorrect assessment of my question. What I am asking is : Are the triangles and/or polygons used within a 3D environment made up of 2D vector enabled triangles/polygons? Are they made of 3D vector enabled triangles/polygons? Are they made up of 2D/3D vector enabled lines? FEEL FREE TO EXTEND QUESTION BY REPLACING "vector" with "raster". And this is in regard to the **default** low quality 3D mesh object that a great deal of 3D rendering softwares provide - of which a great deal is owned to the millions of triangles & polygons connected to themselves.
AncientTides
CC BY-SA 4.0
2022-10-28T22:50:53.347Z
@AncientTides: What is a "vector enabled triangle/polygon"? Also: "*FEEL FREE TO EXTEND QUESTION BY REPLACING "vector" with "raster".*" "Vector" and "raster" are not even remotely the same thing. I cannot imagine a sentence that makes sense with either word in the same place. And even if both did make sense, the sentence wouldn't have the same meaning. I really think you don't fully understand what these words mean.
Nicol Bolas
CC BY-SA 4.0
2022-10-28T22:55:05.740Z
Technology changing question and it gets a negative vote... Guess it can't be helped. Question is not reference x, y, Z coordinates directly but is referencing the use of Mathematical algorithms to draw non-rasterized, vector lines, triangles and polygon that are displayed by OpenGL and other Graphic API's and frameworks as a whole
AncientTides
CC BY-SA 4.0
2022-10-28T22:57:27.357Z
@NicolBolas - vector enabled triangle =  triangle drawn using a bezier curve() that will always have same pixel quality regardless of scale
AncientTides
CC BY-SA 4.0
2022-10-28T23:01:23.923Z
raster enabled triangle/polygon = triangle drawn using raw pixels without the use of any form of mathematical algorithm proven to preserve graphical quality during scaling or rendering of any graphical design, art, image, animation, game etc...
AncientTides
CC BY-SA 4.0
2022-10-28T23:02:38.733Z
@AncientTides: A triangle is made of lines. And while a line is a special case of a Bezier curve, why would you use a Bezier curve to draw something that you *know* is a line? It's just such a strange way of saying it. As for "*same pixel quality regardless of scale*" that's just how rasterization works. Assuming that by "scale" you mean "pixel resolution of the final image."
Nicol Bolas
CC BY-SA 4.0
2022-10-28T23:07:08.483Z
@pmw1234 - Hopefully it will make sense to you in the next couple of years.... 3 to 5 years from now
AncientTides
CC BY-SA 4.0
2022-10-28T23:10:19.190Z
@AncientTides: After doing some Googling, I'm getting the impression that you're talking about PostGIS stuff.
Nicol Bolas
CC BY-SA 4.0
2022-10-28T23:13:19.783Z
@AncientTides: "*Hopefully it will make sense to you in the next couple of years.... 3 to 5 years from now*" Yeah, I've heard all that kind of talk before. How some random person is on to the Next Big Thing that will revolutionize everything in 3-5 years, and the rest of us just don't get it. They haven't been right yet, but maybe you'll be different. Good luck.
Nicol Bolas
CC BY-SA 4.0
2022-10-28T23:16:05.080Z
@NicolBolas - Nahhh.. Just the usual Animation, Game, Graphics design, Comics Canvas, AfterEffects, CAD development amongst other stuff... But don't sweat it, I've gotten bits & pieces of what I wanted from your replies and that of **pmw1234** and **Thomas**.  Thanks again
AncientTides
CC BY-SA 4.0
2022-10-30T04:51:58.687Z
Hi AncientTides, welcome to the site! We're closing this question because it's unclear what you're asking. Various users have made suggestions about ways to edit to improve the question and get it reopened. I appreciate the patience and generosity that everyone has shown in these comments.
luser droog
<opengl><3d><c++><vector-graphics>
Is a line drawn using vectors, triangles or polygons within OpenGL?
AncientTides
# Is a line drawn using vectors, triangles or polygons within OpenGL?

(Asked by: username_0 on 2022-10-28)

Trying to understand how OpenGL generates what is seen as images & graphics and these questions come up.

1. Are 3D lines (which should be drawn using vectors) drawn using triangles or polygons? Or are they drawn using vector values?
2. Are the triangles drawn using vectors or smaller triangles?
3. Can raster pixel data be isolated horizontally and or vertically?
4. Can raster pixel data be exported into text files?
5. Can lines be drawn using custom raster brush/draw tool?

I haven't tried anything yet as there really isn't anything to try. These are questions out of curiosity of knowing how 3D lines, shapes & objects are drawn in OpenGL.

Hopefully the answers provided will help me decide on the framework, libraries and tools to adopt within project. I would appreciate helpful answers or guides to articles that shed some light into these questions.

**Questions asked are applicable to 2D canvas and 3D space.**

P.S - I am absolutely new to Graphics Development & Programming... Be nice, Thanks

---

PLEASE NOTE: Each question can easily be answered using basic straightforward approach of Yes/No followed by a brief explanation stating reason for answer being Yes or No

**Tags:** opengl, 3d, c++, vector-graphics

> **Comments:**
> **username_1**: "*drawn using vector values*" What would that mean? "*triangles drawn using vectors or smaller triangles*" Again, I'm unsure what you're asking about here.  
> **username_2**: Welcome to computer graphics stack exchange. I think it would be helpful to clarify what you mean by small examples. Nevertheless I wrote a small answer for you to give you an overview over the opengl workflow  
> **username_0**: @username_1 - **drawn using vector values** as in are they **drawn using any form of bezier curve vector algorithm?** **Are they drawn using vectors, rasters, shaped polygons & triangles?** .... That sort of vector.  
> **username_0**: @username_2 - Thank you for the warm welcome. I'll be going through your answer now. Much appreciated  
> **username_3**: This question is too broad. Each of the questions from the original poste would require an entire answer. I recommend closing this question and posting a new question picking only 1 of the subjects here at a time.  
> **username_0**: @username_3 - I don't agree....  Each question can easily be answered using basic straightforward approach of **YES/NO** followed by a brief explanation stating reason for answer being **Yes** or **No**  
> **username_3**: Answers: 1) simultaneously none of the above, all of the above and no 2) none of these, 3) this question makes no sense 4) again the question make no sense but bizarrely you could stick .txt at the end of the file so yes? that felt weird. 5) no  
> **username_1**: @username_0: "*Each question can easily be answered using basic straightforward approach of YES/NO*" Your first question is of the form "Are lines drawn with X or Y?" Neither "yes" nor "no" is a valid answer to that question. Same goes for your second and third questions.  
> **username_0**: @NIcolBolas - Incorrect assessment of my question. What I am asking is : Are the triangles and/or polygons used within a 3D environment made up of 2D vector enabled triangles/polygons? Are they made of 3D vector enabled triangles/polygons? Are they made up of 2D/3D vector enabled lines? FEEL FREE TO EXTEND QUESTION BY REPLACING "vector" with "raster". And this is in regard to the **default** low quality 3D mesh object that a great deal of 3D rendering softwares provide - of which a great deal is owned to the millions of triangles & polygons connected to themselves.  
> **username_1**: @username_0: What is a "vector enabled triangle/polygon"? Also: "*FEEL FREE TO EXTEND QUESTION BY REPLACING "vector" with "raster".*" "Vector" and "raster" are not even remotely the same thing. I cannot imagine a sentence that makes sense with either word in the same place. And even if both did make sense, the sentence wouldn't have the same meaning. I really think you don't fully understand what these words mean.  
> **username_0**: Technology changing question and it gets a negative vote... Guess it can't be helped. Question is not reference x, y, Z coordinates directly but is referencing the use of Mathematical algorithms to draw non-rasterized, vector lines, triangles and polygon that are displayed by OpenGL and other Graphic API's and frameworks as a whole  
> **username_0**: @username_1 - vector enabled triangle =  triangle drawn using a bezier curve() that will always have same pixel quality regardless of scale  
> **username_0**: raster enabled triangle/polygon = triangle drawn using raw pixels without the use of any form of mathematical algorithm proven to preserve graphical quality during scaling or rendering of any graphical design, art, image, animation, game etc...  
> **username_1**: @username_0: A triangle is made of lines. And while a line is a special case of a Bezier curve, why would you use a Bezier curve to draw something that you *know* is a line? It's just such a strange way of saying it. As for "*same pixel quality regardless of scale*" that's just how rasterization works. Assuming that by "scale" you mean "pixel resolution of the final image."  
> **username_0**: @username_3 - Hopefully it will make sense to you in the next couple of years.... 3 to 5 years from now  
> **username_1**: @username_0: After doing some Googling, I'm getting the impression that you're talking about PostGIS stuff.  
> **username_1**: @username_0: "*Hopefully it will make sense to you in the next couple of years.... 3 to 5 years from now*" Yeah, I've heard all that kind of talk before. How some random person is on to the Next Big Thing that will revolutionize everything in 3-5 years, and the rest of us just don't get it. They haven't been right yet, but maybe you'll be different. Good luck.  
> **username_0**: @username_1 - Nahhh.. Just the usual Animation, Game, Graphics design, Comics Canvas, AfterEffects, CAD development amongst other stuff... But don't sweat it, I've gotten bits & pieces of what I wanted from your replies and that of **username_3** and **username_2**.  Thanks again  
> **username_4**: Hi username_0, welcome to the site! We're closing this question because it's unclear what you're asking. Various users have made suggestions about ways to edit to improve the question and get it reopened. I appreciate the patience and generosity that everyone has shown in these comments.  

---

## 1 answers

### Answer by username_2 on 2022-10-28. Score: 2 | Accepted answer

The general principle of OpenGL is using the GPU and a so called rendering pipeline where you can program parts of it on your own, called "shader".

The input model you want to draw (render) is stored in a so called VertexBufferObject (VBO). This buffer is simple memory, where you can add information what ever you need.

Before rendering, you define how your data is defined... Here one set of data represents one "Vertex". Usually it is a 3d vector. But you can add several information per vertex, for example a additional normal direction, texture coordinates, color, etc.
The vertices are stored continuously.

Then you can use a 2nd buffer if you like. This buffer is called index buffer object or element Buffer object. This buffer is optional.
When using this buffer, you can store the vertex indices which should be combined to for example a triangle, line, triangle strip etc...

When doing a draw call, you tell Opengl what type of primitives you want to draw. You can use point, line, triangle and different combinations how they should be connected to the following points. For example, when drawing simple triangles, Opengl uses the first 3 vertices to span a triangle and the next 3 vertices for the next triangle. You can also use triangle strips, there the next vertex will be connected this the last two vertices...

Now let's go back to the shaders.
The simplest setup is to use a vertex shader in combination with a fragment shader. The vertex shader code will be executed for each vertex. And is usually used to rotate/scale/translate the vertex position and add a projection. Additionally you can calculate everything else which is vertex based. You can pass data from vertex shader to fragment shader as well... But between vertex stage and fragment stage there is the "Rasterizer". Each primitive will be clipped and culled with respect to the normalized device coordinates. The resulting primitives can hit pixels on your viewport. Then each hit Pixel calls the fragment shader. The data which will be passed from vertex to fragment shader will be interpolated...

This is a very basic and absolutely not complete description, of how OpenGL works with your data. A lot of things are missing here, like depthbuffer, frameBufferObjects, rasterizer settings, blendings, textures, vertexArray and a lot more! But this would be way too much.

After learning the very basics (draw a triangle) you can take a deeper look at other shader stages (Tessellation control, Tessellation evaluation, geometry) and for general purpos calculations you can use compute shader.

You asked for brushes... In general I would say no, but when drawing lines, you can define the line width.
But brushes must be implemented using shaders on your own

Raster images can be stored to text files. You can move images from GPU to CPU and back. Afterwards you can write code to store it to files. For example as BMP.

BTW: in case of choosing Opengl, I would recommend buying the book "opengl super Bible". It is for beginners and has a math chapter which is very helpful. At the end they also show how different techniques like normal mapping can be implemented.

> **Comments:**
> **username_2**: For a private project the easiest way is to use engines like "unity" or "unreal". They do a lot of work for you. To learn opengl you need a lot of time and nerves... Same like direct3d  
> **username_2**: In case you want to use it for commercial projects, the best idea is to hire someone who is familiar with it instead of telling an employee to learn it  
> **username_0**: There are times to jump on the wheel and head out to the event and there are other times where the wheel (as well as mode of transportation) must be redefined because the occasion seems to be taking place across a lake of lava, spiked terrains, underneath sea currents or across space or on the moon. In other words, Yes @username_2 I aam quite aware of the many vast options but as is the case whenever the wheel is the subject of reinvention... These Engines as amazing and profound as there are do not fit my use case scenario. They lack in Fundamental Principles of Representation hence why I need to  
> **username_0**: Not to worry, **I** am the fortunate employee who will be surfing this treacherous waters solo... I truly feel for myself  
> **username_0**: 3D Pipeline -  **The process of 3D graphics can be divided into three-stages: tessellation, geometry, and rendering. In the tessellation stage, a described model of an object is created, and the object is then converted to a set of polygons. The geometry stage includes transformation, lighting, and setup. The rendering stage, which is critical for 3D image quality, creates a two dimensional display from the polygons created in the geometry stage.** I have few problems with this illuminating definition.....  
> **username_0**: **1.** - Why would the object have to be converted to a set of polygons?  
> **username_0**: **2.** What are the spaces inbetween the polygons made of?  
> **username_0**: In response to a line within your answer(where **Rasterizer** is mentioned), why can't a definitive border be placed around surface area of drawn vertex so as to prevent clipping of any kind? Textures and other effects/shaders to be called should be able to work within that finite area provided to them  
> **username_0**: Major thanks for the OpenGL book recommendation, I'll be sure to get it. And in regards to your answer **(even though it tried to scramble my brain a little bit....)**... Thank You  
> **username_1**: @username_0: Please **stop** randomly inserting **bold-face** text **into your** posts. It makes reading your text harder, especially when what you are emphasizing does not need to be emphasized. If you need to quote something, use "" marks.  
> **username_0**: StackOverflow needs a **highlight** feature @username_1  
> **username_2**: To only enable rendering in specific regions (pixels), you can use the stencil buffer... This is a buffer as big as your FBO (the image you render to) where each pixel can hold a value. You can clear this stencil with 0 and only store a 1 to the pixels, which should be able to change during the rendering (stencil test).  
> **username_2**: 2: what are the spaces in between polygon are made of: there is no need to put something in.... For example 3 vertices define a triangle. After doing the calculation of rotation, scale etc. The rasterizer uses barycentric coordinates to do interpolation of so called varyings (data you pass from vertex to fragment shader) and for each pixel within this triangle there will be a fragment shader call...  

---

