Mini-game universal graphics rendering method and device based on layered architecture

By adopting a hierarchical architecture-based method in the game graphics rendering system, the decoupling of the operating system and the game engine and the efficient conversion of the script engine and native code are solved, and the problems of cross-platform universality and resource management in the existing technology are realized, and efficient and flexible mini-game graphics rendering are achieved.

CN119345689BActive Publication Date: 2025-04-25ZHUHAI FANTAI GEEK TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411909528.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-25
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

Existing game graphics rendering systems lack cross-platform universality, make them difficult to achieve flexible function expansion, and have shortcomings in script engine integration, memory management, and rendering interface design.

Method used

The general graphics rendering method of mini-games based on a hierarchical architecture is adopted to decouple the operating system and the game engine through the window abstraction layer, providing a unified game canvas operation interface; the scene initialization, object drawing and animation update interface is provided at the rendering implementation layer; the script engine and native code are efficiently converted through state objects and parameter parsers at the language binding layer, and a weak reference mechanism and termination callback are used to ensure automatic resource recycling.

Benefits of technology

It realizes a lightweight, cross-platform general rendering solution, improves the development efficiency and operation performance of mini-games, and solves the platform limitations and resource management problems of traditional rendering systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119345689B_ABST
    Figure CN119345689B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a method and device for universal graphics rendering of mini-games based on a layered architecture, which realizes the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulates the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing, and animation update are provided in the rendering implementation layer to realize real-time rendering functions. The language binding layer is innovatively designed to realize efficient conversion between the script engine and native code through state objects and parameter parsers, and adopts weak reference mechanism and finalization callback to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform universal rendering solution for mini-game development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a method and device for rendering general graphics for mini-games based on a layered architecture. Background Art

[0002] Traditional game graphics rendering systems are usually developed for specific platforms and lack cross-platform versatility. Existing rendering methods are often tightly coupled with specific game engines, making it difficult to achieve flexible functional expansion. Especially in the field of mini-game development, there is an obvious contradiction between the complexity of the system architecture and the need for lightweight.

[0003] At the same time, the existing system has obvious deficiencies in script engine integration and memory management. The traditional method lacks an efficient language binding mechanism, and the data conversion overhead between scripts and native codes is large. The system is also relatively simple in terms of resource management and fails to effectively handle memory leaks and garbage collection issues.

[0004] In addition, existing technologies also have problems in rendering interface design and abstract encapsulation. There is a lack of a unified canvas operation interface, the platform adaptation cost is high, and there is limited room for rendering performance optimization. Solving these problems is of great significance to improving the efficiency of mini-game development and operating performance. Summary of the invention

[0005] In response to the problems in the prior art, the present application provides a universal graphics rendering method and device for mini-games based on a layered architecture, which can provide a lightweight, cross-platform universal rendering solution for mini-game development.

[0006] In order to solve at least one of the above problems, the present application provides the following technical solutions:

[0007] In a first aspect, the present application provides a general graphics rendering method for mini-games based on a layered architecture, comprising:

[0008] The interaction between the operating system platform and the game engine is realized through the window abstraction layer, and the window creation instruction, the game event monitoring instruction and the image drawing instruction are encapsulated into a game canvas operation interface. The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen;

[0009] The rendering implementation layer calls the game canvas operation interface provided by the window abstraction layer to implement a rendering interface, wherein the rendering interface includes an initialization interface for a game scene, a drawing interface for a game object, and an update interface for a game animation, and the rendering interface performs real-time rendering of the game screen;

[0010] In the language binding layer, the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine are stored in the pointer of the state object. The state object generates a parameter parser to convert the script parameters into native data types. The parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro. The attribute callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner. The game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources. The language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to perform graphics rendering work of the mini-game.

[0011] Furthermore, the interaction between the operating system platform and the game engine is realized through the window abstraction layer, and the window creation instruction, the game event monitoring instruction and the image drawing instruction are encapsulated into a game canvas operation interface, including:

[0012] A window abstract interface class is defined in an underlying programming language, wherein the window abstract interface class includes a window identifier member and a window status information member, a window handle registration interface of an operating system platform is called based on the window identifier member to generate an application main window identifier, a system message loop interface is called based on the window status information member to parse window event data, and the window abstract interface class maps an application programming interface provided by the operating system platform to a corresponding data structure;

[0013] A canvas rendering interface is defined in the window abstract interface class. The canvas rendering interface includes a drawing surface member and a rendering context member. Based on the drawing surface member, a graphics device interface is called to construct drawable surface data of the window client area. Based on the rendering context member, a graphics library interface is called to configure drawing attribute parameters. The canvas rendering interface writes image data by exchanging front and back buffers.

[0014] Furthermore, the game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen, including:

[0015] A window processing class is defined in the game canvas operation interface. The window processing class includes a window procedure member and a message dispatching member. The window procedure member calls a window identifier to parse an application window message. The message dispatching member calls a message queue interface to allocate window event data. The window processing class converts the window event of the operating system platform into standardized game event data.

[0016] A screen refresh class is set in the window processing class, and the screen refresh class includes a vertical synchronization member and a rendering command member. A display refresh rate interface is called based on the vertical synchronization member to calculate the frame interval time, and a graphics library interface is called based on the rendering command member to execute a drawing instruction sequence. The screen refresh class triggers a buffer exchange operation according to a synchronization signal.

[0017] Furthermore, the rendering implementation layer calls the game canvas operation interface provided by the window abstraction layer to implement a rendering interface, the rendering interface includes an initialization interface for a game scene, a drawing interface for a game object, and an update interface for a game animation, and the rendering interface performs real-time rendering of the game screen, including:

[0018] A rendering pipeline class is defined in the rendering implementation layer. The rendering pipeline class includes a scene management member and a rendering state member. A game canvas operation interface is called based on the scene management member to build a scene graph data structure. A graphics context interface is called based on the rendering state member to set a rendering parameter configuration. The rendering pipeline class organizes game object data into rendering batch data.

[0019] An animation control class is set in the rendering pipeline class, and the animation control class includes rendering queue members and animation clock members. A drawing instruction interface is called based on the rendering queue members to sort the rendering instruction set, and a timestamp interface is called based on the animation clock members to calculate animation interpolation parameters. The animation control class allocates drawing resources according to rendering priority.

[0020] Furthermore, storing the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine in the pointer of the state object at the language binding layer includes:

[0021] A state object class is defined at the language binding layer, wherein the state object class includes a virtual machine stack pointer member and a function table pointer member, a stack space allocation address of a script engine is mapped based on the virtual machine stack pointer member, a function symbol address of the script engine is mapped based on the function table pointer member, and the state object class writes virtual machine memory layout data into a pointer array;

[0022] An exception handling class is set in the state object class, and the exception handling class includes an exception table pointer member and a call stack pointer member. The exception vector address of the script engine is mapped based on the exception table pointer member, and the stack frame data of the script engine is mapped based on the call stack pointer member. The exception handling class writes the exception handling routine address into the jump table.

[0023] Furthermore, the state object generates a parameter parser that converts the script parameter into a native data type, and the parameter parser converts the callback function into a function definition of the game script engine through a property callback wrapper macro, and the property callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner, including:

[0024] A parameter parser class is defined in the state object, wherein the parameter parser class includes a type conversion member and a reference count member, and the parameter stack data of the script engine is read based on the type conversion member, and the life cycle of the object reference is recorded based on the reference count member. The parameter parser class writes the script parameter value into the native type variable;

[0025] A callback mapping class is set in the parameter parser class, the callback mapping class includes a function wrapper member and an object mapping member, a script interface declaration of the callback function is generated based on the function wrapper member, a hash table structure of pointers to objects is established based on the object mapping member, and the callback mapping class uses a weak reference counter to record object data.

[0026] Furthermore, the game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources, and the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to perform the graphics rendering work of the mini-game, including:

[0027] A resource recycling class is defined in the language binding layer. The resource recycling class includes a termination callback member and a reference cleanup member. A script object destruction operation is performed based on the termination callback member. A memory space of an object mapping table is released based on the reference cleanup member. The resource recycling class resets a weak reference counter to zero.

[0028] A rendering component class is set in the resource recycling class, and the rendering component class includes a rendering agent member and a drawing command member. A rendering interface is called based on the rendering agent member to register a rendering callback function, and a rendering interface is called based on the drawing command member to execute a drawing operation sequence. The rendering component class drives the screen update according to the game logic.

[0029] In a second aspect, the present application provides a general graphics rendering device for mini-games based on a layered architecture, comprising:

