CN111476858A - 2d engine rendering method, device and equipment based on WebG L - Google Patents

2d engine rendering method, device and equipment based on WebG L Download PDF

Info

Publication number
CN111476858A
CN111476858A CN202010279091.2A CN202010279091A CN111476858A CN 111476858 A CN111476858 A CN 111476858A CN 202010279091 A CN202010279091 A CN 202010279091A CN 111476858 A CN111476858 A CN 111476858A
Authority
CN
China
Prior art keywords
geometric
rendering
objects
webg
geometric object
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010279091.2A
Other languages
Chinese (zh)
Other versions
CN111476858B (en
Inventor
李鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Wooduan Technology Co ltd
Original Assignee
Zhejiang Wooduan Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Wooduan Technology Co ltd filed Critical Zhejiang Wooduan Technology Co ltd
Priority to CN202010279091.2A priority Critical patent/CN111476858B/en
Publication of CN111476858A publication Critical patent/CN111476858A/en
Application granted granted Critical
Publication of CN111476858B publication Critical patent/CN111476858B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a WebG L-based 2d engine rendering method, a WebG L-based 2d engine rendering device and a WebG L-based 2d engine rendering method, a WebG L-based 2d engine rendering device and a computer-readable storage medium, wherein the WebG L-based 2d engine rendering method comprises the steps of obtaining geometric objects corresponding to display objects, sequencing all the geometric objects according to rendering states and mapping information of each geometric object to obtain a sequencing result, performing grouping packaging on all the geometric objects according to the sequencing result and the number of preset single batch objects to obtain a geometric object group, creating batch processing requests according to the number of required mappings and the preset maximum mapping number of each geometric object group, and rendering each batch processing request.

Description

2d engine rendering method, device and equipment based on WebG L
Technical Field
The invention relates to the technical field of computers, in particular to a WebG L-based 2d engine rendering method, device and equipment and a computer-readable storage medium.
Background
WebG L (Web Graphics L library) is a 3D drawing protocol, which allows JavaScript (a scripting language) and OpenG L ES 2.0 (a graphical program interface) to be combined together, and by adding a JavaScript binding of OpenG L ES 2.0, WebG L can provide hardware 3D accelerated rendering for HTM L Canvas (used for drawing Graphics on a Web page), so that a Web developer can more smoothly display 3D scenes and models in a browser by means of a system Graphics card, and can also create complex navigation and data visualization.
In the prior art, most of the WebG L-based 2d engines (i.e., the WebG L d engines) use hardware to render sprites (display objects), and a batch processing method is not adopted, so that rendering efficiency and performance are low, and user experience is not facilitated.
Disclosure of Invention
The invention aims to provide a WebG L-based 2d engine rendering method, a WebG L-based 2d engine rendering device and a computer-readable storage medium, so that the rendering efficiency and the rendering performance of a hardware-rendered display object are improved, and the user experience is improved.
In order to solve the technical problem, the invention provides a 2d engine rendering method based on WebG L, which includes:
acquiring geometric objects corresponding to the display objects respectively; each geometric object is packaged by rendering information of a corresponding display object, and the rendering information comprises vertex data, map information and a rendering state;
sequencing all the geometric objects according to the rendering state and the map information of each geometric object to obtain a sequencing result; wherein, the geometric objects with the same rendering state and the same mapping information in the sequencing result are adjacent;
according to the sorting result and the number of preset single batch objects, all the geometric objects are packaged in groups to obtain a geometric object group; wherein, each geometric object group is uploaded to the vertex data, the map information and the rendering state in the same vertex cache by all the corresponding geometric objects;
creating batch processing requests according to the required mapping number and the preset maximum mapping number of each geometric object group, and rendering each batch processing request; and the quantity of the required maps is the quantity of different map information in the corresponding geometric object group.
Optionally, the sorting all the geometric objects according to the rendering state and the map information of each geometric object to obtain a sorting result includes:
putting all the geometric objects into a display list;
according to the rendering state and the map information of each geometric object, all the geometric objects in the display list are sorted to obtain a sorted display list; and the geometric objects with the same rendering state in the sorted display list are adjacent, and the geometric objects with the same rendering state and the same map information are adjacent.
Optionally, all the geometric objects in the sorted display list are arranged from large to small according to the same number of the rendering states, and the geometric objects in the rendering states are arranged from large to small according to the same number of the map information.
Optionally, the grouping and encapsulating all the geometric objects according to the sorting result and the number of preset single batch objects to obtain a geometric object group includes:
and according to the sorting sequence of the sorted display list, taking the geometric objects with the preset single batch of objects as a group, uploading the vertex data of all the geometric objects in each group to a corresponding vertex cache, and packaging the vertex data, the map information and the rendering state into the geometric object group.
Optionally, the creating a batch request according to the number of required maps and the preset maximum number of maps in each geometric object group includes:
judging whether the quantity of the required maps corresponding to the residual geometric objects in the current geometric object group is greater than the preset maximum number of the maps;
if yes, selecting different map information with the preset maximum number of maps from the remaining geometric objects in the current geometric object group according to the sorting sequence of the current geometric object group to create a current map list, creating a current batch processing request according to the current map list, and executing the step of judging whether the number of required maps corresponding to the remaining geometric objects in the current geometric object group is larger than the preset maximum number of maps;
if not, selecting the mapping information of all the remaining geometric objects in the current geometric object group to create a current mapping list, and creating a current batch processing request according to the current mapping list.
Optionally, the obtaining of the geometric objects corresponding to the display objects includes:
traversing all the display objects according to the root node container;
and encapsulating the rendering information of each display object into a corresponding geometric object.
Optionally, before the sorting all the geometric objects according to the rendering state and the map information of each geometric object and obtaining a sorting result, the method further includes:
and setting a stage level value corresponding to each geometric object according to the level of the original stage corresponding to each display object.
The invention also provides a 2d engine rendering device based on the WebG L, which comprises:
the acquisition module is used for acquiring the geometric objects corresponding to the display objects; each geometric object is packaged by rendering information of a corresponding display object, and the rendering information comprises vertex data, map information and a rendering state;
the sorting module is used for sorting all the geometric objects according to the rendering state and the map information of each geometric object to obtain a sorting result; wherein, the geometric objects with the same rendering state and the same mapping information in the sequencing result are adjacent;
the packaging module is used for packaging all the geometric objects in groups according to the sorting result and the preset number of the single batch objects to obtain a geometric object group; wherein, each geometric object group is uploaded to the vertex data, the map information and the rendering state in the same vertex cache by all the corresponding geometric objects;
the rendering module is used for creating batch processing requests according to the required mapping number and the preset maximum mapping number of each geometric object group and rendering each batch processing request; and the quantity of the required maps is the quantity of different map information in the corresponding geometric object group.
The invention also provides a 2d engine rendering device based on the WebG L, which comprises:
a memory for storing a computer program;
a processor for implementing the steps of the WebG L-based 2d engine rendering method as described above when executing the computer program.
The present invention also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the WebG L-based 2d engine rendering method as described above.
The invention provides a WebG L-based 2d engine rendering method which comprises the steps of obtaining geometric objects corresponding to display objects, wherein each geometric object is packaged by rendering information of the corresponding display object, the rendering information comprises vertex data, map information and a rendering state, sequencing all the geometric objects according to the rendering state and the map information of each geometric object to obtain a sequencing result, wherein the geometric objects with the same rendering state in the sequencing result are adjacent, the geometric objects with the same rendering state and the same map information are adjacent, packaging all the geometric objects in a grouping mode according to the sequencing result and the preset single batch object number to obtain a geometric object group, wherein all the geometric object groups are uploaded to a same vertex cache by all the geometric objects corresponding to each geometric object group, the vertex data, the map information and the rendering state are packaged, creating batch processing requests according to the demand map number and the preset maximum map number of each geometric object group, and rendering each batch processing request, wherein the demand map number is the number of different map information in the corresponding geometric object group;
therefore, according to the method and the device for processing the batch requests by the WebG L, all the geometric objects are sequenced according to the rendering state and the map information of each geometric object, and the geometric objects which are the same in rendering state and need to be rendered by the same map can be adjacent, so that the rendering effect when the batch requests are rendered by hardware is guaranteed, the rendering efficiency and the rendering performance are improved, and the user experience is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a 2d engine rendering method based on WebG L according to an embodiment of the present invention;
FIG. 2 is a schematic flowchart of another WebG L-based 2d engine rendering method according to an embodiment of the present invention;
fig. 3 is a block diagram illustrating a 2d engine rendering apparatus based on WebG L according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a 2d engine rendering device based on WebG L according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart of a 2d engine rendering method based on WebG L according to an embodiment of the present invention, where the method includes:
step 101: acquiring geometric objects corresponding to the display objects respectively; and each geometric object is packaged by rendering information of the corresponding display object, and the rendering information comprises vertex data, map information and a rendering state.
It is understood that a processor running a 2d engine based on WebG L (i.e., WebG L2 d engine) will render multiple times per second at a fixed frame rate, which is exemplified by the rendering of each frame of the processor.
The geometric object (Geometry) in this step is packaged with information required for rendering of the corresponding display object (Sprite), that is, rendering information, such as vertex data, map information, rendering state, and the like.
Specifically, in this step, the processor may obtain geometric objects corresponding to all display objects corresponding to the current frame rendering lock. For the specific way in which the processor acquires the respective geometric objects corresponding to the display objects in this step, the specific way can be set by a designer according to a use scene and user requirements, for example, the processor can traverse all the display objects according to a Root node container; and encapsulating the rendering information of each display object into a corresponding geometric object. As long as the processor can obtain the geometric objects corresponding to all the display objects corresponding to the current frame rendering, this embodiment does not limit this.
Step 102: sequencing all the geometric objects according to the rendering state and the mapping information of each geometric object to obtain a sequencing result; and geometric objects with the same rendering state and the same mapping information in the sequencing result are adjacent.
It can be understood that, in this step, the geometric objects having the same rendering state and the same map information after the completion of the sorting are adjacent to each other by sorting all the geometric objects, so that the geometric objects having the same rendering state and requiring the use of the same map in the geometric objects corresponding to the batch processing request for the subsequent rendering are adjacent to each other, and the rendering effect is ensured.
Specifically, the specific manner in which the processor sorts all the geometric objects according to the rendering state and the map information of each geometric object in this step to obtain a sorting result may be set by a designer, for example, all the geometric objects may be put into a preset queue, i.e., a display queue, and then arranged in the display queue according to the map information of the rendering states of the geometric objects, so that the geometric objects in the same rendering state and the same map information (i.e., the same map is used during rendering) are adjacent to each other; correspondingly, the geometric objects in the same rendering state in the display queue may also be adjacent, that is, the geometric objects in the same rendering state in the sorting result in this step are adjacent, and the geometric objects in the same rendering state and the same mapping information are adjacent. That is, the present step may include: according to the rendering state and the mapping information of each geometric object, sequencing all the geometric objects in the display list to obtain a display list which is sequenced; and the geometric objects with the same rendering state and the same mapping information in the sorted display list are adjacent.
Furthermore, all the geometric objects in the sorted display list can be arranged from large to small according to the same number of rendering states, and the geometric objects in the same rendering states can be arranged from large to small according to the same number of the tile information.
Correspondingly, the step of setting the stage level value corresponding to each geometric object according to the level of the original stage corresponding to each display object can be further included before the step, so that after the rendering of the display objects is finished subsequently, the rendering result corresponding to each display object can be put back to the level of the original stage corresponding to the stage level value according to the stage level value corresponding to each geometric object. As shown in fig. 2, when all the geometric objects (Geometry) are put into the display queue, different z values (i.e., stage level values) may be set according to the level of the display object (Sprite) corresponding to each geometric object in the original stage.
Step 103: according to the sequencing result and the number of preset single batch objects, all geometric objects are packaged in groups to obtain a geometric object group; and each geometric object group is packaged by vertex data, map information and rendering state uploaded to the same vertex cache by all the corresponding geometric objects.
It can be understood that the preset number of single BATCH objects in this step may be the preset maximum single BATCH object data (BATCH _ general) of the WebG L2 d engine, and the purpose of this step may be to encapsulate all geometric objects into one or more geometric object groups (geotrygroups) according to the preset number of single BATCH objects according to the sorting result, that is, to encapsulate the geometric objects of the preset number of single BATCH objects into one geometric object group according to the sorting result.
For example, when the sorting result in this step is a sorted display list, the processor may upload vertex data of all geometric objects in each group to a corresponding vertex cache according to a sorting order by using geometric objects of a preset single batch number as a group, and package the vertex data, the map information, and the rendering state into a geometric object group.
Step 104: creating batch processing requests according to the required mapping number and the preset maximum mapping number of each geometric object group, and rendering each batch processing request; the number of the required maps is the number of different map information in the corresponding geometric object group.
It should be noted that the preset maximum number of tiles in this step may be the maximum number of tiles (MAX _ TEXTURE) supported by a single fragment shader supported by preset hardware (e.g., graphics card GPU). The purpose of this step may be to encapsulate each geometric object group into one or more batch processing requests (batchdrawcalls) according to a preset maximum number of maps and an actual number of required maps of each geometric object group, that is, the number of all geometric objects corresponding to each batch processing request is less than or equal to the preset number of single batch objects, and the number of required maps of all geometric objects corresponding to each batch processing request (that is, the number of different map information) is less than or equal to the preset maximum number of maps; therefore, the batch processing request is rendered, the batch processing of rendering is realized, namely a plurality of objects to be rendered are merged and submitted to hardware for rendering at one time, and the rendering performance is improved.
It can be understood that, for the specific way in which the processor creates the batch request according to the required number of maps and the preset maximum number of maps of each geometric object group in this step, it may be set by the designer, for example, it may traverse all geometric object groups, if the number of maps needed to be used by all geometric objects in the geometric object groups exceeds the preset maximum number of maps, then create a map list for one group with the preset maximum number of maps, and create the batch request according to the map list; if the preset maximum number of maps is not exceeded, all the maps needed for the set of geometric objects are placed in the map list and a batch request is created.
That is, the present step may include: judging whether the quantity of the required maps corresponding to the residual geometric objects in the current geometric object group is greater than the preset maximum number of the maps or not; wherein, the current geometric object group is any geometric object group currently processed; if so, selecting different mapping information with preset maximum mapping numbers from the remaining geometric objects in the current geometric object group according to the sorting sequence of the current geometric object group to create a current mapping list, creating a current batch processing request according to the current mapping list, executing a step of judging whether the required mapping numbers corresponding to the remaining geometric objects in the current geometric object group are larger than the preset maximum mapping numbers, and continuously processing the remaining geometric objects in the current geometric object group; if not, selecting the mapping information of all the remaining geometric objects in the current geometric object group to create a current mapping list, and creating a current batch processing request according to the current mapping list.
Specifically, the processor in this step renders each batch request, and may render each batch request by using hardware such as a GPU for the processor. Correspondingly, the step may further include a step of uploading a map to the hardware performing the rendering, for example, the processor may traverse all the batch processing requests, and before each batch processing request is rendered by using the hardware, may determine whether to upload the map required by the batch processing request to the hardware; if the mapping is not uploaded, uploading the mapping and rendering the batch processing request; if the map is uploaded, the batch processing request can be directly rendered, and repeated uploading is avoided.
In the embodiment of the invention, all the geometric objects are sequenced according to the rendering state and the map information of each geometric object, and the geometric objects which have the same rendering state and need to be rendered by using the same map can be adjacent, so that the rendering effect when the batch processing request is rendered by using hardware is ensured, the rendering efficiency and the rendering performance are improved, and the user experience is improved.
Referring to fig. 3, fig. 3 is a block diagram illustrating a 2d engine rendering apparatus based on WebG L according to an embodiment of the present invention, where the apparatus may include:
an obtaining module 10, configured to obtain geometric objects corresponding to display objects respectively; each geometric object is packaged by rendering information of a corresponding display object, and the rendering information comprises vertex data, map information and a rendering state;
the sorting module 20 is configured to sort all the geometric objects according to the rendering state and the map information of each geometric object, and obtain a sorting result; geometric objects with the same rendering state and the same mapping information in the sequencing result are adjacent;
the packaging module 30 is configured to package all geometric objects in groups according to the sorting result and the number of preset single batch objects, and obtain a geometric object group; wherein, each geometric object group is packaged by the vertex data and the chartlet information and the rendering state which are uploaded to the same vertex cache by all the corresponding geometric objects;
the rendering module 40 is configured to create batch processing requests according to the number of required maps of each geometric object group and a preset maximum number of maps, and render each batch processing request; the number of the required maps is the number of different map information in the corresponding geometric object group.
Optionally, the sorting module 20 may be specifically configured to put all geometric objects into the display list; sequencing all the geometric objects in the display list according to the rendering state and the mapping information of each geometric object to obtain a display list which is sequenced; and the geometric objects with the same rendering state and the same mapping information in the sorted display list are adjacent.
Optionally, all the geometric objects in the sorted display list are arranged from large to small according to the same number of rendering states, and the geometric objects in the same rendering states are arranged from large to small according to the same number of the tile information.
Optionally, the encapsulation module 30 may be specifically configured to, according to the sorting order of the sorted display list, take geometric objects with a preset number of single batch objects as a group, upload vertex data of all geometric objects in each group to a corresponding vertex cache, and encapsulate the vertex data, the map information, and the rendering state into a geometric object group.
Optionally, the rendering module 40 may include:
the judging submodule is used for judging whether the quantity of the required maps corresponding to the residual geometric objects in the current geometric object group is larger than the preset maximum map quantity or not;
the first creating submodule is used for selecting different mapping information with the preset maximum mapping number from the remaining geometric objects in the current geometric object group according to the sorting sequence of the current geometric object group to create a current mapping list if the mapping number is larger than the preset maximum mapping number, creating a current batch processing request according to the current mapping list, and sending a starting signal to the judging submodule;
and the first creating sub-module is used for selecting the mapping information of all the residual geometric objects in the current geometric object group to create a current mapping list if the mapping number is not larger than the preset maximum mapping number, and creating the current batch processing request according to the current mapping list.
Optionally, the obtaining module 10 may include:
the traversing submodule is used for traversing all the display objects according to the root node container;
and the packaging submodule is used for packaging the rendering information of each display object into a corresponding geometric object.
Optionally, the apparatus may further include:
and the level setting module is used for setting a stage level value corresponding to each geometric object according to the level of the original stage corresponding to each display object.
In this embodiment, the sorting module 20 sorts all the geometric objects according to the rendering state and the map information of each geometric object, and geometric objects which have the same rendering state and need to be rendered by using the same map can be adjacent to each other, so that the rendering effect when a batch request is rendered by using hardware is ensured, the rendering efficiency and the rendering performance are improved, and the user experience is improved.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a 2d engine rendering device based on WebG L according to an embodiment of the present invention, where the device 1 may include:
the system comprises a memory 11 for storing a computer program, and a processor 12 for implementing the steps of the WebG L-based 2d engine rendering method provided by the above embodiment when the computer program is executed.
In the present embodiment, the device 1 may be a PC (Personal Computer), or may be a terminal device such as a tablet Computer, a portable Computer, or a server.
The device 1 may include a memory 11, a processor 12 and a bus 13.
Wherein the memory 11 comprises at least one type of readable storage medium comprising a Flash memory, a hard disk, a multimedia Card, a Card type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, etc., the memory 11 may in some embodiments be an internal storage unit of the device 1, such as a hard disk of the device 1, the memory 11 may in other embodiments also be an external storage device of the device 1, such as a plug-in hard disk provided on the device 1, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card), etc., further, the memory 11 may comprise both an internal storage unit of the device 1 and an external storage device, the memory 11 may be used not only for storing application software installed in the device 1 and various types of data, such as code for executing a program based on the WebG L2 d engine rendering method, etc., but also for temporarily storing data that has been or will be output.
The processor 12 may be, in some embodiments, a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data Processing chip for executing program code or Processing data stored in the memory 11, such as code of a program for executing a 2d engine rendering method based on WebG L, and the like.
The bus 13 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 4, but this does not indicate only one bus or one type of bus.
Further, the device may further comprise a network interface 14, and the network interface 14 may optionally comprise a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the device 1 and other electronic devices.
Optionally, the device 1 may further comprise a user interface 15, the user interface 15 may comprise a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 15 may also comprise a standard wired interface, a wireless interface, optionally, in some embodiments, the Display may be an L ED Display, a liquid crystal Display, a touch-sensitive liquid crystal Display, an O L ED (Organic L light-Emitting Diode) touch-sensitive device, etc., wherein the Display may also be appropriately referred to as a Display screen or Display unit for displaying information processed in the device 1 and for displaying a visualized user interface.
Fig. 4 only shows the device 1 with the components 11-15, and it will be understood by a person skilled in the art that the structure shown in fig. 4 does not constitute a limitation of the device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
In addition, the embodiment of the present invention also discloses a computer readable storage medium, which stores a computer program thereon, and the computer program, when executed by a processor, implements the steps of the WebG L-based 2d engine rendering method provided in the above embodiment.
Wherein the storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device, the apparatus and the computer-readable storage medium disclosed in the embodiments correspond to the method disclosed in the embodiments, so that the description is simple, and the relevant points can be referred to the description of the method.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The present invention provides a method, an apparatus, a device and a computer readable storage medium for rendering a 2d engine based on WebG L, which are described in detail herein, and the principles and embodiments of the present invention are described in detail herein, and the description of the embodiments is only for the purpose of helping understanding the method and the core idea of the present invention.

