Basic knowledge that is useful to know when using OpenGL
投稿日: Invalid Date
更新日: 2024/07/02
I don't want to explain too much about the history or mechanisms because it makes me sleepy. However, this part is where I struggled a lot while studying on my own, so I think I have to explain it. I will do my best to keep the explanation as concise as possible.
You don't need to understand everything, but I think it's good to have an overview, so I'll summarize it in the first session. The first session is fine for skimming.
As you progress to the following pages, I believe your understanding of OpenGL will deepen, so please revisit it then.
Roughly minimal hardware knowledge
Graphic drivers are included with CPUs and GPUs, essentially the brain of a computer is the CPU, and the GPU assists with that. Major manufacturers of graphic drivers include Intel, NVidia, and AMD.
NVidia and AMD manufacture a part called GPU (graphic board). To put it very roughly, a GPU is a component that can execute simple programs at extremely high speeds. OpenGL utilizes this GPU to create images quickly. Basically, you will need to create a program called a shader.
However, not all PCs require high performance, so many PCs do not have a built-in GPU. In that case, the processing is done by the CPU, but CPUs are originally not good at such processing. Therefore, in the old days, CPUs incorporated the functions of GPUs.
Of course, it does not come close to a PC with a GPU installed. Integrated graphics, sometimes referred to as onboard graphics or simply onboard (as it used to be a feature on the motherboard in the past).
I wrote this for those who are not familiar with CPUs and GPUs, prioritizing understanding through imagery, so it may not be completely accurate. Exploring parts used in PCs and other components can be quite fascinating, so whenever you feel like it, you may want to give it a try.
Why not use the new OpenGL?
This was written in the previous message, but it is because there are many computers that are not compatible.
Addition:
In most cases, the new version can be written more concisely, and honestly, I don't think there is much reason to support old computers at this point. You will be happier if you develop from version 4 or at least version 3.(At 2020/02)
Both GPU and CPU manufacturers are competing to develop better products, so performance is constantly improving and new features are being added. Naturally, OpenGL is also evolving to utilize these features.
However, there are times when new features are not supported on older GPUs or CPUs. And it is not always necessary to have the latest features in order to program.
Of course, if new functionality is needed, you should use the new OpenGL. In that case, the only option for users is to "purchase a more expensive PC if they want to run this program."
In reality, this is particularly evident in games. Many people buy new PCs specifically for new games.
Current Status of GLU (OpenGL Utility Libraries)
GLU is a library that assists OpenGL, and includes functions such as gluLookAt and gluPerspective. Each function is used to set up parameters like the viewpoint.
In conclusion, I would say that GLU can still be used, but basically, it is better to use the more advanced GLM.
I am not researching in detail, but it is doubtful whether the new OpenGL supports GLU, and there is no real benefit in using a library that has been neglected for over 10 years.
I will explain in detail later, but functions like gluLookAt
and gluPerspective
set values to the built-in variable gl_ModelViewProjectionMatrix
. However, nowadays, it is more common to create the ModelViewProjection matrix on the C++ side using functions like glm::LookAt
and glm::Perspective
, and send it to the shader side as a uniform variable.
Types of Graphics Libraries
OpenGL (GLSL), DirectX (HLSL), Vulkan, Cg, Java 3D, and others are available.
The most famous ones are the open-source OpenGL and Microsoft-developed DirectX. DirectX only works on Windows OS, while OpenGL works on various environments. I think you will need to use one of these if you do CG.
Vulkan allows for highly advanced tuning when creating software such as VR. It is positioned as the successor to OpenGL, but requires greater knowledge and technical expertise than OpenGL. (It is not to say that OpenGL has fatal flaws, but rather that they serve different purposes.)
So I think it's okay to consider that OpenGL is a different thing. Development of OpenGL continues, and it will keep evolving, so please rest assured.
Cg development has already been terminated, so there is no reason to start using it now.
Java 3D doesn't really have much presence to begin with. I've never seen anyone using it. It's a bit unclear what its purpose is. You can use OpenGL with Java, so let's use that instead.
In summary, let's use either OpenGL or DirectX.
What is Computer Graphics (CG) Technology
Programming, not just CGI, is a technology of sleight of hand no matter how far you go.
In languages like C, the existence of data types such as int
and double
is due to the limited computational resources of computers. It is impossible to realize infinite numerical values on a computer, so only a practical range is implemented.
The same applies to CG programming. It is not possible to draw infinitely smooth curves or surfaces.
The emphasis is on how it appears as a curve or surface when it is output on the screen.
So basically, curves are approximated by multiple straight lines.
The Old Good OpenGL and the New OpenGL
Let's take a rough look at the history of OpenGL.
Year | Version |
---|---|
1992 | OpenGL 1.0 |
1997 | OpenGL 1.1 |
2006 | OpenGL 2.1 |
2008 | OpenGL 3.0 |
2010 | OpenGL 3.3 |
2010 | OpenGL 4.0 |
2010 | OpenGL 4.1 |
2011 | OpenGL 4.2 |
2012 | OpenGL 4.3 |
2013 | OpenGL 4.4 |
2014 | OpenGL 4.5 |
2017 | OpenGL 4.6 |
In the OpenGL 1.x series, there were functions such as glRotate
and glScale
. These functions are used to rotate or scale polygons as intended.
Just a heads up, these functions are now deprecated, and these processes are currently implemented using shader with matrix calculations. However, replacement functions for glRotate
and glScale
are provided in GLM, so you don't need to worry too much about it.
The advantage of these functions is that you can create programs without any knowledge of matrix calculations and the like. Perhaps because of this, some people say it's a thing of the past. I learned this in college, but I wonder why I learned it since it's no longer being used. The drawback is its lack of flexibility and the inefficiency in processing.
OpenGL 2.1 now includes the GLSL programming shader as a standard specification.
In OpenGL 3.0, efforts were made to streamline the bloated OpenGL specification, leading to the deprecation of many features. However, OpenGL maintains compatibility across versions by allowing deprecated functions to be used as extension functions. This further complicates the specification...
In the OpenGL 4.x series, it has been evolving very rapidly to keep up with its rival DirectX (which used to progress quite slowly).
As providing a detailed explanation here may become messy, please refer to the Wiki if you are interested.
Next time, I will finally start writing the code.