[0030] An abstract module, used to realize the interaction between the operating system platform and the game engine through the window abstraction layer, encapsulate the window creation instruction, the game event monitoring instruction and the image drawing instruction into a game canvas operation interface, and the game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input event of the player, and the game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen;

[0031] A rendering module, used to call the game canvas operation interface provided by the window abstraction layer in the rendering implementation layer to implement a rendering interface, wherein the rendering interface includes an initialization interface for a game scene, a drawing interface for a game object, and an update interface for a game animation, and the rendering interface performs real-time rendering of the game screen;

[0032] A binding module is used to store the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine in the pointer of the state object at the language binding layer, the state object generates a parameter parser to convert the script parameter into a native data type, the parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro, the attribute callback wrapper macro establishes a mapping table from native pointer to game object and stores the game object in a weak reference manner, the game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources, and the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to perform the graphics rendering work of the mini-game.

[0033] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the general graphics rendering method for mini-games based on a layered architecture are implemented.

[0034] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the general graphics rendering method for mini-games based on a layered architecture.

[0035] In a fifth aspect, the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the general graphics rendering method for mini-games based on a layered architecture.

[0036] It can be seen from the above technical solution that the present application provides a general graphics rendering method and device for mini-games based on a layered architecture, which realizes the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulates the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing, and animation update are provided in the rendering implementation layer to realize real-time rendering functions. The language binding layer is innovatively designed to realize efficient conversion between the script engine and native code through state objects and parameter parsers, and adopts weak reference mechanisms and termination callbacks to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform general rendering solution for mini-game development. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0038] Figure 1 This is one of the flowcharts of a general graphics rendering method for mini-games based on a layered architecture in an embodiment of the present application;

[0039] Figure 2 This is a second flow chart of a general graphics rendering method for mini-games based on a layered architecture in an embodiment of the present application;

[0040] Figure 3 This is a third flow chart of a general graphics rendering method for mini-games based on a layered architecture in an embodiment of the present application;

[0041] Figure 4 This is a fourth flow chart of a general graphics rendering method for mini-games based on a layered architecture in an embodiment of the present application;

[0042] Figure 5 This is a fifth flow chart of a general graphics rendering method for mini-games based on a layered architecture in an embodiment of the present application;

[0043] Figure 6 This is a sixth flow chart of a general graphics rendering method for mini-games based on a layered architecture in an embodiment of the present application;

[0044] Figure 7 This is a flowchart of a general graphics rendering method for mini-games based on a layered architecture in an embodiment of the present application, No. 7;

[0045] Figure 8 This is a structural diagram of a general graphics rendering device for mini-games based on a layered architecture in an embodiment of the present application;

[0046] Fig. 9 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application.

[0047] Reference numerals:

[0048] Electronic device 9600, central processing unit 9100, memory 9140, communication module 9110, input unit 9120, audio processor 9130, display 9160, power supply 9170, buffer memory 9141, application / function storage unit 9142, data storage unit 9143, driver program storage unit 9144, antenna 9111, speaker 9131, microphone 9132. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0050] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.

[0051] Taking into account the problems existing in the prior art, the present application provides a general graphics rendering method and device for mini-games based on a layered architecture, which realizes the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulates the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing, and animation update are provided in the rendering implementation layer to realize real-time rendering functions. The language binding layer is innovatively designed to realize efficient conversion between the script engine and the native code through state objects and parameter parsers, and a weak reference mechanism and finalization callback are used to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform general rendering solution for mini-game development.

[0052] In order to provide a lightweight, cross-platform universal rendering solution for mini-game development, this application provides an embodiment of a mini-game universal graphics rendering method based on a layered architecture, see Figure 1 The general graphics rendering method for mini-games based on the layered architecture specifically includes the following contents:

[0053] Step S101: The interaction between the operating system platform and the game engine is realized through the window abstraction layer, and the window creation instruction, the game event monitoring instruction and the image drawing instruction are encapsulated into a game canvas operation interface. The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen;

[0054] Optionally, this embodiment realizes the decoupling between the operating system platform and the game engine by constructing a window abstraction layer, and provides a unified abstract interface for mini-game graphics rendering. The window abstraction layer is implemented using the underlying programming language, ensuring direct interaction performance with the operating system platform.

[0055] In the process of window creation, this embodiment first defines a window abstract interface class, which contains two core members: window identifier and status information. The window identifier member obtains the unique identifier of the application main window by calling the window handle registration interface of the operating system. This identifier is used as the index for all subsequent window operations. For example, when creating a 2D horizontal version of a game window, the window title, size, style and other attributes can be set through the identifier to achieve personalized customization of the game window.

[0056] This embodiment encapsulates the system message loop interface in the window state information member, which is responsible for parsing the window event data from the operating system. These events include state changes such as window creation, destruction, activation, and minimization, as well as interactive information of input devices such as keyboards and mice. By establishing an event mapping table, the native window messages of the operating system are converted into a unified game event format, which is convenient for the processing of the upper-level game logic.

[0057] In terms of rendering implementation, this embodiment designs a special canvas rendering interface, which contains two key members: drawing surface and rendering context. The drawing surface member is responsible for building a drawable surface in the window client area by calling the graphics device interface. This surface serves as the target buffer for rendering the game screen. For example, when implementing a card game, the size and format of the drawing surface can be dynamically adjusted according to the number and layout of game cards.

[0058] The rendering context member is responsible for configuring the graphics rendering parameters and setting the drawing attributes by calling the underlying graphics library interface. These attributes include color blending mode, transparency, transformation matrix, etc. In order to achieve smooth screen switching, this embodiment adopts double buffer technology, completes all drawing operations in the background buffer, and then exchanges it with the foreground buffer at an appropriate time to avoid screen tearing.

[0059] This embodiment innovatively designs a game canvas operation interface that integrates window management and rendering control functions. Through this unified interface, the upper-level game logic can easily create windows, process input events, and update the screen. For example, when developing a simple puzzle game, you only need to call the corresponding interface method to create a game window, respond to player operations, and draw the game screen.

[0060] In order to improve rendering performance, this embodiment implements a batch processing mechanism for rendering instructions. When executing drawing operations, multiple drawing commands are first organized into batches and then submitted to the graphics library for execution at one time, reducing the overhead of API calls. This is particularly effective when processing game scenes with a large number of sprite objects, and can significantly improve rendering efficiency.

[0061] This embodiment also takes into account the cross-platform compatibility issue. Through the encapsulation of the abstract layer, the API differences of different operating system platforms are shielded. Developers only need to focus on the unified interface without considering the underlying implementation details. For example, the same game code can run on Windows and Linux platforms, and only the abstract layer adapter of the corresponding platform needs to be implemented.

[0062] In terms of event processing, this embodiment implements an efficient event distribution mechanism. By establishing an event listener linked list, multiple game objects are supported to respond to user input at the same time. This design is particularly useful when developing complex interactive games, and can accurately route input events to corresponding processing programs.

[0063] The window abstraction layer design of this embodiment significantly improves the efficiency and maintainability of game development. Through unified interface abstraction, the interaction logic between the game engine and the operating system is simplified, allowing developers to focus on the implementation of gameplay. At the same time, good architecture design also facilitates subsequent function expansion, and new rendering features can be easily integrated into the existing framework.

[0064] Step S102: calling the game canvas operation interface provided by the window abstraction layer in the rendering implementation layer to implement the rendering interface, wherein the rendering interface includes a game scene initialization interface, a game object drawing interface, and a game animation update interface, and the rendering interface performs real-time rendering of the game screen;

[0065] Optionally, this embodiment builds a complete rendering interface system in the rendering implementation layer, and realizes efficient rendering of the game scene by calling the game canvas operation interface provided by the window abstraction layer. The rendering implementation layer adopts a layered design mode, dividing the rendering function into three main modules: scene initialization, object drawing, and animation update.

[0066] This embodiment first designs a scene initialization interface, which is responsible for constructing the basic data structure of the game scene. During the scene initialization process, the game objects are organized through the scene tree structure, the parent-child node relationship is established, and the spatial hierarchical management of the objects is realized. For example, in a multi-level platform jumping game, the scene tree can contain multiple rendering levels such as background layer, platform layer, character layer and UI layer, and each level contains corresponding game objects.

[0067] In the implementation of the game object drawing interface, this embodiment uses rendering batch optimization technology. By analyzing the material, texture, and rendering state of the game object, objects with similar rendering properties are organized into the same rendering batch, reducing the overhead of rendering state switching. For example, when drawing multiple sprites with the same texture, they can be merged into one rendering call, significantly improving rendering performance.