Claims (10)

1. A WebG L-based 2d engine rendering method is characterized by comprising the following steps:
acquiring geometric objects corresponding to the display objects respectively; each geometric object is packaged by rendering information of a corresponding display object, and the rendering information comprises vertex data, map information and a rendering state;
sequencing all the geometric objects according to the rendering state and the map information of each geometric object to obtain a sequencing result; wherein, the geometric objects with the same rendering state and the same mapping information in the sequencing result are adjacent;
according to the sorting result and the number of preset single batch objects, all the geometric objects are packaged in groups to obtain a geometric object group; wherein, each geometric object group is uploaded to the vertex data, the map information and the rendering state in the same vertex cache by all the corresponding geometric objects;
creating batch processing requests according to the required mapping number and the preset maximum mapping number of each geometric object group, and rendering each batch processing request; and the quantity of the required maps is the quantity of different map information in the corresponding geometric object group.
2. The WebG L-based 2d engine rendering method according to claim 1, wherein the sorting all the geometric objects according to the rendering state and the map information of each geometric object to obtain a sorting result comprises:
putting all the geometric objects into a display list;
according to the rendering state and the map information of each geometric object, all the geometric objects in the display list are sorted to obtain a sorted display list; and the geometric objects with the same rendering state in the sorted display list are adjacent, and the geometric objects with the same rendering state and the same map information are adjacent.
3. The WebG L-based 2d engine rendering method according to claim 2, wherein all the geometric objects in the sorted display list are arranged from large to small according to the same number of the rendering states, and the geometric objects in the rendering states are arranged from large to small according to the same number of the map information.
4. The WebG L-based 2d engine rendering method according to claim 2, wherein the grouping and packaging all the geometric objects according to the sorting result and a preset number of single batch objects to obtain a geometric object group comprises:
and according to the sorting sequence of the sorted display list, taking the geometric objects with the preset single batch of objects as a group, uploading the vertex data of all the geometric objects in each group to a corresponding vertex cache, and packaging the vertex data, the map information and the rendering state into the geometric object group.
5. The WebG L-based 2d engine rendering method according to claim 1, wherein the creating a batch request according to the number of required maps and the preset maximum number of maps in each geometric object group comprises:
judging whether the quantity of the required maps corresponding to the residual geometric objects in the current geometric object group is greater than the preset maximum number of the maps;
if yes, selecting different map information with the preset maximum number of maps from the remaining geometric objects in the current geometric object group according to the sorting sequence of the current geometric object group to create a current map list, creating a current batch processing request according to the current map list, and executing the step of judging whether the number of required maps corresponding to the remaining geometric objects in the current geometric object group is larger than the preset maximum number of maps;
if not, selecting the mapping information of all the remaining geometric objects in the current geometric object group to create a current mapping list, and creating a current batch processing request according to the current mapping list.
6. The WebG L-based 2d engine rendering method according to claim 1, wherein the obtaining of the geometric objects corresponding to the display objects comprises:
traversing all the display objects according to the root node container;
and encapsulating the rendering information of each display object into a corresponding geometric object.
7. The WebG L-based 2d engine rendering method according to any one of claims 1 to 6, wherein the method, before the sorting of all the geometric objects according to the rendering state and the map information of each geometric object and obtaining a sorting result, further comprises:
and setting a stage level value corresponding to each geometric object according to the level of the original stage corresponding to each display object.
8. A WebG L-based 2d engine rendering apparatus, comprising:
the acquisition module is used for acquiring the geometric objects corresponding to the display objects; each geometric object is packaged by rendering information of a corresponding display object, and the rendering information comprises vertex data, map information and a rendering state;
the sorting module is used for sorting all the geometric objects according to the rendering state and the map information of each geometric object to obtain a sorting result; wherein, the geometric objects with the same rendering state and the same mapping information in the sequencing result are adjacent;
the packaging module is used for packaging all the geometric objects in groups according to the sorting result and the preset number of the single batch objects to obtain a geometric object group; wherein, each geometric object group is uploaded to the vertex data, the map information and the rendering state in the same vertex cache by all the corresponding geometric objects;
the rendering module is used for creating batch processing requests according to the required mapping number and the preset maximum mapping number of each geometric object group and rendering each batch processing request; and the quantity of the required maps is the quantity of different map information in the corresponding geometric object group.
9. A WebG L-based 2d engine rendering device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the WebG L-based 2d engine rendering method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the WebG L-based 2d engine rendering method of any one of claims 1 to 7.
CN202010279091.2A 2020-04-10 2020-04-10 WebGL-based 2d engine rendering method, device and equipment Active CN111476858B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010279091.2A CN111476858B (en) 2020-04-10 2020-04-10 WebGL-based 2d engine rendering method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010279091.2A CN111476858B (en) 2020-04-10 2020-04-10 WebGL-based 2d engine rendering method, device and equipment

