01.opengl function

glm::mate4 Identity(1.0f): In this code, a 4*4 matrix is ​​defined to represent the projection or projection matrix of a transformation matrix, where 'glm::mat4' represents 4* in the GLM library 4 matrix type, and Identity represents a variable name . 1.0f means initializing the matrix to the identity matrix, that is, the matrix on the diagonal is all 1, and the remaining elements are all 0.

glEnable(): Enable the specified OpenGL function. This function can accept a parameter to specify the function that needs to be enabled.
    For example, glEnable(GL_BLEND) can enable the blending function,
             glEnable(GL_DEPTH_TEST) can enable the depth test function,
             glEnable(GL_TEXTURE_2D) can enable the 2D texture mapping function, etc.

glDisable(): Turn off the specified OpenGL function. This function can accept a parameter that specifies the function that needs to be turned off .
    For example, glDisable(GL_BLEND) can turn off the blending function,
              glDisable(GL_DEPTH_TEST) can turn off the depth testing function,
              glDisable(GL_TEXTURE_2D) can turn off the 2D texture mapping function, etc.

glBlendFunc(): Set the blending function. This function accepts two parameters, namely the source factor and the target factor, which are used to control how the source color and target color are mixed during mixing.     For example, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) can be set to the source color source alpha + target color (1-source alpha) for blending.

glViewport(): Set the viewport size and position. This function accepts four parameters, which are the x coordinate of the lower left corner of the viewport, the y coordinate of the lower left corner, width, and height.
    For example, glViewport(0, 0, 640, 480) can set the viewport to the area with the lower left corner coordinates (0, 0), a width of 640, and a height of 480.

The glBindFramebuffer() function is a function used to bind buffer objects in OpenGL;
    its prototype is: void glBindFrambuffer(GL_FRAMEBUFFER, GLuint framebuffer);
where 'target' indicates the type of buffer object to be bound, and the optional value is 'GL_fRAMEBUFFER' , 'GL_READ_FRAMEBUFFER' and 'GL_DRAW_FRAMEBUFFER', the default value is 'GL_FRAMEBUFFER', the default value is 'GL_FRAMEBUFFER', which means binding the read and write buffer objects at the same time,
framebuffer means the ID of the buffer object to be bound.

    Buffer objects are an important concept in OpenGL for off-screen rendering. Off-screen rendering refers to outputting the rendering results to a texture or rendering buffer instead of outputting them directly to the screen. A framebuffer object can contain one or more render buffers or texture attachments, and can be bound to different stages of the rendering pipeline for rendering. Advanced rendering techniques such as screen post-processing, rendering to textures, multisampling, etc. can be implemented using framebuffer objects.
Use the 'glBindFramebuffer()' function to bind a buffer object to the OpenGL rendering pipeline, thereby outputting the rendering results to the framebuffer object. After binding a buffer object, all rendering operations will affect the buffer object instead of the screen. The binding operation can be unbound by setting the 'framebuffer' parameter to 0.

eglSwapBuffer(): is a function of the EGL API, used to exchange the front and rear buffers of the specified EGL window. In double-buffered drawing, the application will draw in the back buffer, the application will draw in the back buffer, and the final rendering result will be stored in the back buffer. The front buffer displays the rendering result of the previous frame. The function of 'eglSwapBuffers()' is to swap the contents of the back buffer into the front buffer so that the rendering results can be displayed on the screen.
When rendering with opengl ES, 'eglSwapBuffers()' is usually called after a frame of drawing is completed. For example, if you write a game using OPenGl ES, then each frame of rendering will be displayed on the screen through 'eglSwapBuffers()'.

 this->perception_pic1 = new HwBuffer(NPU_BUFFER_WIDTH, NPU_BUFFER_HEIGHT, DRM_FORMAT_RGB888);
Create a new instance of the class named 'HwBuffer' and assign it to the member variable 'perception_pic1' of the current object. The 'HwBuffer' constructor receives two Parameters 'NPU_BUFFER_WIDTH' and 'NPU_BUFFER_HEIGHT', these parameters are defined as constants in the code. The third parameter "DRM_FORMAT_RGB888" of the constructor specifies the buffer format as 24-bit RGB. This indicates that 'HwBuffer' is a class representing an in-memory image buffer, with hardware acceleration.

Off -screen rendering refers to rendering without displaying the rendering results on the screen. It is usually used to generate application scenarios such as textures, shadows, and post-production special effects.

Off-screen rendering requires creating an Off-screen Framebuffer Object (FBO for short) and drawing the rendering results to the FBO. After rendering is completed, the texture on the FBO or the data in the render buffer can be read out, or mapped to other objects as textures. Because off-screen rendering does not need to be displayed on the screen, higher-precision, larger-sized render targets can be used, thereby improving rendering effects.

In OpenGL ES, the current frame buffer is bound to the specified FBO through the glBindFramebuffer() function, then the glRenderbufferStorage() or glTexImage2D() function is used to create a rendering buffer or texture as an attachment to the FBO, and finally the rendering operation is performed. After rendering is completed, you can use the glReadPixels() function to read the pixel data on the FBO into memory, or directly map the texture on the FBO to other objects. Off-screen rendering requires attention to issues such as memory management and performance optimization.

Guess you like

Origin blog.csdn.net/m0_48707860/article/details/130576546