A method and device for image rendering based on GLSL ES
By removing and replacing the target extension code in the shader code on the Android side, making it compatible on the Windows side, it solves the problem that GLSL ES image rendering technology under the Android platform cannot be used on the Windows platform, and improves the gaming experience.
Patent Information
- Application Number
- CN202111440868.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-11-30
AI Technical Summary
The existing technology cannot be compatible with the GLSL ES image rendering technology used on the Android platform on the Windows platform, resulting in limited gaming experience.
By obtaining and checking the shader code on the Android side, removing the target extension code, and replacing its corresponding target texture description code with preset general code, and sending it to the Windows side for image rendering.
Making the processed shader code compatible on the Windows side, enhancing the player's gaming experience.
Smart Images

Figure CN114359464B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to an image rendering method and apparatus based on GLSL ES, a storage medium, and a computer device. Background Art
[0002] With the rapid development of smart mobile terminals, their user base is getting larger and larger. In order to adapt to the increasing user needs, smart mobile terminal developers have developed a series of new mobile terminal software. Among them, the potential market for mobile games based on the Android system is larger than that of other smart mobile terminal platforms. Therefore, more and more mobile game apps are gradually emerging in this environment.
[0003] Currently, GLSL ES image rendering technology is widely used in mobile game apps to provide a better gaming experience. However, using mobile phones as smart mobile devices usually has the following problems: small screen, fast power consumption, frequent phone calls that interrupt the game, etc., which seriously affects the player's gaming experience. However, GLSL ES image rendering technology, as the core of the game, cannot be used directly on the Windows side because it is not compatible with the Windows side.
[0004] Therefore, how to successfully use the GLSL ES image rendering technology used on the Android platform on the Windows platform to improve the player experience has become an urgent problem to be solved in this field. Summary of the invention
[0005] In view of this, the present application provides an image rendering method and apparatus, storage medium, and computer equipment based on GLSL ES, so that the processed shader code can be compatible with the Windows side, so that image rendering can be performed on the Windows side, which can greatly enhance the player's experience.
[0006] According to one aspect of the present application, a GLSL ES-based image rendering method is provided, comprising:
[0007] Obtaining a GLSL ES-based shader code, and checking whether a target extension code exists in the shader code;
[0008] When the target extension code exists in the shader code, the target extension code is removed, and the target texture description code corresponding to the target extension code is replaced with a preset general code;
[0009] The replaced shader code and the preset conversion code are sent to the Windows end, so that the Windows end renders the image according to the replaced shader code and the preset conversion code.
[0010] Optionally, before checking whether there is a target extension code in the shader code, the method further includes:
[0011] Searching for a code corresponding to a preset keyword in the shader code, using the code as a macro name, and using the preset general code as macro content for macro definition;
[0012] Perform macro definition processing on the shader code and update the shader code.
[0013] Optionally, before obtaining the GLSL ES-based shader code, the method further includes:
[0014] Monitor the call instruction of the preset application program to the target interface in real time, and when the call instruction is monitored, capture the target interface at the driver layer;
[0015] Acquire the string text uploaded by the preset application through the target interface, and integrate the string text to obtain an initial shader code based on GLSL ES;
[0016] Invalid codes in the initial shader code are removed to obtain the GLSL ES-based shader code.
[0017] Optionally, removing invalid code from the initial shader code to obtain the GLSL ES-based shader code specifically includes:
[0018] The empty string, comment code and declaration information in the initial shader code are removed to obtain the GLSL ES-based shader code.
[0019] Optionally, the Windows end renders the image according to the replaced shader code and the preset conversion code, specifically including:
[0020] The Windows end receives the replaced shader code and the preset conversion code, and determines whether there is a target texture object in the shader code through the preset conversion code;
[0021] When the target texture object exists, determining whether a first texture object corresponding to a preset texture generation function is the same as a second texture object bound in a preset texture binding function;
[0022] When they are the same, transmitting the parameter data corresponding to the preset texture generation function to the second texture bound to the second texture object, so as to render the image;
[0023] When they are not the same, determine the first texture corresponding to the last time the preset texture binding function bound the first texture object, replace the second texture and the second texture object corresponding to the preset texture binding function with the first texture and the first texture object, and transfer the parameter data corresponding to the preset texture generation function to the first texture to render the image.
[0024] Optionally, after transmitting the parameter data corresponding to the preset texture generation function to the first texture to render the image, the method further includes:
[0025] The first texture and the first texture object corresponding to the preset texture binding function are restored to the second texture and the second texture object.
[0026] Optionally, sending the replaced shader code and the preset conversion code to the Windows end specifically includes:
[0027] The replaced shader code and the preset conversion code are packaged, and an identifier corresponding to the Windows end is determined, and based on the identifier, the packaged shader code and the preset conversion code are sent to the Windows end through a target pipeline.
[0028] According to another aspect of the present application, there is provided an image rendering device based on GLSL ES, comprising:
[0029] A code checking module, used for obtaining a shader code based on GLSL ES, and checking whether a target extension code exists in the shader code;
[0030] A code replacement module, used for removing the target extension code when the target extension code exists in the shader code, and replacing the target texture description code corresponding to the target extension code with a preset general code;
[0031] The code sending module is used to send the replaced shader code and the preset conversion code to the Windows end, so that the Windows end renders the image according to the replaced shader code and the preset conversion code.
[0032] Optionally, the device further comprises:
[0033] A macro definition processing module is used to query the code corresponding to the preset keyword in the shader code before checking whether there is a target extension code in the shader code, use the code as the macro name, and use the preset general code as the macro content to perform macro definition; perform macro definition processing on the shader code and update the shader code.
[0034] Optionally, the device further comprises:
[0035] A monitoring module, used for monitoring the calling instruction of the preset application to the target interface in real time before obtaining the GLSL ES-based shader code, and capturing the target interface at the driver layer when the calling instruction is monitored;
[0036] An integration module, used for acquiring the string text uploaded by the preset application through the target interface, and integrating the string text to obtain an initial shader code based on GLSL ES;
[0037] A removal module is used to remove invalid codes in the initial shader code to obtain the GLSL ES-based shader code.
[0038] Optionally, the removal module is specifically used to:
[0039] The empty string, comment code and declaration information in the initial shader code are removed to obtain the GLSL ES-based shader code.
[0040] Optionally, the device further comprises:
[0041] A receiving module, configured to receive the replaced shader code and the preset conversion code on the Windows side, and determine whether a target texture object exists in the shader code through the preset conversion code;
[0042] A judging module, used for judging whether a first texture object corresponding to a preset texture generating function is the same as a second texture object bound in a preset texture binding function when the target texture object exists;
[0043] A rendering module, used for transmitting parameter data corresponding to the preset texture generation function to the second texture bound to the second texture object, so as to render the image, when the parameters are the same;
[0044] A texture replacement module is used to determine the first texture corresponding to the preset texture binding function when it last bound the first texture object, when they are not the same, replace the second texture and the second texture object corresponding to the preset texture binding function with the first texture and the first texture object, and transmit the parameter data corresponding to the preset texture generation function to the first texture to render the image.
[0045] Optionally, the device further comprises:
[0046] A code recovery module is used to transmit the parameter data corresponding to the preset texture generation function to the first texture, so as to restore the first texture and the first texture object corresponding to the preset texture binding function to the second texture and the second texture object after rendering the image.
[0047] Optionally, the code sending module is specifically used to:
[0048] The replaced shader code and the preset conversion code are packaged, and an identifier corresponding to the Windows end is determined, and based on the identifier, the packaged shader code and the preset conversion code are sent to the Windows end through a target pipeline.
[0049] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the above-mentioned image rendering method based on GLSL ES is implemented.
[0050] According to another aspect of the present application, a computer device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned GLSL ES-based image rendering method when executing the program.
[0051] By means of the above technical scheme, the present application provides an image rendering method and device based on GLSL ES, a storage medium, and a computer device. The Android end obtains a shader code based on GLSL ES, and checks the obtained shader code to see whether there is a target extension code therein. If the target extension code is found in the shader code after checking, the target extension code can be removed from the shader code. Since the corresponding target texture description code is usually used in the case of the target extension code, the target texture description code can also be replaced by the preset general code. Then, the replaced shader code and the preset conversion code can be sent to the Windows end. After the Windows end receives the replaced shader code and the preset conversion code, the image can be rendered according to the shader code and the preset conversion code. The embodiment of the present application removes the target extension code existing in the shader code based on GLSL ES on the Android end, and replaces the target texture description code, so that the processed shader code can be compatible with the Windows end, so that the image can be rendered on the Windows end, which can greatly improve the player's experience.
[0052] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0054] Figure 1 A schematic diagram of a process of an image rendering method based on GLSL ES provided in an embodiment of the present application is shown;
[0055] Figure 2 A schematic diagram of a process of another image rendering method based on GLSL ES provided in an embodiment of the present application is shown;
[0056] Figure 3 A schematic diagram of the operation flow of a preset texture generation function provided in an embodiment of the present application is shown;
[0057] Figure 4 A schematic diagram of the operation flow of another preset texture generation function provided in an embodiment of the present application is shown;
[0058] Figure 5A schematic structural diagram of an image rendering device based on GLSL ES provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0059] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0060] In this embodiment, a GLSL ES-based image rendering method is provided. Figure 1 As shown, the method includes:
[0061] Step 101, obtaining a GLSL ES-based shader code, and checking whether a target extension code exists in the shader code;
[0062] The image rendering method based on GLSL ES (OpenGL ES Shading Language) provided in the embodiment of the present application can effectively solve the incompatibility problem of applying the GLSL ES image rendering technology used in the Android platform to the Windows platform, and can enhance the user's gaming experience on the Windows platform. GLSL ES is a shading language based on GLSL (OpenGL Shading Language), which has developed a variety of extensions for mobile platforms based on GLSL to support the diverse usage requirements of mobile terminals. First, the Android terminal obtains the shader code based on GLSL ES, and checks the obtained shader code to see if there is a target extension code, where the target extension code refers to the extension code developed for the mobile terminal under GLSL ES, which cannot be recognized by the Windows terminal. For example, OES_EGL_image_external is a unique extension of the Android terminal to support special devices in mobile devices, such as the YUV texture format of the camera, which facilitates the efficient processing of video streams by mobile devices, but there is no support for this extension code on the Windows terminal.
[0063] Step 102, when the target extension code exists in the shader code, the target extension code is removed, and the target texture description code corresponding to the target extension code is replaced with a preset general code;
[0064] In this embodiment, if it is found through inspection that there is a target extension code in the shader code, since the Windows side does not support the target extension code, that is, the target extension code cannot be correctly identified, the target extension code can be removed from the shader code. Since the corresponding target texture description code is usually used in the presence of a target extension code, the target texture description code can also be replaced by a preset universal code, where the preset universal code is a code that can be recognized by the Windows side. For example, the target texture description code corresponding to the OES_EGL_image_external extension code can be samplerExternalOES (used by the Android side to render camera data), so samplerExternalOES can be replaced with sampler2D supported by the Windows side, where sampler2D is equivalent to the preset universal code.
[0065] Step 103, sending the replaced shader code and the preset conversion code to the Windows end, so that the Windows end renders the image according to the replaced shader code and the preset conversion code.
[0066] In this embodiment, after replacing the target texture description code in the shader code, the replaced shader code and the preset conversion code can be sent to the Windows end. Here, the preset conversion code is used to replace the replaced shader code when it is running on the Windows end. If there are some codes that the Windows end cannot recognize, the preset conversion code can be used to replace them. After the replacement, the image can be rendered normally on the Windows end. After receiving the replaced shader code and the preset conversion code, the Windows end can render the image according to the shader code and the preset conversion code.
[0067] By applying the technical solution of this embodiment, the Android end obtains the shader code based on GLSL ES, and checks the obtained shader code to see whether there is a target extension code therein. If it is found that the target extension code exists in the shader code after checking, the target extension code can be removed from the shader code. Since the corresponding target texture description code is usually used in the presence of the target extension code, the target texture description code can also be replaced by the preset general code. Then, the replaced shader code and the preset conversion code can be sent to the Windows end. After the Windows end receives the replaced shader code and the preset conversion code, the image can be rendered according to the shader code and the preset conversion code. The embodiment of the present application removes the target extension code existing in the shader code based on GLSL ES of the Android end, and replaces the target texture description code, so that the processed shader code can be compatible with the Windows end, so that image rendering can be performed on the Windows end, which can greatly enhance the player's experience.
[0068] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process of this embodiment, another image rendering method based on GLSL ES is provided, such as Figure 2 As shown, the method includes:
[0069] Step 201, monitoring the call instruction of the preset application to the target interface in real time, and when the call instruction is monitored, capturing the target interface at the driver layer; obtaining the string text uploaded by the preset application through the target interface, and integrating the string text to obtain the initial shader code based on GLSL ES; removing the invalid code in the initial shader code to obtain the shader code based on GLSL ES;
[0070] In this embodiment, the Android end can monitor the call instructions of the preset application to the target interface in real time. Before the preset application performs image rendering, it can call the target interface glShaderSource (replace the source code in the shader object) to upload its own shader code, so the target interface can be captured at the driver layer to perform a compatibility check under the Windows platform. After monitoring the call instruction to the target interface, the target interface can be captured, and then the string text uploaded by the preset application is obtained using the target interface. The shader code may include multiple string texts. After integrating these string texts, the initial version of the shader code based on GLSL ES can be obtained. The initial version of the shader code may include invalid codes such as empty strings, comment codes written by programmers, and other automatically generated declaration information. The existence of these invalid codes will affect the parsing of subsequent codes. Therefore, these invalid codes can be further removed from the initial shader code, and then a clean shader code based on GLSL ES is obtained. The embodiment of the present application removes the invalid code in the initial shader code, which can effectively reduce the impact of invalid code on subsequent code parsing and improve the stability of code parsing.
[0071] Step 202, obtaining a shader code based on GLSL ES, searching for a code corresponding to a preset keyword in the shader code, using the code as a macro name, and using the preset general code as a macro content to perform macro definition; performing macro definition processing on the shader code, and updating the shader code;
[0072] In this embodiment, after obtaining the shader code based on GLSL ES, the shader code can be further obtained, and the code corresponding to the preset keyword in the shader code can be queried. Here, the preset keyword can be a keyword that is regarded as a code that the Windows system cannot support when it is not processed by macro definition. If there is a code corresponding to the preset keyword in the shader code, then this code can be used as the macro name in the macro definition, and the preset general code that can be recognized by the Windows end is regarded as the macro content for macro definition. After these codes are macro-defined, the entire shader code can be macro-defined, and the shader code can be converted into a shader code after the macro definition takes effect, so that some codes corresponding to the preset keywords can be avoided. After being replaced before being displayed. For example, if the code mySampler is not macro-defined, mySampler cannot be correctly identified as sampler2D in the subsequent process, but may be identified as samplerExternalOES, which will cause the subsequent shader code to fail to run normally on the Windows side.
[0073] Step 203, checking whether there is a target extension code in the shader code; when the target extension code exists in the shader code, removing the target extension code and replacing the target texture description code corresponding to the target extension code with a preset general code;
[0074] In this embodiment, after the shader code is processed by macro definition, it can be further checked whether there is a target extension code in the shader code after macro definition processing. If there is a target extension code, the target extension code therein can be removed, and at the same time, the target texture description code in the shader code can be replaced with a preset general code.
[0075] Step 204, packing the replaced shader code and the preset conversion code, and determining the identifier corresponding to the Windows end, and sending the packed shader code and the preset conversion code to the Windows end through the target pipeline based on the identifier, so that the Windows end renders the image according to the replaced shader code and the preset conversion code.
[0076] In this embodiment, when the target extension code in the shader code is removed and the target texture description code is replaced with a preset universal code supported by the Windows end, the replaced shader code and the preset conversion code can be packaged, and at the same time, the identifier of the Windows end to be sent can be determined, and then the corresponding Windows end is determined according to the identifier of the Windows end, and the packaged codes are sent to the determined Windows end using the target pipeline. After the Windows end receives the replaced shader code and the preset conversion code, it can render the image according to the shader code and the preset conversion code.
[0077] In an embodiment of the present application, optionally, the "Windows end renders the image based on the replaced shader code and the preset conversion code" in step 204 specifically includes: the Windows end receives the replaced shader code and the preset conversion code, and determines whether there is a target texture object in the shader code through the preset conversion code; when the target texture object exists, determines whether the first texture object corresponding to the preset texture generation function is the same as the second texture object bound in the preset texture binding function; when they are the same, transmits the parameter data corresponding to the preset texture generation function to the second texture bound to the second texture object to render the image; when they are not the same, determines the first texture corresponding to the last time the preset texture binding function bound the first texture object, replaces the second texture corresponding to the preset texture binding function and the second texture object with the first texture and the first texture object, and transmits the parameter data corresponding to the preset texture generation function to the first texture to render the image.
[0078] In this embodiment, after receiving the replaced shader code and preset conversion code sent by the Android end, the Windows end can determine whether there is a target texture object in the shader code through the preset conversion code, wherein the target texture object can be GL_TEXTURE_EXTERNAL_OES. When the target texture object exists, it indicates that the corresponding texture objects in the preset texture generation function and the preset texture binding function may be different. Therefore, when the target texture object exists, it can be determined whether the first texture object in the preset texture generation function is the same as the second texture object bound in the preset texture binding function. When the first texture object corresponding to the preset texture generation function is the same as the second texture object bound in the preset texture binding function, the parameter data corresponding to the preset texture generation function can be directly transmitted to the second texture bound to the second texture object, thereby realizing the rendering of the image. If they are not the same, the subsequent operation of the code will be hindered, so the second texture object in the preset texture binding function can be replaced with the first texture object through the preset conversion code, and the second texture in the preset texture binding function can be replaced with the latest first texture corresponding to the last time the preset texture binding function bound the first texture object. Next, the parameter data corresponding to the preset texture generation function is transferred to the first texture to achieve image rendering. Here, functions related to operating textures all require the specified texture object. Taking glBindTexture as an example, when the target is GL_TEXTURE_2D, each call will bind the specified texture to GL_TEXTURE_2D. GLSL ES's unique GL_TEXTURE_EXTERNAL_OES is similar to GL_TEXTURE_2D, both of which bind the specified texture to the object. The difference is that there is no GL_TEXTURE_EXTERNAL_OES on the Windows side.
[0079] To implement GL_TEXTURE_EXTERNAL_OES, you need to convert this texture object to GL_TEXTURE_2D. Functions that modify this texture, such as glTexImage2D, need to distinguish different targets. On the Android side, you can use GL_TEXTURE_2D and GL_TEXTURE_EXTERNAL_OES interchangeably without any problems, because these two targets are similar but non-conflicting implementations at the bottom layer. However, GL_TEXTURE_EXTERNAL_OES needs to be converted to the supported GL_TEXTURE_2D on the Windows side, which will cause texture confusion, rendering errors, screen distortion and other problems. Therefore, you can use the preset conversion code to convert the compatibility of the Android and Windows codes. For example, if glTexImage2D is the preset texture generation function, the corresponding first texture object is GL_TEXTURE_2D, and glBindTexture is the preset texture binding function, the corresponding second texture object is GL_TEXTURE_EXTERNAL_OES, and the corresponding bound texture is the second texture, then the GL_TEXTURE_EXTERNAL_OES of the preset texture binding function can be replaced with GL_TEXTURE_2D, and the second texture can be replaced with the first texture corresponding to the last binding of GL_TEXTURE_2D, and then the relevant operations of the glTexImage2D function can be executed. When the first texture object in the preset texture generation function is the same as the second texture object bound in the preset texture binding function, the relevant operations of the glTexImage2D function are directly executed. In other words, when the first texture object corresponding to glTexImage2D is GL_TEXTURE_2D and the second texture object corresponding to glBindTexture is GL_TEXTURE_EXTERNAL_OES, glTexImage2D on the Android side will recognize different targets and transfer parameter data to the texture whose last texture object is GL_TEXTURE_2D. On the Windows side, there is no GL_TEXTURE_EXTERNAL_OES, so this state needs to be maintained using the preset conversion code and switched to the texture expected by the user.
[0080] Further, as a specific embodiment of the present application, Figure 3As shown, if glTexImage2D is the preset texture generation function, the corresponding texture object is GL_TEXTURE_2D. Next, check the texture object bound before glBindTexture. When the texture object bound before glBindTexture is GL_TEXTURE_2D, directly execute the related operations of the glTexImage2D function; when the texture object bound before glBindTexture is GL_TEXTURE_EXTERNAL_OES, then you can replace the texture object GL_TEXTURE_EXTERNAL_OES bound by glBindTexture with GL_TEXTURE_2D, and replace the texture with the texture corresponding to the last time GL_TEXTURE_2D was bound, and then execute the related operations of the glTexImage2D function. When the operation is completed, restore the state bound before glBindTexture. As shown Figure 4 As shown, if glTexImage2D is the preset texture generation function, the corresponding texture object is GL_TEXTURE_EXTERNAL_OES. Next, check the texture object bound before glBindTexture. When the texture object bound before glBindTexture is GL_TEXTURE_EXTERNAL_OES, directly execute the related operations of the glTexImage2D function; when the texture object bound before glBindTexture is GL_TEXTURE_2D, then you can replace the texture object GL_TEXTURE_2D bound by glBindTexture with GL_TEXTURE_EXTERNAL_OES, and replace the texture with the texture corresponding to the last binding of GL_TEXTURE_EXTERNAL_OES, and then execute the related operations of the glTexImage2D function. When the operation is completed, restore the state of glBindTexture binding.
[0081] In an embodiment of the present application, optionally, after "transmitting parameter data corresponding to the preset texture generation function to the first texture to render the image", the method also includes: restoring the first texture and the first texture object corresponding to the preset texture binding function to the second texture and the second texture object.
[0082] In this embodiment, after rendering the image, the second texture object and the second texture replaced in the preset texture binding function can also be restored. After the code is run, the embodiment of the present application restores the binding state of the preset texture binding function, which does not affect the previous shader code flow and logic.
[0083] In an embodiment of the present application, optionally, the "removing invalid code in the initial shader code to obtain the GLSL ES-based shader code" specifically includes: removing empty character strings, comment codes and declaration information in the initial shader code to obtain the GLSL ES-based shader code.
[0084] Further, as Figure 1 The specific implementation of the method, the embodiment of the present application provides an image rendering device based on GLSL ES, such as Figure 5 As shown, the device comprises:
[0085] A code checking module, used for obtaining a shader code based on GLSL ES, and checking whether a target extension code exists in the shader code;
[0086] A code replacement module, used for removing the target extension code when the target extension code exists in the shader code, and replacing the target texture description code corresponding to the target extension code with a preset general code;
[0087] The code sending module is used to send the replaced shader code and the preset conversion code to the Windows end, so that the Windows end renders the image according to the replaced shader code and the preset conversion code.
[0088] Optionally, the device further comprises:
[0089] A macro definition processing module is used to query the code corresponding to the preset keyword in the shader code before checking whether there is a target extension code in the shader code, use the code as the macro name, and use the preset general code as the macro content to perform macro definition; perform macro definition processing on the shader code and update the shader code.
[0090] Optionally, the device further comprises:
[0091] A monitoring module, used for monitoring the calling instruction of the preset application to the target interface in real time before obtaining the GLSL ES-based shader code, and capturing the target interface at the driver layer when the calling instruction is monitored;
[0092] An integration module, used for acquiring the string text uploaded by the preset application through the target interface, and integrating the string text to obtain an initial shader code based on GLSL ES;
[0093] A removal module is used to remove invalid codes in the initial shader code to obtain the GLSL ES-based shader code.
[0094] Optionally, the removal module is specifically used to:
[0095] The empty string, comment code and declaration information in the initial shader code are removed to obtain the GLSL ES-based shader code.
[0096] Optionally, the device further comprises:
[0097] A receiving module, configured to receive the replaced shader code and the preset conversion code on the Windows side, and determine whether a target texture object exists in the shader code through the preset conversion code;
[0098] A judging module, used for judging whether a first texture object corresponding to a preset texture generating function is the same as a second texture object bound in a preset texture binding function when the target texture object exists;
[0099] A rendering module, used for transmitting parameter data corresponding to the preset texture generation function to the second texture bound to the second texture object, so as to render the image, when the parameters are the same;
[0100] A texture replacement module is used to determine the first texture corresponding to the preset texture binding function when it last bound the first texture object, when they are not the same, replace the second texture and the second texture object corresponding to the preset texture binding function with the first texture and the first texture object, and transmit the parameter data corresponding to the preset texture generation function to the first texture to render the image.
[0101] Optionally, the device further comprises:
[0102] A code recovery module is used to transmit the parameter data corresponding to the preset texture generation function to the first texture, so as to restore the first texture and the first texture object corresponding to the preset texture binding function to the second texture and the second texture object after rendering the image.
[0103] In this embodiment, in addition to the modules corresponding to the Android side, the device may also include modules corresponding to the Windows side, including a receiving module, a judging module, a texture replacement module, a rendering module, and a code recovery module.
[0104] Optionally, the code sending module is specifically used to:
[0105] The replaced shader code and the preset conversion code are packaged, and an identifier corresponding to the Windows end is determined, and based on the identifier, the packaged shader code and the preset conversion code are sent to the Windows end through a target pipeline.
[0106] It should be noted that for other corresponding descriptions of the functional units involved in the image rendering device based on GLSL ES provided in the embodiment of the present application, please refer to Figure 1 to Figure 2 The corresponding description in the method will not be repeated here.
[0107] Based on the above Figure 1 to Figure 2 The method shown in the embodiment of the present application is accordingly provided with a storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned Figure 1 to Figure 2 The GLSLES-based image rendering method shown.
[0108] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0109] Based on the above Figure 1 to Figure 2 The method shown, and Figure 5 In order to achieve the above-mentioned purpose, the embodiment of the present application further provides a computer device, which can be a personal computer, a server, a network device, etc. The computer device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 to Figure 2 The GLSL ES-based image rendering method shown.
[0110] Optionally, the computer device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a Bluetooth interface, a WI-FI interface), etc.
[0111] Those skilled in the art will appreciate that the computer device structure provided in this embodiment does not limit the computer device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0112] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages and saves the hardware and software resources of the computer device, and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the storage medium, and communication with other hardware and software in the physical device.
[0113] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware platforms, or by hardware. The Android end obtains the shader code based on GLSL ES, and checks the obtained shader code to see whether there is a target extension code therein. If the target extension code is found in the shader code after checking, the target extension code can be removed from the shader code. Since the corresponding target texture description code is usually used in the case of the target extension code, the target texture description code can also be replaced by the preset general code. Then, the replaced shader code and the preset conversion code can be sent to the Windows end. After the Windows end receives the replaced shader code and the preset conversion code, the image can be rendered according to the shader code and the preset conversion code. The embodiment of the present application removes the target extension code existing in the shader code based on GLSL ES of the Android end, and replaces the target texture description code, so that the processed shader code can be compatible with the Windows end, so that the image rendering can be performed on the Windows end, which can greatly enhance the player's experience.
[0114] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0115] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A GLSL ES-based image rendering method, characterized in that: include: Obtain a shader code based on GLSL ES, and check whether there is a target extension code in the shader code, wherein the target extension code is an extension code under GLSL ES that is developed for a mobile terminal and cannot be recognized by a Windows terminal; When the target extension code exists in the shader code, the target extension code is removed, and the target texture description code corresponding to the target extension code is replaced with a preset general code, wherein the preset general code is a code that can be recognized by the Windows end; The replaced shader code and the preset conversion code are sent to the Windows side, so that the Windows side renders the image according to the replaced shader code and the preset conversion code. When the replaced shader code is run on the Windows side, if there is code therein that the Windows side cannot recognize, it is replaced by the preset conversion code, so that the Windows side can render the image normally.
2. The method according to claim 1, characterized in that Before checking whether there is a target extension code in the shader code, the method further includes: Searching for a code corresponding to a preset keyword in the shader code, using the code as a macro name, and using the preset general code as macro content for macro definition; Perform macro definition processing on the shader code and update the shader code.
3. The method according to claim 1, characterized in that Before obtaining the GLSL ES-based shader code, the method further includes: Monitor the call instruction of the preset application program to the target interface in real time, and when the call instruction is monitored, capture the target interface at the driver layer; Acquire the string text uploaded by the preset application through the target interface, and integrate the string text to obtain an initial shader code based on GLSL ES; Invalid codes in the initial shader code are removed to obtain the GLSL ES-based shader code.
4. The method according to claim 3, characterized in that The removing of invalid codes in the initial shader code to obtain the GLSL ES-based shader code specifically includes: The empty string, comment code and declaration information in the initial shader code are removed to obtain the GLSLES-based shader code.
5. The method according to claim 1, characterized in that The Windows end renders the image according to the replaced shader code and the preset conversion code, specifically including: The Windows end receives the replaced shader code and the preset conversion code, and determines whether there is a target texture object in the shader code through the preset conversion code; When the target texture object exists, determining whether a first texture object corresponding to a preset texture generation function is the same as a second texture object bound in a preset texture binding function; When they are the same, transmitting the parameter data corresponding to the preset texture generation function to the second texture bound to the second texture object, so as to render the image; When they are not the same, determine the first texture corresponding to the last time the preset texture binding function bound the first texture object, replace the second texture and the second texture object corresponding to the preset texture binding function with the first texture and the first texture object, and transfer the parameter data corresponding to the preset texture generation function to the first texture to render the image.
6. The method according to claim 5, characterized in that After transmitting the parameter data corresponding to the preset texture generation function to the first texture to render the image, the method further includes: The first texture and the first texture object corresponding to the preset texture binding function are restored to the second texture and the second texture object.
7. The method according to claim 1, characterized in that The step of sending the replaced shader code and the preset conversion code to the Windows end specifically includes: The replaced shader code and the preset conversion code are packaged, and an identifier corresponding to the Windows end is determined, and based on the identifier, the packaged shader code and the preset conversion code are sent to the Windows end through a target pipeline.
8. An image rendering device based on GLSL ES, characterized in that: include: A code checking module, used for obtaining a shader code based on GLSL ES, and checking whether there is a target extension code in the shader code, wherein the target extension code is an extension code under GLSL ES developed for a mobile terminal and cannot be recognized by a Windows terminal; A code replacement module, used for removing the target extension code when the target extension code exists in the shader code, and replacing the target texture description code corresponding to the target extension code with a preset general code, wherein the preset general code is a code that can be recognized by the Windows end; A code sending module is used to send the replaced shader code and the preset conversion code to the Windows side, so that the Windows side renders the image according to the replaced shader code and the preset conversion code. When the replaced shader code is run on the Windows side, if there is code therein that the Windows side cannot recognize, it is replaced by the preset conversion code, so that the Windows side can render the image normally.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