Publications (2)

Publication Number Publication Date
CN111476858A true CN111476858A (en) 2020-07-31
CN111476858B CN111476858B (en) 2023-03-14

Family

ID=71751795

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010279091.2A Active CN111476858B (en) 2020-04-10 2020-04-10 WebGL-based 2d engine rendering method, device and equipment

Country Status (1)

Country Link
CN (1) CN111476858B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112348962A (en) * 2020-11-30 2021-02-09 久瓴(江苏)数字智能科技有限公司 Model component clicking method and device, computer equipment and storage medium
CN112614041A (en) * 2020-12-29 2021-04-06 完美世界(北京)软件科技发展有限公司 Data driving method and device for sparse rendering, storage medium and electronic device

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100164983A1 (en) * 2008-12-29 2010-07-01 Microsoft Corporation Leveraging graphics processors to optimize rendering 2-d objects
CN106504185A (en) * 2016-10-26 2017-03-15 腾讯科技(深圳)有限公司 One kind renders optimization method and device
CN107463398A (en) * 2017-07-21 2017-12-12 腾讯科技(深圳)有限公司 Game rendering intent, device, storage device and terminal
US20180150296A1 (en) * 2016-11-28 2018-05-31 Samsung Electronics Co., Ltd. Graphics processing apparatus and method of processing texture in graphics pipeline
CN109076097A (en) * 2016-03-14 2018-12-21 电子湾有限公司 System and method for entrusting contents processing
CN109509247A (en) * 2018-09-21 2019-03-22 苏州蜗牛数字科技股份有限公司 A method of support the geometry of light-maps instantiates to draw
CN110717963A (en) * 2019-08-30 2020-01-21 杭州群核信息技术有限公司 WebGL-based replaceable model hybrid rendering display method, system and storage medium
US20200026516A1 (en) * 2018-07-20 2020-01-23 Cesium GS, Inc. Systems and Methods For Rendering Vector Data On Static And Dynamic-Surfaces Using Screen Space Decals And A Depth Texture

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100164983A1 (en) * 2008-12-29 2010-07-01 Microsoft Corporation Leveraging graphics processors to optimize rendering 2-d objects
CN109076097A (en) * 2016-03-14 2018-12-21 电子湾有限公司 System and method for entrusting contents processing
CN106504185A (en) * 2016-10-26 2017-03-15 腾讯科技(深圳)有限公司 One kind renders optimization method and device
US20180150296A1 (en) * 2016-11-28 2018-05-31 Samsung Electronics Co., Ltd. Graphics processing apparatus and method of processing texture in graphics pipeline
CN107463398A (en) * 2017-07-21 2017-12-12 腾讯科技(深圳)有限公司 Game rendering intent, device, storage device and terminal
US20200026516A1 (en) * 2018-07-20 2020-01-23 Cesium GS, Inc. Systems and Methods For Rendering Vector Data On Static And Dynamic-Surfaces Using Screen Space Decals And A Depth Texture
CN109509247A (en) * 2018-09-21 2019-03-22 苏州蜗牛数字科技股份有限公司 A method of support the geometry of light-maps instantiates to draw
CN110717963A (en) * 2019-08-30 2020-01-21 杭州群核信息技术有限公司 WebGL-based replaceable model hybrid rendering display method, system and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112348962A (en) * 2020-11-30 2021-02-09 久瓴(江苏)数字智能科技有限公司 Model component clicking method and device, computer equipment and storage medium
CN112348962B (en) * 2020-11-30 2022-05-27 久瓴(江苏)数字智能科技有限公司 Model component clicking method and device, computer equipment and storage medium
CN112614041A (en) * 2020-12-29 2021-04-06 完美世界(北京)软件科技发展有限公司 Data driving method and device for sparse rendering, storage medium and electronic device

