Simple-framework (MaliSDK framework analysis), framework

Source: Internet
Author: User
Tags printable characters

Simple-framework (MaliSDK framework analysis), framework

Simple-framework(Mali SDK framework analysis)

 

1. All definitions and implementations are placed in the same namespace, And the # include file is usually outside the namespace. The total namespace is namespace MaliSDK {}. When used, using namespaceMaliSDK contains all the content in the namespace.

2. define the type in the header file and use # ifndef, # define, # endif to prevent multiple inclusion issues. This is implemented in the corresponding. cpp file. Definition and implementation are separated.

 

Functions of each file:

1. VectorTypes. h: This file defines the vector type, which is implemented using a custom struct type. Vec2, Vec3, and Vec4 represent the 2, 3, and 4-dimensional vectors of an integer and are used to store coordinates and other data. Similarly, Vec2f, Vec3f, and Vec4f represent floating point vectors. There is no corresponding. cpp file, and only the type is defined in the. h file.

2. Platform. h: defines the abstract base class Platform. Then, generate three child classes WindowsPlatform, DesktopLinuxPlatform, and LinuxOnARMPlatform based on the public inheritance.

2.1 define static variable parameter member function log (const char * format,...) in the abstract base class ,...) to print the log information, and indirectly combine it into GL_CHECK (x) to detect the return value of the gl function.

VoidPlatform: log (const char * format ,...)

{Va_list ap;

Va_start (ap, format); // ap points to the first address of a Variable Parameter

Vfprintf (stderr, format, ap); // mainly used

Fprintf (stderr, "\ n ");

Va_end (ap );

}

# DefineGL_CHECK (x )\

X; \\// returns the value first, and then checks and processes errors in block statements.

{\

GLenum glError = glGetError ();\

If (glError! = GL_NO_ERROR ){\

LOGD ("glGetError () = % I (0x %. 8x) at % s: % I \ n ", glError, glError, _ FILE __, _ LINE __);\

Exit (1 );\

}\

}

2.2 LOGD macro to print debugging information. If DEBUG is defined, the debugging information is printed; otherwise, the debugging information is not printed.

Example:

LOGD ("vertexShaderID = % d", vertexShaderID );

// The definition is as follows:

# Ifdef DEBUG

# Define LOGD fprintf (stderr, "Debug:"); Platform: log

# Else

# Define LOGD

 

There are three types of macro definitions of printed information:

# Define LOGIPlatform: log LOGI is used to print normal information

# Define LOGEfprintf (stderr, "Error:"); Platform: log LOGE is used to print Error information

LOGD macro to print debugging information.

 

2.3 static Platform * getInstance (void); call the getInstance function of the corresponding Platform based on different platforms and return a base class pointer pointing to the object of the derived class; virtual voidcreateWindow (int width, int height), virtual void destroyWindow (void), and virtual WindowStatus checkWindow (void) of the subclass are called through the virtual functions and polymorphism of the base class ); specific implementation method.

 

3. LinuxOnARMPlatform class: Class Based on ARM Linux platform. Three virtual functions are implemented for the platform environment.

Use the fbdev_window structure to create a window.

4. plutoplinuxplatform class: A class based on the Linux platform. Three virtual functions are implemented for the platform environment.

5. WindowsPlatform class: Windows platform-based class. Three virtual functions are implemented for the platform environment.

6. EGLRuntime class: mainly manages and configures EGL-related interface calls. Class. Configure the display environment.

ConfigAttributes []: Specifies the config attribute list, which is the required attribute configuration. It mainly includes RGBA, buffer, deep cache size, rendering type, and anti-sample size configuration.

ContextAttributes []: context attribute list, mainly used to specify the version of OpenGL es.

Invalid wattributes []: Window attribute list. Specifies whether the rendering surface is a front-end cache area or a back-end cache area.

 

InitializeEGL function: configures a display window environment by calling a series of EGL interfaces.

EglGetDisplay: Creates and initializes the connection to the local EGL display, and opens the connection to The EGL Display Server.

EglInitialize: after the connection is successfully opened, You need to initialize EGL.

EglChooseConfig: queries all EGL surface configurations supported by the underlying window system. EGL returns the optimal configuration list based on the requirements specified by configAttributes. First, return the number of optimal configurations, and then the allocated space storage returns the array of sub-configuration lists. Then select RGB for the most in-depth configuration.

EglCreateWindowSurface: Creates a rendering area on the screen based on the most matched configuration.

EglCreateContext: Creates a rendering context.

EglMakeCurrent: Specify EGLcontext as the current context.

