Study Link 1: https://pan.baidu.com/s/1xcTWd283zJ9bXCs2kYG-BA Extraction code: 7t5p Study Link 2: https://share.weiyun.com/ZgSMB098 Password: in4rmz
Qt has built-in support for OpenGL, which means that as long as your Qt version supports OpenGL, you can use OpenGL in your Qt application without installing OpenGL separately.
However, to use OpenGL in your Qt application, your system needs to have a graphics driver that supports OpenGL. This usually means you need to install an OpenGL-compatible graphics card driver on your system. Most modern desktop systems (including Windows, macOS, and most Linux distributions) come with OpenGL-supported graphics drivers pre-installed, so you usually do not need to install them manually.
If your system does not have an OpenGL-compatible graphics driver, or your current driver does not support the OpenGL version you require, you may need to manually install a new graphics driver. This usually involves downloading the driver from your graphics card manufacturer's website and installing it following their instructions.
Please note that although Qt supports OpenGL, not all Qt features require OpenGL. Most Qt features (including Qt Widgets and Qt Quick 2D) can run on systems without OpenGL. Only certain specific features (such as Qt Quick 3D and some Qt 3D features) require OpenGL.
1. Differences between Vulkan and OpenGL Regarding the differences between Vulkan and OpenGL: compared to OpenGL, Vulkan can describe your application's intended behavior to the graphics card in greater detail, allowing you to achieve better performance and lower driver overhead. Vulkan's design philosophy is basically similar to Direct3D 12 and Metal, but as a replacement for OpenGL, it was designed for cross-platform implementation from the start, and can be used for development on Windows, Linux, and Android. Khronos even provides a Vulkan SDK for Mac OS, although the underlying implementation of this SDK actually uses MoltenVK.
Vulkan's main goal is not to compete with DirectX, but to replace OpenGL, so the key focus is on the comparison with the latter. At high resolutions, high image quality, when the GPU is the primary bottleneck, the performance of Vulkan and OpenGL is roughly the same. But as resolution decreases, the CPU becomes more impactful on performance, and Vulkan's advantage gradually becomes apparent — especially on the GTX 980 Ti, Vulkan can outperform OpenGL by as much as 33%!
2. OpenGL Objects We can understand an OpenGL object as a collection of states, responsible for managing all the states under it. Of course, besides states, OpenGL objects also store other data. Note that these states do not overlap with the states in the context mentioned above. Only when an OpenGL object is bound to a context will the various states of the OpenGL object be mapped to the context's state. Therefore, if you change the context's state at this point, it will also affect the bound object, and conversely, functions that depend on these context states will also use the data stored in this object. Therefore, binding an OpenGL object can be done either to modify the object's state (most objects need to be bound to the context before their state can be changed), or to allow the context to use the object's state during rendering.
3. How OpenGL Works First, I think the hardest part to understand when getting started with OpenGL is creating the full program. Even though I already had some basic graphics knowledge, I was completely confused when I started working with OpenGL, because I had no idea how its programs operate. So here, I think the first thing we need to explain is OpenGL's overall working principle: OpenGL is a state machine, so its operation relies on context switching, or more precisely, setting the current context. Therefore, whether you create a shader, VAO, or VBO, you need to bind them to the current context after creation.
4. Common Difficulties When Learning OpenGL: Difficulty 1: Do not know how to combine individual examples into a complete rendering engine Difficulty 2: Cannot connect shaders to the CPU workflow, and do not know where a given resource/data comes from. Even if you know when it is sent to the GPU, you still do not understand how the GPU locates the resource/data. Difficulty 3: It is difficult to develop the mindset required for parallel computing Difficulty 4: It is difficult to understand how various templates work across multiple batches. You cannot concretely understand the process of blending and testing, and cannot understand the true meaning of a FrameBuffer. Difficulty 5: It is difficult to build spatial imagination, and do not understand how matrix transformation transforms vertices or other data into different spaces for unified calculation. Difficulty 6: It is difficult to understand how the transition from Vertex to Fragment occurs.
5. Building an OpenGL Program 1. Create a build directory in the project root: mkdir build cd build 2. Run the cmake command, specifying the build system and compiler to use: cmake .. -G Ninja -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ 3. Run ninja: After ninja finishes compiling, you can find the executable in the build directory. If it runs normally, that means your OpenGL development environment has been successfully set up.
This is a discussion topic separated from the original topic at https://studygolang.com/topics/17495