[0068] The animation update interface of this embodiment adopts a time-driven update mechanism. By accurately calculating the frame interval time, the smoothness and consistency of the animation playback are ensured. When processing multiple animation sequences, the animation state machine is used to manage the transition between different animations to achieve a smooth animation switching effect. For example, in a role-playing game, the transition between the character's standby, walking, jumping and other actions can be smoothly processed.

[0069] In order to achieve efficient rendering management, this embodiment designs a rendering pipeline class, which is responsible for coordinating scene management and rendering state control. The rendering pipeline maintains the scene graph data structure through the scene management member to achieve the spatial organization and viewport clipping of objects. The rendering state member is responsible for managing the rendering parameter configuration, including the setting of rendering attributes such as depth testing and blending mode.

[0070] This embodiment innovatively implements the animation control class, and prioritizes rendering instructions through rendering queue members. This design allows transparent objects to be correctly rendered after opaque objects, ensuring the visual effect of the picture. The animation clock member achieves smooth animation transitions through interpolation calculations to avoid animation freezes at different frame rates.

[0071] In terms of rendering optimization, this embodiment implements the frustum culling and occlusion culling technology. By quickly determining whether a game object is within the frustum or is occluded by other objects, unnecessary rendering calculations are reduced. This is particularly effective in rendering complex scenes and can significantly improve rendering efficiency.

[0072] This embodiment also designs a material system to support a combination of multiple rendering effects. Through the dynamic adjustment of material parameters, visual effects such as lighting, shadows, and special effects can be achieved. For example, when rendering a character, the material properties can be dynamically changed to achieve visual feedback such as injury flashing and skill special effects.

[0073] In order to support dynamic scene changes, this embodiment implements a dynamic update mechanism for the scene graph. When a game object moves, rotates, or scales, the scene graph automatically updates the object's transformation matrix to ensure the accuracy of the rendered position. This is especially important when dealing with scenes with a large number of moving objects.

[0074] The rendering implementation layer of this embodiment significantly improves the rendering efficiency of the game screen through reasonable interface design and optimization strategy. The unified rendering interface simplifies the game development process, allowing developers to focus on the implementation of the gameplay. At the same time, the rendering optimization mechanism ensures that the screen performance can still be smooth in complex scenes.

[0075] In practical applications, the rendering implementation layer of this embodiment can adapt to the needs of different types of mini-games. Whether it is a 2D horizontal version game, a card game or a simple casual game, the ideal visual effect can be obtained by configuring the corresponding rendering parameters. The flexible interface design also provides convenience for subsequent function expansion, and the new rendering features can be easily integrated into the existing framework.

[0076] Step S103: at the language binding layer, the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine are stored in the pointer of the state object; the state object generates a parameter parser to convert the script parameters into native data types; the parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro; the attribute callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner; the game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources; the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to execute the graphics rendering work of the mini-game.

[0077] Optionally, this embodiment implements deep integration of the game script engine and the native rendering interface at the language binding layer, and ensures the stability of script execution and the efficiency of resource management through a carefully designed state management and memory control mechanism.

[0078] This embodiment first constructs a state object management mechanism, which stores the key runtime information of the game script engine in the state object during the initialization phase. Specifically, the virtual machine stack address is used to track the call chain of the script function, the virtual machine function table address is used to quickly locate the function defined in the script, and the exception handling address is used to capture and handle exceptions when the script is running. For example, when developing a game with multiple scene switching, the state object can ensure the continuity of the script context during the scene switching process.

[0079] The design of the parameter parser adopts the type mapping table method to dynamically convert the data types in the script language into native data types. This embodiment handles the conversion of basic types such as integers and floating-point numbers by establishing a type conversion rule set, and supports recursive conversion of complex types such as arrays and objects. For example, when processing game configuration data, the script configuration in JSON format can be directly converted into a native data structure.

[0080] This embodiment innovatively designs a property callback packaging macro system, which implements a two-way calling mechanism from script functions to native functions through function pointer packaging. In the process of callback function packaging, the function signature template is used to automatically generate packaging code, which ensures type safety and simplifies development work. For example, when implementing a game controller, player input events can be easily passed to the script layer for processing.

[0081] In terms of object lifecycle management, this embodiment adopts a weak reference storage strategy. By establishing a mapping table from native pointers to game objects, game objects are stored in a weak reference manner to avoid memory leaks caused by circular references. When a script object is no longer referenced, the termination callback function is automatically triggered to perform resource recycling operations. For example, when processing a large number of dynamically created game entities, timely release of memory can be guaranteed.

[0082] This embodiment implements an intelligent garbage collection mechanism, which automatically processes unused resources through the termination callback function. The recycling process includes operations such as releasing native memory, cleaning up rendering resources, and unblocking event monitoring. This mechanism is particularly suitable for processing temporary game objects, such as particle effects, temporary special effects, etc.

[0083] In the implementation of the rendering component, this embodiment calls the interface of the rendering implementation layer through the language binding layer to build a lightweight canvas rendering component. The component adopts the command buffer design pattern to cache rendering instructions before submitting them in batches, reducing the communication overhead between the script layer and the native layer. For example, when drawing a large number of sprites, multiple drawing operations can be merged and submitted at once.

[0084] This embodiment designs an efficient event distribution mechanism, and manages the triggering order of script callbacks through event queues. During event processing, event filters are used to avoid repeated calls, and event priority management is implemented. This is particularly useful when dealing with complex game interaction logic.

[0085] To improve performance, this embodiment implements object pooling technology to reduce the overhead of dynamic memory allocation by pre-allocating and reusing objects. The object pool manager maintains a cache pool of different types of objects and quickly provides available objects when needed. This is especially important for game elements that are frequently created and destroyed.

[0086] This embodiment also implements an asynchronous resource loading mechanism, and manages the loading process of game resources through a resource loading queue. The loader component can schedule loading tasks according to priority, ensure on-demand loading of game resources, and improve game startup speed and runtime performance.

[0087] In practical applications, the language binding layer design of this embodiment significantly improves the development efficiency and running performance of the mini-game. Through reasonable memory management and resource recycling mechanism, the stability of the game during long-term operation is ensured. The flexible script binding mechanism also facilitates the rapid iteration of game logic, and developers can focus on the implementation of the gameplay without paying too much attention to the underlying details.

[0088] As can be seen from the above description, the general graphics rendering method for mini-games based on a layered architecture provided in the embodiment of the present application can realize the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulate the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing, and animation update are provided in the rendering implementation layer to realize real-time rendering functions. The language binding layer is innovatively designed to realize efficient conversion between the script engine and native code through state objects and parameter parsers, and a weak reference mechanism and termination callback are used to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform general rendering solution for mini-game development.

[0089] In one embodiment of the mini-game universal graphics rendering method based on the layered architecture of the present application, see Figure 2 , and can also include the following:

[0090] Step S201: defining a window abstract interface class using an underlying programming language, wherein the window abstract interface class includes a window identifier member and a window status information member, calling a window handle registration interface of an operating system platform based on the window identifier member to generate an application main window identifier, calling a system message loop interface based on the window status information member to parse window event data, and mapping an application programming interface provided by the operating system platform to a corresponding data structure;

[0091] Step S202: A canvas rendering interface is defined in the window abstract interface class, wherein the canvas rendering interface includes a drawing surface member and a rendering context member, a graphics device interface is called based on the drawing surface member to construct drawable surface data of the window client area, and a graphics library interface is called based on the rendering context member to configure drawing attribute parameters, and the canvas rendering interface writes image data by exchanging the front and back buffers.

[0092] Optionally, this embodiment uses an underlying programming language to implement a cross-platform window abstraction layer, and implements encapsulation and management of window systems on different operating system platforms through unified interface definition and data structure mapping.

[0093] This embodiment first designs a window abstract interface class, which serves as a bridge for the application to interact with the operating system window system. The window identifier member stores the unique identifier of the window, through which a specific window can be accurately located and operated. For example, in a multi-window game application, the main game window and the setting window can be distinguished by the window identifier to achieve coordinated management between windows.

[0094] The window status information member is responsible for maintaining the dynamic state of the window, including key information such as the window's position, size, and focus state. This embodiment continuously monitors and processes window events through the system message loop interface to ensure that it can respond to user interactions in a timely manner. For example, when a player adjusts the size of the game window, the window status information member will immediately update the relevant parameters and trigger appropriate redraw operations.

[0095] In terms of interface mapping, this embodiment adopts the adapter mode to convert the native interfaces of different operating system platforms into a unified data structure. This design allows the upper application code to use a consistent interface for window operations without having to worry about the differences in the underlying platforms. For example, the HWND of the Windows platform and the Window identifier of the Linux platform are both mapped to a unified window identifier format.