EglSwapBuffers: swap the front-end and back-end cache areas.

TerminateEGL function: cleanup at the end.

7. Shader class: used to create and compile a Shader object.

LoadShader: loads the source code of the shader to the character array or character pointer in the form of a file.

ProcessShader: Creates a coloring machine object, provides the source code of the coloring machine, compiles the coloring machine, and views the compilation status of the coloring machine. If the compilation fails, the source code and the log information compiled by the Shadow are printed.

8. matrix class: Matrix-related class, defining common proof and common proof operations, such as translation, rotation, scaling, multiplication, positive projection transformation proof, Perspective Projection Transformation Matrix, transpose, inverse Matrix. (Primary Order of matrix columns)

IdentityArray: a static unit matrix in the class.

DegreesToRadians: converts degrees to radians.

Multiply or *: matrix multiplication, primary column order.

GetAsArray: returns a pointer to a matrix element.

MatrixScale: multiply each element of the matrix by a scaling factor.

CreateScaling: Create a scaling matrix.

CreateTranslation: Creates a translation matrix.

MatrixPerspective: Creates a Perspective matrix.

MatrixOrthographic: creates an Ortho matrix.

CreateRotationX, createRotationY, and createRotationZ: rotate around the X axis, Y axis, and Z axis.

VertexTransform: multiply the vertex vector matrix.

Print: print the matrix element.

MatrixTranspose: matrix transpose.

MatrixDeterminant: calculates the value of the 3x3 or 4x4 matrix determinant based on the first line.

MatrixInvert: used to obtain the inverse matrix of the matrix with adjoint proof.

9. Timer class: provides a high-precision Timer class, which uses hardware timers and counters to achieve independent timing of the platform. It is divided into Linux and Windows, and mainly analyzes the Windows version.

Reset: set the current timestamp to the current time when the counter is converted.

GetTime: the difference between the current time and the timestamp at reset.

GetInterval: the time difference between the current time and the last time interval node.

GetFPS: calculates Frames Per Second every Second.

IsTimePassed: generates a certain interval. The default value is 1 second.

Read:

Prototype: BOOLQueryPerformanceFrequency (LARGE_INTEGER * lpFrequency );

Purpose: return the hardware-supported high-precision counter frequency.

Returned value: non-zero. Hardware supports high-precision counters. Zero, hardware does not support, and reading fails.

Call the QueryPerformanceFrequency () function to obtain the clock frequency of the timer. Then, call QueryPerformanceCounter () before and after the occurrence of an event that requires strict timing. the precise time of the event experience can be calculated using the difference in counting and clock frequency obtained twice.

10. ETCHeader class: obtains the ETC file header information from the ETC compressed texture .. The pkm file format has a total of 16 file headers. The first six bytes indicate the file format name and version type. 7, 8 bytes are null bytes. Indicates the maximum and minimum valid bits for compressing the texture width, and indicates the maximum and lowest valid bits for compressing the texture height. 12, 13 the maximum and minimum valid bits of the original texture width, and are the highest and lowest valid bits of the original texture height.

GetWidth: the width of the original texture. GetHeight: the length of the original texture.

GetPaddedWidth: compresses the texture width. GetPaddedHeight: the length of the compressed texture.

GetSize: the size of the compressed texture, in bytes. (ETC1 has four or eight bits per pixel and ETC2 has four or eight bits)

11. Texture class: Use textures.

GetCompressedTextureFormats: obtains the supported compressed texture formats and quantities.

IsETCSupported: determines whether the ETC texture compression is supported, and prints key information such as support for Texture Information and quantity.

LoadData: reads data from a file and can read compressed or uncompressed texture data.

CreateTexture: Creates a texture image of the specified size with random data. (RGBA four channels

CreateTexture: it can also be used to generate single-channel textures. (R single channel)

DeleteTextureData: Delete the texture image generated by createTexture.

LoadPKMData: extract the first 16 bytes of the ETC compressed texture file from the. pkm compressed texture image, extract the texture data, and return the pointer to the texture data.

LoadCompressedMipmaps: automatically loads various levels of mipmap compression textures. From level0 to the maximum level, it is loaded and bound to different compression texture levels of mipmap through glCompressedTexImage2D.

12. Text: Use textures to draw ANSI printable characters. The size of each character is 8*16 pixels. The default font size scaling factor scale is 1.0, and other reasonable values range from 0.75 to 3.0.

13. Geometry: this class is used to generate geometric shapes. It mainly produces the vertex data of rings, balls, cubes, and rectangles, and the normal vectors.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.