OpenGL code of Chastity White Rose

OpenGL is a cross platform way of doing 2D and even 3D graphics. I started learning it to see what it can help me do. If your browser supports images, you probably saw the spinning triangle at the top of this page. That triangle was made with OpenGL and the purpose of this section of my website is to explain how it was created and how all kinds of polygons can be created using OpenGL and then included in web pages, videos, or even video games if someone has the right skills.

OpenGL describes a series of functions to describe colors and shapes and where they should be. I specifically use version 2.1 and use this reference when I need to look up a certain function. However, OpenGL does not describe how to actually create a window to draw the shapes onto! For this I use the library freeglut because it is used in many tutorials and I found good help available on it. Neither freeglut nor opengl have a built in way of saving image files so that part is my own invention modified from my other project Binary Bit Map.

The full source code required to make that triangle is available. You can download all 3 of these files.
main.c
makefile
polygon_animation.txt

To make it work you will need a lot of tools however! A C compiler, a PC with good operating system(preferably Linux), and a method of installing freeglut. This is the unfortunate disadvantage of being a C programmer. Using the tools can be harder than writing the actual code. In the future I intend to write a guide on this topic. But any experienced C programmer who has compiled other things from source can figure it out. For non programmers, all you need to know is that OpenGL is quite capable of doing incredible graphics! I recommend learning the C Programming Language and OpenGL if you are looking to make similar graphics. I have only a very basic understanding of it but my polygons are proof that it works.

Aside from freeglut, I have also had success with glfw. It works a little differently in that it does not require a display callback and also that the programmer has to know better how to control the timing of it because it doesn't have the timed callback functions and I use functions which get the time and loop until the right amount has passed.
But no matter what, the same exact OpenGL code is available whether freeglut or glfw once the context is set up. Therefore the following pentagram was made using the exact same code that saves image files as was used for the triangle.

The full source code required to make the above pentagram is also available. You can download these 2 files.
main.c
makefile

OpenGL is definitely not limited to only black and white, even though the theme of my site is based on those two colors. For this reason I also made the color changing hue square which you should also see above this paragraph. Like the other examples, I have provided the source. However, notice that this time there are multiple files. I do not always put everything in only the main.c file as in the two above examples.

main.c
gl_bbmio.h
gl_bbm_polygon.h
gl_bbm_palette.h
makefile

If you like what you see here. You may want to see the checkerboard examples.

You may have noticed that there is no text on any of the animations. This is because at the time I did not know how to draw text in a program created with OpenGL. However I did have some success later at using FTGL to draw text in an animation. My skills and knowledge are slowly improving.

Some time after I learned to use FTGL I began a new project which will function as the place everybody who visits my website can find the latest version of my OpenGL code including better versions of the header files seen in the other examples. I now prefer glfw for the greater control it allows me to have.

Most OpenGL code on this website is compatible with legacy version 1.1 which is considered outdated at this time. I still prefer it though. However I decided to learn modern or core version 3.3 just to see how it is different. It requires shaders and is a lot more complicated but I wanted a challenge.