[0096] This embodiment innovatively designs a canvas rendering interface, providing complete drawing functions through drawing surface members and rendering context members. The drawing surface member is responsible for managing the drawable area of ​​the window client area, and creates and maintains the drawing buffer by calling the underlying graphics device interface. This design ensures that the rendering operation is always performed within the valid drawing area.

[0097] The rendering context member carries the configuration information of the drawing state, including drawing attributes such as color, line type, and fill mode. This embodiment dynamically adjusts these parameters through the graphics library interface to achieve flexible drawing effects. For example, when drawing UI elements of different styles in the game, you can quickly switch the drawing style by modifying the parameters of the rendering context.

[0098] This embodiment uses double buffer technology to achieve smooth rendering of the picture. By alternating the front and back buffers, the picture tearing and flickering are avoided. During the drawing process, the new image data is first written to the back buffer, and then exchanged with the front buffer after completion to ensure that the displayed picture is always complete.

[0099] In order to improve rendering performance, this embodiment implements an intelligent buffer management mechanism. By analyzing changes in rendering content, only the changed areas can be selectively updated to reduce unnecessary rendering overhead. For example, in a game scene with a static background, only the area of ​​dynamic elements needs to be redrawn.

[0100] This embodiment also designs an event distribution mechanism to process window events in an orderly manner through a message queue. The event processor calls the corresponding processing function according to the event type to ensure that the window system can correctly respond to the user's input. For example, events such as mouse clicks and keyboard keys can be accurately passed to the corresponding processing logic.

[0101] In terms of resource management, this embodiment implements lifecycle management of rendering resources. By tracking the usage status of the drawing surface and rendering context, it ensures that the relevant resources are correctly released when the window is closed or rebuilt, thereby avoiding resource leakage.

[0102] The window abstraction layer of this embodiment significantly improves the efficiency of cross-platform game development through reasonable interface design and optimization strategy. The unified interface definition simplifies the development process, allowing developers to focus on the implementation of game functions. At the same time, the optimized rendering mechanism ensures the smooth display of the game screen.

[0103] In practical applications, the window abstraction layer of this embodiment can adapt to different types of game requirements. Whether it is a full-screen game or a window mode, the ideal display effect can be obtained by configuring the corresponding window parameters. The flexible interface design also provides convenience for subsequent function expansion, and new window features can be easily integrated into the existing framework.

[0104] In one embodiment of the mini-game universal graphics rendering method based on the layered architecture of the present application, see Figure 3 , and can also include the following:

[0105] Step S301: defining a window processing class in the game canvas operation interface, wherein the window processing class includes a window procedure member and a message dispatching member, calling a window identifier based on the window procedure member to parse an application window message, calling a message queue interface based on the message dispatching member to allocate window event data, and the window processing class converts the window event of the operating system platform into standardized game event data;

[0106] Step S302: setting a screen refresh class in the window processing class, wherein the screen refresh class includes a vertical synchronization member and a rendering command member, calling a display refresh rate interface based on the vertical synchronization member to calculate a frame interval, calling a graphics library interface based on the rendering command member to execute a drawing instruction sequence, and triggering a buffer exchange operation according to a synchronization signal.

[0107] Optionally, this embodiment implements a complete set of game window event processing and screen refresh mechanisms, and achieves efficient game interaction and smooth screen rendering through carefully designed window processing classes and screen refresh classes.

[0108] This embodiment first constructs a window processing class in the game canvas operation interface, which receives and processes raw window messages from the operating system through a window procedure member. The window procedure member uses an event filter mode to classify and preprocess the received window messages. For example, when a player adjusts the size of the game window, the window procedure member captures the corresponding window size change message and converts it into a standardized game event format.

[0109] The message distribution member adopts the observer mode design and maintains an orderly event processing queue through the message queue interface. This embodiment implements a priority message queue to ensure that key events (such as input events) can be processed first. For example, when processing intensive game operations, the player's input events will be distributed first to ensure the responsiveness of the game.

[0110] In terms of event standardization, this embodiment designs an event converter to convert native window events of different platforms into a standard game event data structure. This design allows the game logic layer to use a unified event processing interface without having to worry about the differences in the underlying platforms. For example, the coordinate systems of mouse click events on different platforms may be different, and can be unified into game world coordinates through the event converter.

[0111] The screen refresh class of this embodiment implements an advanced vertical synchronization mechanism. The vertical synchronization member calculates the optimal frame interval by querying the refresh rate parameters of the display. This method can effectively avoid screen tearing and ensure the smoothness of game operation. For example, on a display with a refresh rate of 60Hz, the system will automatically adjust the rendering interval to synchronize it with the refresh cycle of the display.

[0112] The rendering command member adopts the command mode design, encapsulates the drawing operation into a command object and executes it in sequence. This embodiment implements a command batch processing mechanism, which can merge and execute multiple similar drawing operations to reduce the number of graphics API calls. For example, when drawing a large number of similar game sprites, all drawing commands can be submitted at once through the batch processing mechanism.

[0113] This embodiment innovatively designs an adaptive frame rate control mechanism. By monitoring the actual rendering performance and system load, the game update frequency is dynamically adjusted. When the system load is high, the update frequency of non-critical parts can be appropriately reduced to ensure the smoothness of the core gameplay.

[0114] In terms of buffer management, this embodiment implements an intelligent buffer exchange strategy. The exchange timing of the buffer is controlled by a synchronization signal to ensure that the screen update is synchronized with the display refresh. This design not only avoids screen tearing, but also optimizes the utilization efficiency of GPU resources.

[0115] This embodiment also implements a rendering state cache mechanism, which reduces the overhead of state switching by tracking and reusing the same rendering state. For example, when drawing game objects using the same material, the rendering state can be kept unchanged, thereby improving rendering efficiency.

[0116] In order to handle window size changes, this embodiment designs an adaptive rendering mechanism. When the window size changes, the system automatically adjusts the resolution of the rendering target and recalculates the layout of UI elements to ensure that the game screen always maintains the correct display ratio.

[0117] The implementation of this embodiment significantly improves the stability and fluency of the game operation. Through a reasonable event processing mechanism, it is ensured that the game can accurately respond to the player's operation. The optimized rendering process ensures the smoothness and synchronization of the screen update.

[0118] In practical applications, the design of this embodiment solves the window processing and screen synchronization problems in cross-platform game development. The unified event processing interface simplifies the implementation of game logic, and the optimized rendering mechanism ensures high-quality display of game screens. The flexible design architecture also facilitates subsequent function expansion, and new event types and rendering features can be easily integrated into the existing framework.

[0119] In one embodiment of the mini-game universal graphics rendering method based on the layered architecture of the present application, see Figure 4 , and can also include the following:

[0120] Step S401: defining a rendering pipeline class in a rendering implementation layer, wherein the rendering pipeline class includes a scene management member and a rendering state member, calling a game canvas operation interface based on the scene management member to construct a scene graph data structure, calling a graphics context interface based on the rendering state member to set a rendering parameter configuration, and the rendering pipeline class organizes game object data into rendering batch data;

[0121] Step S402: An animation control class is set in the rendering pipeline class, wherein the animation control class includes rendering queue members and animation clock members, a drawing instruction interface is called based on the rendering queue members to sort the rendering instruction set, and a timestamp interface is called based on the animation clock members to calculate animation interpolation parameters, and the animation control class allocates drawing resources according to rendering priority.

[0122] Optionally, this embodiment implements an efficient game rendering pipeline and animation control system, and achieves efficient rendering of game scenes and smooth animation effects through carefully designed data structures and algorithms.

[0123] This embodiment constructs a rendering pipeline class in the rendering implementation layer, which maintains a complete scene data structure through a scene management member. The scene management member uses the octree space partitioning technology to divide the three-dimensional scene space into a number of subspace nodes, thereby achieving efficient scene object management. For example, in a large open world game, the scene objects that need to be rendered can be quickly determined based on the player's perspective position.

[0124] The rendering state member adopts the state machine design pattern and dynamically manages the rendering state through the graphics context interface. This embodiment implements a rendering state cache mechanism, which minimizes state switching operations by comparing the difference between the current state and the target state. For example, when rendering game objects using the same material, the rendering state can be kept unchanged, reducing the state switching overhead.

[0125] This embodiment innovatively designs a rendering batch optimization algorithm. By analyzing the material, texture, and rendering properties of game objects, objects with similar rendering characteristics are organized into the same rendering batch. This approach significantly reduces the number of rendering state switches and drawing calls. For example, when rendering a large amount of grass or trees, vegetation models using the same material can be merged into one rendering batch.

[0126] The animation control class implements complex animation system management. The rendering queue members use a priority queue data structure to sort rendering instructions according to the properties of the rendering object (such as transparency, depth value, etc.). This ensures the correctness of the rendering order, which is especially important when dealing with translucent objects.

[0127] The animation clock member implements a precise time control mechanism. The interpolation parameters between animation frames are calculated through a high-precision timestamp interface to achieve a smooth animation transition effect. This embodiment supports multiple interpolation methods, including linear interpolation, Bezier curve interpolation, etc., and the appropriate interpolation algorithm can be selected according to different animation requirements.

[0128] In terms of rendering resource management, this embodiment implements an intelligent resource allocation strategy. By analyzing scene complexity and system performance, the rendering accuracy and level of detail are dynamically adjusted. For example, when the load is high, the rendering accuracy of distant objects can be reduced to ensure the smoothness of the main game scene.

[0129] This embodiment designs a scene culling system, which quickly screens out visible scene objects through technologies such as frustum culling and occlusion culling. This optimization significantly reduces unnecessary rendering calculations and improves rendering efficiency. For example, in indoor scenes, view culling can be performed through doors and windows, and only objects in the player's visible area can be rendered.

[0130] In order to process dynamic objects, this embodiment implements a dynamic batch merging mechanism. By analyzing the motion characteristics of objects, objects with similar motion patterns are organized into the same dynamic batch, reducing the rendering overhead of dynamic objects. For example, in a particle special effects system, similar particle effects can be merged for rendering.

[0131] This embodiment also implements an asynchronous processing mechanism for the rendering pipeline. By separating scene updates and rendering calculations into different processing threads, the parallel processing capability of the system is improved. This design is particularly suitable for modern multi-core processor architectures and can better utilize hardware resources.

[0132] In terms of animation synchronization, this embodiment designs a frame synchronization mechanism. Through unified animation clock control, all animation effects in the game are ensured to be updated synchronously to avoid the problem of inconsistent animation speed. For example, in a multiplayer online game, frame synchronization can be used to ensure that all players see the same animation effect.

[0133] The implementation of this embodiment significantly improves the performance and visual effects of game rendering. Through the optimized rendering pipeline and animation control system, the smoothness and consistency of the game screen are ensured. Intelligent resource management and optimization strategies ensure the stable operation of the system on various hardware platforms.

[0134] In practical applications, the design of this embodiment solves the rendering optimization problem of large game scenes. The perfect scene management and rendering optimization mechanism ensure the high-quality presentation of the game screen, and the flexible animation control system provides rich visual effects for the game. The combination of these technologies provides powerful graphics rendering support for game development.

[0135] In one embodiment of the mini-game universal graphics rendering method based on the layered architecture of the present application, see Figure 5 , and can also include the following:

[0136] Step S501: defining a state object class at the language binding layer, the state object class including a virtual machine stack pointer member and a function table pointer member, mapping a stack space allocation address of a script engine based on the virtual machine stack pointer member, mapping a function symbol address of the script engine based on the function table pointer member, and the state object class writing virtual machine memory layout data into a pointer array;

[0137] Step S502: An exception handling class is set in the state object class, wherein the exception handling class includes an exception table pointer member and a call stack pointer member, and an exception vector address of the script engine is mapped based on the exception table pointer member, and stack frame data of the script engine is mapped based on the call stack pointer member. The exception handling class writes the exception handling routine address into a jump table.

[0138] Optionally, this embodiment implements a complete set of script engine memory management and exception handling mechanisms, and implements an efficient script execution environment and a stable error handling mechanism through carefully designed state object classes and exception handling classes.

[0139] This embodiment first constructs a state object class at the language binding layer, which manages the memory allocation during script runtime through the virtual machine stack pointer member. The virtual machine stack pointer adopts a segmented memory management strategy to divide the stack space into multiple fixed-size segments, thereby achieving efficient memory allocation and recycling. For example, when processing recursive function calls, the stack space can be dynamically expanded to avoid stack overflow problems.

[0140] The function table pointer member uses a hash table data structure to achieve fast function symbol lookup. This embodiment uses a double-layer hash table design, with the first layer storing module names and the second layer storing function names, which significantly improves the efficiency of function calls. For example, when AI behavior functions are frequently called in a game script, the corresponding function implementation can be quickly located.

[0141] In terms of memory layout management, this embodiment innovatively designs a memory mapping mechanism. By establishing a mapping table from virtual addresses to physical addresses, efficient data exchange between script space and local space is achieved. The pointer array adopts a compact storage structure, which reduces memory fragmentation and improves memory utilization.

[0142] The exception handling class of this embodiment implements a complete exception capture and processing process. The exception table pointer member maintains an exception type mapping table, which associates different types of exceptions with corresponding processing functions. This design allows the game script to gracefully handle various runtime errors and improves the stability of the game.

[0143] The call stack pointer member implements the stack frame tracking mechanism. By recording the context information of the function call, including local variables, parameter values, and return addresses, a complete call chain tracking is achieved. For example, when an exception occurs in the game script, the location where the error occurred and the call path can be accurately located.

[0144] This embodiment designs an intelligent stack memory management strategy. By analyzing the function call characteristics, the stack space requirements are predicted and the appropriate amount of stack memory is allocated in advance. This method reduces the number of runtime stack expansions and improves script execution efficiency. For example, when dealing with complex game AI decisions, the required stack space can be estimated based on the depth of the decision tree.

[0145] In order to handle concurrently executed scripts, this embodiment implements a thread-safe state management mechanism. Through thread local storage technology, an independent state object is maintained for each script execution thread, avoiding resource competition problems. This is particularly important for multi-player online games, ensuring that scripts of different players do not interfere with each other.

[0146] This embodiment also implements an exception recovery mechanism. When an exception occurs in the script, the exception handling class can save the current execution state, perform cleanup operations, and try to recover to a safe state. This mechanism greatly improves the fault tolerance of the game and avoids the entire game crashing due to local errors.

[0147] In terms of performance optimization, this embodiment designs a function call cache mechanism. By caching the addresses of recently called functions, the symbol lookup overhead is reduced. This is particularly effective for frequently called function modules in games, such as physical calculations, AI decisions, etc.

[0148] The jump table design of this embodiment adopts a direct indexing method to avoid the conditional judgment overhead in traditional exception handling. By establishing a direct mapping from exception type to processing function, fast exception distribution is achieved. For example, when handling common exceptions such as network timeout and resource loading failure, the corresponding processing logic can be quickly executed.

[0149] The implementation of this embodiment significantly improves the performance and stability of the game script system. Through optimized memory management and exception handling mechanisms, the efficiency and reliability of script execution are ensured. The perfect error handling mechanism provides good debugging and maintenance capabilities.

[0150] In practical applications, the design of this embodiment solves the memory management and error handling problems of the game script system. The efficient function call mechanism and stable exception handling process provide a reliable script execution environment for game development. The comprehensive application of these technologies significantly improves the development efficiency and operation stability of the game.

[0151] In one embodiment of the mini-game universal graphics rendering method based on the layered architecture of the present application, see Figure 6 , and can also include the following:

[0152] Step S601: defining a parameter parser class in a state object, wherein the parameter parser class includes a type conversion member and a reference count member, reading parameter stack data of the script engine based on the type conversion member, recording the life cycle of an object reference based on the reference count member, and writing the script parameter value into a native type variable;

[0153] Step S602: a callback mapping class is set in the parameter parser class, the callback mapping class includes a function wrapper member and an object mapping member, a script interface declaration of a callback function is generated based on the function wrapper member, a hash table structure of pointers to objects is established based on the object mapping member, and the callback mapping class uses a weak reference counter to record object data.

[0154] Optionally, this embodiment implements an efficient script engine binding system, and achieves seamless data interaction and memory management between the script layer and the native layer through the design of the state object class and the parameter parser class.

[0155] This embodiment first constructs a state object class at the language binding layer, and implements precise memory management through a virtual machine stack pointer member. This member uses memory mapping technology to directly map the stack space of the script engine, avoiding frequent memory copy operations. For example, when a script function calls a native method, it can directly access parameter data through the stack pointer, improving data access efficiency.

[0156] The function table pointer member implements an efficient function symbol resolution mechanism. This embodiment uses the symbol table cache technology to store the symbol addresses of commonly used functions in a fast-access cache to reduce symbol search overhead. By establishing a mapping relationship between function names and memory addresses, fast function call jumps are achieved.

[0157] The exception handling class adopts an innovative exception handling mechanism. The exception table pointer member maintains a complete exception vector table, which records the addresses of handlers for different types of exceptions. When an exception occurs during script execution, the corresponding handling routine can be quickly located to ensure stable operation of the program.

[0158] The call stack pointer member of this embodiment realizes accurate tracking of the stack frame. By recording the stack frame information of each function call, including data such as local variables, parameters and return addresses, a complete call chain tracking is realized. This is crucial for exception handling and debugging functions.

[0159] The type conversion member in the parameter parser class implements an intelligent type system. This embodiment supports complex type conversion rules and can automatically process the conversion between script types and native types. For example, when processing complex data types such as strings and arrays, deep copying and type adaptation can be automatically completed.

[0160] The reference counting member uses a generational reference counting algorithm to achieve precise memory management by recording the creation time and reference relationship of the object. This design is particularly suitable for handling complex scenarios such as circular references and effectively preventing memory leaks.

[0161] The callback mapping class of this embodiment innovatively implements a function packaging mechanism. The function packaging member can automatically generate a script interface declaration, so that the native function can be easily called by the script layer. At the same time, through intelligent parameter adaptation, the parameter transfer differences between different languages ​​are handled.

[0162] The object mapping member adopts a hash table structure to achieve efficient object search and mapping. This embodiment uses an open addressing method to resolve hash conflicts and implements a dynamic expansion mechanism to ensure search efficiency. By maintaining a bidirectional mapping from object to pointer, the uniqueness of the object identifier is ensured.

[0163] This embodiment implements an intelligent weak reference counting mechanism. By distinguishing between strong references and weak references, the memory leak problem caused by circular references is avoided. The weak reference counter will not prevent the object from being garbage collected, but it can track the usage status of the object.

[0164] In terms of exception handling, this embodiment designs an exception recovery mechanism. When an exception occurs, the system can automatically roll back to a safe state and release related resources to ensure the stability of the program. For example, when an exception occurs during a file operation, the file handle can be closed correctly.

[0165] This embodiment also implements a context management mechanism. By maintaining thread local storage, the isolation of script states in a multi-threaded environment is ensured. This is crucial for implementing thread-safe script calls.

[0166] In order to optimize performance, this embodiment implements a parameter pool mechanism. By pre-allocating and reusing parameter objects, the overhead of dynamic memory allocation is reduced. This is particularly effective when processing high-frequency function calls.

[0167] The design of this embodiment significantly improves the performance and reliability of the script engine. The script execution overhead is reduced through optimized memory management and function call mechanism. The perfect exception handling and memory tracking mechanism ensures the stable operation of the program.

[0168] In practical applications, this embodiment solves the performance and stability problems in the game script system. The optimized memory management and function call mechanism enable efficient execution of the game logic script, while the perfect exception handling ensures the stable operation of the game. The combination of these technologies provides powerful script support capabilities for game development.

[0169] In one embodiment of the mini-game universal graphics rendering method based on the layered architecture of the present application, see Figure 7 , and can also include the following:

[0170] Step S701: defining a resource recovery class at the language binding layer, wherein the resource recovery class includes a termination callback member and a reference cleanup member, executing a destruction operation of a script object based on the termination callback member, releasing the memory space of an object mapping table based on the reference cleanup member, and the resource recovery class resets a weak reference counter to zero;

[0171] Step S702: Setting a rendering component class in the resource recycling class, wherein the rendering component class includes a rendering proxy member and a drawing command member, calling a rendering interface to register a rendering callback function based on the rendering proxy member, and calling a rendering interface to execute a drawing operation sequence based on the drawing command member, wherein the rendering component class drives screen updates according to game logic.

[0172] Optionally, this embodiment implements a complete game script resource management and rendering system, and achieves efficient memory management and smooth game screen rendering through carefully designed resource recycling classes and rendering component classes.

[0173] This embodiment first constructs a resource recycling class at the language binding layer, and implements intelligent object lifecycle management through the termination callback member. When the script object is no longer referenced, the termination callback member will automatically trigger the destruction operation to ensure that the resources are released in time. For example, when the game scene is switched, the texture resources and model data that are no longer used can be automatically cleaned up.

[0174] The reference cleanup member adopts a hierarchical cleanup strategy to release resources in order according to the dependencies between objects. This embodiment ensures the correct order of resource release by building an object dependency graph, avoiding the dangling pointer problem. This is particularly important when dealing with complex game scenes, such as when releasing a scene graph with child nodes.

[0175] This embodiment innovatively designs a memory management mechanism for the object mapping table. By implementing the memory pool technology, small blocks of memory that are frequently allocated and released are optimized and managed. This design significantly reduces memory fragmentation and improves memory utilization efficiency. For example, when processing a large number of game entity objects, memory allocation and recycling can be completed quickly.

[0176] The design of the weak reference counter uses atomic operations to ensure the accuracy of counting in a multi-threaded environment. When the counter returns to zero, the resource recovery process is triggered, including operations such as removing references between objects and releasing memory space. This mechanism effectively prevents memory leaks.

[0177] The rendering component class of this embodiment implements an efficient rendering management mechanism. The rendering proxy member establishes a bridge between the script logic and the rendering system by registering a callback function. This design allows the game logic to easily control the rendering process and achieve complex visual effects.

[0178] The drawing command member adopts the command queue design mode to serialize and store rendering operations. This embodiment implements a command batch processing mechanism to reduce the overhead of rendering state switching by merging similar rendering instructions. For example, when rendering multiple models with the same material, rendering commands can be submitted at one time.

[0179] The rendering update mechanism of this embodiment is closely integrated with the game logic. By establishing a frame synchronization mechanism, the timing consistency of the rendering operation and the game logic is ensured. This design avoids screen tearing and freezing problems and provides a smooth gaming experience.

[0180] In order to optimize rendering performance, this embodiment implements a dynamic batch processing mechanism. By analyzing the spatial relationship and rendering status of objects in the scene, the mergeable rendering operations are automatically packaged for processing. This significantly reduces the number of rendering calls and improves rendering efficiency.

[0181] This embodiment also designs an intelligent resource preloading mechanism. By analyzing the structure and switching logic of the game scene, the resources to be used are loaded in advance. This mechanism effectively reduces the loading delay when the scene switches, providing a smooth gaming experience.

[0182] In terms of rendering optimization, this embodiment implements the frustum culling and occlusion culling techniques. By quickly determining whether an object is within the field of view or is blocked by other objects, unnecessary rendering calculations are reduced. This is particularly important for optimizing rendering performance in complex scenes.

[0183] The rendering component class of this embodiment supports seamless switching of multiple rendering technologies. Through the abstract rendering interface, the appropriate rendering scheme can be dynamically selected according to the hardware capabilities and performance requirements. This flexibility enables the game to adapt to different hardware platforms.

[0184] The implementation of this embodiment significantly improves the running efficiency and picture quality of the game. The optimized resource management mechanism ensures the memory stability during the game running. The efficient rendering system provides smooth picture performance.

[0185] In practical applications, this embodiment solves the resource management and rendering performance problems in game development. The optimized memory management mechanism ensures the stable operation of the game, while the efficient rendering system provides an excellent visual experience. The comprehensive application of these technologies significantly improves the overall quality of the game.

[0186] In order to provide a lightweight, cross-platform universal rendering solution for mini-game development, the present application provides an embodiment of a mini-game universal graphics rendering device based on a layered architecture for implementing all or part of the contents of the mini-game universal graphics rendering method based on a layered architecture, see Figure 8 The mini-game universal graphics rendering device based on the layered architecture specifically includes the following contents:

[0187] The abstract module 10 is used to realize the interaction between the operating system platform and the game engine through the window abstraction layer, and encapsulate the window creation instruction, the game event monitoring instruction and the image drawing instruction into a game canvas operation interface. The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input event of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen;

[0188] A rendering module 20, which is used to call the game canvas operation interface provided by the window abstraction layer in the rendering implementation layer to implement a rendering interface, wherein the rendering interface includes an initialization interface for a game scene, a drawing interface for a game object, and an update interface for a game animation, and the rendering interface performs real-time rendering of the game screen;

[0189] The binding module 30 is used to store the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine in the pointer of the state object at the language binding layer. The state object generates a parameter parser to convert the script parameters into native data types. The parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro. The attribute callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner. The game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources. The language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to perform the graphics rendering work of the mini-game.

[0190] As can be seen from the above description, the universal graphics rendering device for mini-games based on a layered architecture provided in the embodiment of the present application can realize the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulate the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing, and animation update are provided in the rendering implementation layer to realize real-time rendering functions. The language binding layer is innovatively designed to realize efficient conversion between the script engine and native code through state objects and parameter parsers, and a weak reference mechanism and termination callback are used to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform universal rendering solution for mini-game development.

[0191] From the hardware level, in order to provide a lightweight, cross-platform universal rendering solution for mini-game development, the present application provides an embodiment of an electronic device for implementing all or part of the contents of the mini-game universal graphics rendering method based on a layered architecture, and the electronic device specifically includes the following contents:

[0192] Processor, memory, communication interface and bus; wherein the processor, memory and communication interface communicate with each other through the bus; the communication interface is used to realize information transmission between the mini-game universal graphics rendering device based on the layered architecture and the core business system, user terminal and related database and other related devices; the logic controller can be a desktop computer, a tablet computer and a mobile terminal, etc., but the present embodiment is not limited thereto. In the present embodiment, the logic controller can be implemented with reference to the embodiment of the mini-game universal graphics rendering method based on the layered architecture and the embodiment of the mini-game universal graphics rendering device based on the layered architecture in the embodiment, and the contents thereof are incorporated herein, and the repeated parts are not repeated.

[0193] It is understandable that the user terminal may include a smart phone, a tablet electronic device, a network set-top box, a portable computer, a desktop computer, a personal digital assistant (PDA), a vehicle-mounted device, a smart wearable device, etc. Among them, the smart wearable device may include smart glasses, a smart watch, a smart bracelet, etc.

[0194] In practical applications, part of the general graphics rendering method for mini-games based on the layered architecture can be executed on the electronic device side as described above, or all operations can be completed in the client device. The selection can be made based on the processing capability of the client device and the limitations of the user's usage scenario. This application does not limit this. If all operations are completed in the client device, the client device may also include a processor.

[0195] The client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and other implementation scenarios may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, or a server cluster consisting of multiple servers, or a server structure of a distributed device.

[0196] Fig. 9 FIG. 9 is a schematic block diagram of the system structure of the electronic device 9600 according to an embodiment of the present application. Fig. 9 As shown, the electronic device 9600 may include a central processor 9100 and a memory 9140; the memory 9140 is coupled to the central processor 9100. It is worth noting that Fig. 9 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.

[0197] In one embodiment, the function of the mini-game universal graphics rendering method based on the layered architecture can be integrated into the central processing unit 9100. The central processing unit 9100 can be configured to perform the following control:

[0198] Step S101: The interaction between the operating system platform and the game engine is realized through the window abstraction layer, and the window creation instruction, the game event monitoring instruction and the image drawing instruction are encapsulated into a game canvas operation interface. The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen;

[0199] Step S102: calling the game canvas operation interface provided by the window abstraction layer in the rendering implementation layer to implement the rendering interface, wherein the rendering interface includes a game scene initialization interface, a game object drawing interface, and a game animation update interface, and the rendering interface performs real-time rendering of the game screen;

[0200] Step S103: at the language binding layer, the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine are stored in the pointer of the state object; the state object generates a parameter parser to convert the script parameters into native data types; the parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro; the attribute callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner; the game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources; the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to execute the graphics rendering work of the mini-game.

[0201] As can be seen from the above description, the electronic device provided by the embodiment of the present application realizes the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulates the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing and animation update are provided in the rendering implementation layer to realize real-time rendering function. The language binding layer is innovatively designed to realize efficient conversion between the script engine and the native code through state objects and parameter parsers, and a weak reference mechanism and termination callback are used to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform universal rendering solution for mini-game development.

[0202] In another embodiment, the mini-game universal graphics rendering device based on the layered architecture can be configured separately from the central processing unit 9100. For example, the mini-game universal graphics rendering device based on the layered architecture can be configured as a chip connected to the central processing unit 9100, and the function of the mini-game universal graphics rendering method based on the layered architecture can be implemented through the control of the central processing unit.

[0203] like Fig. 9 As shown, the electronic device 9600 may also include: a communication module 9110, an input unit 9120, an audio processor 9130, a display 9160, and a power supply 9170. It is worth noting that the electronic device 9600 does not necessarily have to include Fig. 9 In addition, the electronic device 9600 may also include Fig. 9 For components not shown, reference may be made to the prior art.

[0204] like Fig. 9 As shown, the central processing unit 9100 is sometimes also referred to as a controller or an operation control, and may include a microprocessor or other processor device and / or logic device. The central processing unit 9100 receives input and controls the operation of various components of the electronic device 9600.

[0205] The memory 9140 may be, for example, one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The above-mentioned information related to the failure may be stored, and a program for executing the relevant information may also be stored. The CPU 9100 may execute the program stored in the memory 9140 to implement information storage or processing, etc.

[0206] The input unit 9120 provides input to the central processing unit 9100. The input unit 9120 is, for example, a key or a touch input device. The power supply 9170 is used to provide power to the electronic device 9600. The display 9160 is used to display display objects such as images and texts. The display may be, for example, an LCD display, but is not limited thereto.

[0207] The memory 9140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 9140 may also be some other type of device. The memory 9140 includes a buffer memory 9141 (sometimes referred to as a buffer). The memory 9140 may include an application / function storage unit 9142, which is used to store application programs and function programs or processes for executing the operation of the electronic device 9600 through the central processor 9100.

[0208] The memory 9140 may also include a data storage unit 9143 for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit 9144 of the memory 9140 may include various drivers for communication functions of the electronic device and / or for executing other functions of the electronic device (such as messaging applications, address book applications, etc.).

[0209] The communication module 9110 is a transmitter / receiver that sends and receives signals via the antenna 9111. The communication module 9110 (transmitter / receiver) is coupled to the central processor 9100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.

[0210] Based on different communication technologies, multiple communication modules 9110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless LAN module. The communication module 9110 (transmitter / receiver) is also coupled to a speaker 9131 and a microphone 9132 via an audio processor 9130 to provide an audio output via the speaker 9131 and receive an audio input from the microphone 9132, thereby realizing a common telecommunication function. The audio processor 9130 may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor 9130 is also coupled to the central processor 9100, so that recording can be performed on the local machine through the microphone 9132, and the sound stored on the local machine can be played through the speaker 9131.

[0211] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps of the method for rendering a mini-game universal graphics based on a layered architecture in the above-mentioned embodiment, where the execution subject is a server or a client. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, all the steps of the method for rendering a mini-game universal graphics based on a layered architecture in the above-mentioned embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:

[0212] Step S101: The interaction between the operating system platform and the game engine is realized through the window abstraction layer, and the window creation instruction, the game event monitoring instruction and the image drawing instruction are encapsulated into a game canvas operation interface. The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen;

[0213] Step S102: calling the game canvas operation interface provided by the window abstraction layer in the rendering implementation layer to implement the rendering interface, wherein the rendering interface includes a game scene initialization interface, a game object drawing interface, and a game animation update interface, and the rendering interface performs real-time rendering of the game screen;

[0214] Step S103: at the language binding layer, the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine are stored in the pointer of the state object; the state object generates a parameter parser to convert the script parameters into native data types; the parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro; the attribute callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner; the game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources; the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to execute the graphics rendering work of the mini-game.

[0215] As can be seen from the above description, the computer-readable storage medium provided in the embodiment of the present application realizes the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulates the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing, and animation update are provided in the rendering implementation layer to realize real-time rendering functions. The language binding layer is innovatively designed to realize efficient conversion between the script engine and native code through state objects and parameter parsers, and a weak reference mechanism and termination callback are used to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform universal rendering solution for mini-game development.

[0216] The embodiments of the present application also provide a computer program product capable of implementing all the steps of the method for rendering a mini-game universal graphics based on a layered architecture in the above-mentioned embodiment, where the execution subject is a server or a client. When the computer program / instruction is executed by a processor, the steps of the method for rendering a mini-game universal graphics based on a layered architecture are implemented. For example, the computer program / instruction implements the following steps:

[0217] Step S101: The interaction between the operating system platform and the game engine is realized through the window abstraction layer, and the window creation instruction, the game event monitoring instruction and the image drawing instruction are encapsulated into a game canvas operation interface. The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen;

[0218] Step S102: calling the game canvas operation interface provided by the window abstraction layer in the rendering implementation layer to implement the rendering interface, wherein the rendering interface includes a game scene initialization interface, a game object drawing interface, and a game animation update interface, and the rendering interface performs real-time rendering of the game screen;

[0219] Step S103: at the language binding layer, the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine are stored in the pointer of the state object; the state object generates a parameter parser to convert the script parameters into native data types; the parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro; the attribute callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner; the game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources; the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to execute the graphics rendering work of the mini-game.

[0220] As can be seen from the above description, the computer program product provided by the embodiment of the present application realizes the decoupling of the operating system and the game engine through the window abstraction layer, and encapsulates the core operations into a unified game canvas interface. Standard interfaces such as scene initialization, object drawing and animation update are provided in the rendering implementation layer to realize real-time rendering function. The language binding layer is innovatively designed to realize efficient conversion between the script engine and the native code through state objects and parameter parsers, and a weak reference mechanism and termination callback are used to ensure automatic recycling of resources. This method breaks through the platform limitations of traditional rendering systems and provides a lightweight, cross-platform universal rendering solution for mini-game development.

[0221] It should be understood by those skilled in the art that embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0222] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (apparatus), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0223] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0224] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0225] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A general graphics rendering method for mini-games based on a layered architecture, characterized in that: The method comprises: The interaction between the operating system platform and the game engine is realized through the window abstraction layer, and the window creation instructions, game event monitoring instructions and image drawing instructions are encapsulated as the game canvas operation interface, which includes: A window abstract interface class is defined in an underlying programming language, the window abstract interface class includes a window identifier member and a window status information member, a window handle registration interface of an operating system platform is called based on the window identifier member to generate an application main window identifier, a system message loop interface is called based on the window status information member to parse window event data, and the window abstract interface class maps an application programming interface provided by the operating system platform to a corresponding data structure; a canvas rendering interface is defined in the window abstract interface class, the canvas rendering interface includes a drawing surface member and a rendering context member, a graphics device interface is called based on the drawing surface member to construct window client area drawable surface data, a graphics library interface is called based on the rendering context member to configure drawing attribute parameters, and the canvas rendering interface uses a front and back buffer exchange method to write image data; The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen; The rendering implementation layer calls the game canvas operation interface provided by the window abstraction layer to implement a rendering interface, wherein the rendering interface includes an initialization interface for a game scene, a drawing interface for a game object, and an update interface for a game animation, and the rendering interface performs real-time rendering of the game screen; In the language binding layer, the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine are stored in the pointer of the state object. The state object generates a parameter parser to convert the script parameters into native data types. The parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro. The attribute callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner. The game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources. The language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to perform graphics rendering work of the mini-game.

2. The method for rendering universal graphics for mini-games based on a layered architecture according to claim 1, characterized in that: The game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input events of the player. The game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen, including: A window processing class is defined in the game canvas operation interface. The window processing class includes a window procedure member and a message dispatching member. The window procedure member calls a window identifier to parse an application window message. The message dispatching member calls a message queue interface to allocate window event data. The window processing class converts the window event of the operating system platform into standardized game event data. A screen refresh class is set in the window processing class, and the screen refresh class includes a vertical synchronization member and a rendering command member. A display refresh rate interface is called based on the vertical synchronization member to calculate the frame interval time, and a graphics library interface is called based on the rendering command member to execute a drawing instruction sequence. The screen refresh class triggers a buffer exchange operation according to a synchronization signal.

3. The method for rendering universal graphics for mini-games based on a layered architecture according to claim 1, characterized in that: The rendering implementation layer calls the game canvas operation interface provided by the window abstraction layer to implement the rendering interface, the rendering interface includes an initialization interface of the game scene, a drawing interface of the game object and an update interface of the game animation, and the rendering interface performs real-time rendering of the game screen, including: A rendering pipeline class is defined in the rendering implementation layer. The rendering pipeline class includes a scene management member and a rendering state member. A game canvas operation interface is called based on the scene management member to build a scene graph data structure. A graphics context interface is called based on the rendering state member to set a rendering parameter configuration. The rendering pipeline class organizes game object data into rendering batch data. An animation control class is set in the rendering pipeline class, and the animation control class includes rendering queue members and animation clock members. A drawing instruction interface is called based on the rendering queue members to sort the rendering instruction set, and a timestamp interface is called based on the animation clock members to calculate animation interpolation parameters. The animation control class allocates drawing resources according to rendering priority.

4. The method for rendering universal graphics for mini-games based on a layered architecture according to claim 1, characterized in that: The method of storing the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine in the pointer of the state object at the language binding layer includes: A state object class is defined at the language binding layer, wherein the state object class includes a virtual machine stack pointer member and a function table pointer member, a stack space allocation address of a script engine is mapped based on the virtual machine stack pointer member, a function symbol address of the script engine is mapped based on the function table pointer member, and the state object class writes virtual machine memory layout data into a pointer array; An exception handling class is set in the state object class, and the exception handling class includes an exception table pointer member and a call stack pointer member. The exception vector address of the script engine is mapped based on the exception table pointer member, and the stack frame data of the script engine is mapped based on the call stack pointer member. The exception handling class writes the exception handling routine address into the jump table.

5. The method for rendering universal graphics for mini-games based on a layered architecture according to claim 1, characterized in that: The state object generates a parameter parser that converts script parameters into native data types. The parameter parser converts the callback function into the function definition of the game script engine through a property callback wrapper macro. The property callback wrapper macro establishes a mapping table from native pointers to game objects and stores the game objects in a weak reference manner, including: A parameter parser class is defined in the state object, wherein the parameter parser class includes a type conversion member and a reference count member, and the parameter stack data of the script engine is read based on the type conversion member, and the life cycle of the object reference is recorded based on the reference count member. The parameter parser class writes the script parameter value into the native type variable; A callback mapping class is set in the parameter parser class, the callback mapping class includes a function wrapper member and an object mapping member, a script interface declaration of the callback function is generated based on the function wrapper member, a hash table structure of pointers to objects is established based on the object mapping member, and the callback mapping class uses a weak reference counter to record object data.

6. The method for rendering universal graphics for mini-games based on a layered architecture according to claim 1, characterized in that: The game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources, and the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to perform the graphics rendering work of the mini-game, including: A resource recycling class is defined in the language binding layer. The resource recycling class includes a termination callback member and a reference cleanup member. A script object destruction operation is performed based on the termination callback member. A memory space of an object mapping table is released based on the reference cleanup member. The resource recycling class resets a weak reference counter to zero. A rendering component class is set in the resource recycling class, and the rendering component class includes a rendering agent member and a drawing command member. A rendering interface is called based on the rendering agent member to register a rendering callback function, and a rendering interface is called based on the drawing command member to execute a drawing operation sequence. The rendering component class drives the screen update according to the game logic.

7. A general graphics rendering device for mini-games based on a layered architecture, characterized in that: The device comprises: The abstract module is used to realize the interaction between the operating system platform and the game engine through the window abstract layer, and encapsulate the window creation instruction, the game event monitoring instruction and the image drawing instruction into the game canvas operation interface, which specifically includes: defining the window abstract interface class by using the underlying programming language, the window abstract interface class includes a window identifier member and a window status information member, calling the window handle registration interface of the operating system platform based on the window identifier member to generate the main window identifier of the application program, calling the system message loop interface based on the window status information member to parse the window event data, and the window abstract interface class maps the application programming interface provided by the operating system platform to the corresponding data structure; defining the canvas rendering interface in the window abstract interface class, the canvas rendering interface includes a drawing surface member and a rendering context member, calling the graphics device interface based on the drawing surface member to construct the drawable surface data of the window client area, calling the graphics library interface based on the rendering context member to configure the drawing attribute parameters, and the canvas rendering interface uses the front and back buffer exchange method to write the image data, and the game canvas operation interface is used to process the creation of the game window, the update of the game screen and the input event of the player, and the game canvas operation interface calls the graphics library interface to complete the underlying rendering of the game screen; A rendering module, used to call the game canvas operation interface provided by the window abstraction layer in the rendering implementation layer to implement a rendering interface, wherein the rendering interface includes an initialization interface for a game scene, a drawing interface for a game object, and an update interface for a game animation, and the rendering interface performs real-time rendering of the game screen; A binding module is used to store the virtual machine stack address, virtual machine function table address and exception handling address of the game script engine in the pointer of the state object at the language binding layer, the state object generates a parameter parser to convert the script parameter into a native data type, the parameter parser converts the callback function into the function definition of the game script engine through the attribute callback wrapper macro, the attribute callback wrapper macro establishes a mapping table from native pointer to game object and stores the game object in a weak reference manner, the game script engine triggers the termination callback function of the attribute callback wrapper macro to recycle resources, and the language binding layer calls the rendering interface provided by the rendering implementation layer to implement the canvas rendering component of the lightweight game engine to perform the graphics rendering work of the mini-game.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the general graphics rendering method for mini-games based on a layered architecture as described in any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the general graphics rendering method for mini-games based on a layered architecture as described in any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Three-dimensional game engine system

    CN102880464A

  • Cloud platform virtual machine recovery method and computer equipment

    CN112732406A

  • Method and device for determining object for calling stack frame, equipment and medium

    CN112925717A