Get started with LearnOpenGL

Write in front

  Original link . The original text should be a project on github. This article is mainly used to record some knowledge points and problems encountered by myself.

OpenGL

  Before starting this journey, let's first understand what OpenGL is. It is generally regarded as an API (Application Programming Interface), which contains a series of functions that can manipulate graphics and images. However, OpenGL itself is not an API, it is just a specification (Specification) developed and maintained by the Khronos organization.
  The OpenGL specification strictly stipulates how each function should be executed and their output value. As for the specific implementation of each internal function (Implement), it will be determined by the developer of the OpenGL library.
  The developer of the actual OpenGL library is usually the manufacturer of the graphics card. The OpenGL versions supported by the graphics card you purchased are specially developed for this series of graphics cards. Since most implementations of OpenGL are written by graphics card manufacturers, when a bug occurs, it can usually be resolved by upgrading the graphics card driver. These drivers will include the latest version of OpenGL that your graphics card can support, which is why it is always recommended that you occasionally update the graphics card driver.

Core mode and immediate rendering mode

  Early OpenGL used immediate rendering mode (Immediate mode, that is, fixed rendering pipeline), which is very convenient to draw graphics. Most functions of OpenGL are hidden by the library, and developers rarely have the freedom to control how OpenGL performs calculations. The developers are eager to have more flexibility. Over time, the specifications have become more and more flexible, and developers have more control over drawing details. The immediate rendering mode is indeed easy to use and understand, but it is too inefficient. Therefore, starting from OpenGL 3.2, the specification document began to abandon the immediate rendering mode, and developers are encouraged to develop in the Core-profile of OpenGL. The specification of this branch completely removes the old features.

Expand

  A major feature of OpenGL is the support for extensions. When a graphics card company proposes a new feature or a major rendering optimization, it is usually implemented in the driver in an extended manner. If a program runs on a graphics card that supports this extension, developers can use some of the more advanced and effective graphics features provided by this extension. In this way, developers can use these new rendering features without waiting for a new OpenGL specification to be available, and simply check whether the graphics card supports this extension. Usually, when an extension is very popular or very useful, it will eventually become part of the future OpenGL specification.
Insert picture description here

state machine

  OpenGL itself is a huge state machine (State Machine): A series of variables describing how OpenGL should now run. The state of OpenGL is usually called OpenGL context (Context). We usually use the following methods to change the OpenGL state: setting options, operating buffers. Finally, we use the current OpenGL context to render.
  Suppose that when we want to tell OpenGL to draw a line segment instead of a triangle, we change the OpenGL state by changing some context variables to tell OpenGL how to draw. Once we change the state of OpenGL to draw a line segment, the next drawing command will draw a line segment instead of a triangle.
  When using OpenGL, we will encounter some state -changing functions, which will change the context . And state -using functions, which perform some operations according to the current OpenGL state . As long as you remember that OpenGL is essentially a large state machine, it will be easier to understand most of its features.

Object

  The OpenGL library is written in C language and also supports derivation of multiple languages, but its core is still a C library. Because some language structures of C are not easily translated to other high-level languages, some abstraction layers are introduced when OpenGL is developed. "Object" is one of them.
  An object in OpenGL refers to a collection of options, which represents a subset of the OpenGL state. For example, we can use an object to represent the settings of the drawing window, and then we can set its size, the number of supported colors, and so on. You can think of the object as a C-style structure (Struct):
Insert picture description here

Guess you like

Origin blog.csdn.net/xiji333/article/details/112796863