Also Published As

Publication number Publication date
CN111476858B (en) 2023-03-14

Similar Documents

Publication Publication Date Title
CN110990516A (en) Map data processing method and device and server
CN112102437B (en) Canvas-based radar map generation method and device, storage medium and terminal
CN111950056B (en) BIM display method and related equipment for building informatization model
CN111476858B (en) WebGL-based 2d engine rendering method, device and equipment
CN112785676B (en) Image rendering method, device, equipment and storage medium
CN113256782A (en) Three-dimensional model generation method and device, storage medium and electronic equipment
US20230298237A1 (en) Data processing method, apparatus, and device and storage medium
WO2023197762A1 (en) Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product
CN109389659A (en) Rendering method and device of PPT (Power Point) mathematical formula, storage medium and terminal equipment
CN113538502A (en) Picture clipping method and device, electronic equipment and storage medium
CN110738720A (en) Special effect rendering method and device, terminal and storage medium
US11157551B2 (en) Method and device for image loading
CN116128983A (en) Picture processing method and device and picture rendering method and device
CN113989442B (en) Building information model construction method and related device
CN112184538B (en) Image acceleration method, related device, equipment and storage medium
CN111967478B (en) Feature map reconstruction method, system, storage medium and terminal based on weight overturn
CN113572724B (en) Sequence frame loading speed optimization method and device
CN116185545A (en) Page rendering method and device
CN111325816B (en) Feature map processing method and device, storage medium and terminal
CN115794400A (en) Memory management method, device and equipment of deep learning model and storage medium
CN114712853A (en) Game map loading and displaying method, device, equipment and storage medium
CN109767379B (en) Data normalization processing method and device, storage medium and electronic equipment
CN115270710A (en) Typesetting method and typesetting device
CN112416489A (en) Engineering drawing display method and related device
CN112511765B (en) Image rotation method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant