Embodiment
In order that those skilled in the art more fully understand the technical scheme in the application, it is real below in conjunction with the application
The accompanying drawing in example is applied, the technical scheme in the embodiment of the present application is clearly and completely described, it is clear that described implementation
Example only some embodiments of the present application, rather than whole embodiments.Based on the embodiment in the application, this area is common
The every other embodiment that technical staff is obtained under the premise of creative work is not made, should all belong to the application protection
Scope.
Fig. 1 is a kind of a kind of herein described method flow diagram of embodiment of page coloring device code debugging method.Although
This application provides such as following embodiments or method operating procedure shown in the drawings or apparatus structure, but based on conventional or need not
Performing creative labour can include operating procedure or module less after more or part merges in methods described or device
Unit.In the step of necessary causality is not present in logicality or structure, the execution sequence of these steps or the mould of device
Block structure is not limited to the embodiment of the present application or execution sequence shown in the drawings or modular structure.Described method or modular structure
When device or end product in practice is applied, it can be carried out according to embodiment or method shown in the drawings or modular structure
Order perform or it is parallel perform (environment of such as parallel processor or multiple threads, even including distributed treatment
Implementation environment).
The application, can to solve in a kind of embodiment that the problem of prior art web terminal can not debug tinter provides
To write simulation tinter using certain Programming language in advance, the simulation tinter is to draw 3D rendering according to the page to use
Former tinter running environment simulation generation.Described simulation tinter can be raw during web terminal tinter is debugged
Into generation is compiled when project, tinter can be simulated with load operating when needing to carry out page coloring device code debugging.This
Apply for that the Pages Design language for the adjustable that the simulation tinter of embodiment can be used using operating personnel writes generation, therefore
The tinter of simulation can be run in debugging, it is possible to the code run in former tinter is carried out in simulation tinter
Debugging.Specific one kind practices scene as described in Figure 1, a kind of page coloring device code debugging method that the application is provided
A kind of embodiment can include:
S1:When triggering the shader code debugging of the page, the simulation tinter of the former tinter of loading, the simulation tinter
It is configured to using default Programming language and simulates the running environment compiling generation of former tinter;
S2:In the simulation tinter, the shader code of the page is debugged;
S3:Shader code after being debugged in the simulation tinter is translated into according to default transformation rule described
The corresponding character string of former tinter, and the character string is embedded into the former tinter corresponding code position.
Described tinter, is that one kind is transported on GPU (Graphics Processing Unit, GPU, image processor)
Capable program, it can be understood as the instruction and data operated in video card.The tinter that general page 3D graphical developments are used leads to
Often include vertex shader and piece member tinter.The main task of vertex shader is the coordinate for receiving three dimensions midpoint, will
It is processed as the coordinate in page two-dimensional space and output;The main task of piece member tinter is to needing on screen to be processed
Each pixel exports a color value.Vertex shader is mainly reception attribute variables and uniform variables.
Attribute variable storages the data on putting itself, and it is mainly position a little.The data of uniform variable storages can
For helping tinter to complete task, in other words, tinter is to need uniform variables and generally do not handle them.Top
Point Coloring device, which needs to export varying variables, gives piece member tinter.It is general, it is described in webGL tinters
Attribute, uniform, varying are mainly the effect for describing the variable in tinter.
The application is specifically carried out using webGL tinters in the embodiment application scenarios of 3D rendering exploitation design, described
Former tinter be webGL tinters.Described simulation tinter can write generation using a variety of Programming language.By
In webGL be mainly used in for HTML5Canvas provide hardware 3D accelerate render, such web developer just can be by system
Video card comes displaying 3D scenes and model, and can create navigation and the data visualization of complexity more glibly in browser.Therefore,
Tinter is simulated described in a kind of embodiment can be using a kind of JS (Javascript, JS, script) written in code
Into, be mainly used in the debugging of the page 3D rendering processing.Therefore, in a kind of embodiment that the application is provided,
S101:The former tinter is webGL tinters, and the simulation tinter is using the generation of JS written in code.
Fig. 2 is the data flow schematic diagram between tinter when the application simulates tinter using JS written in code.Such as Fig. 2
It is shown, in the present embodiment application scenarios, during WebGL graphings, using two kinds of tinters:Vertex shader and piece member coloring
Device.As shown in FIG., vertex shader can read vertex information from caching, and javascript codes set uniform to become
Amount and attribute variables.Vertex shader reads attribute variables and uniform variables, exports varying variables, defeated
The varying variables gone out can carry out mathematic interpolation automatically according to summit;Piece member tinter can according to uniform variables and
Varying variables calculate the color for obtaining current point.
When the embodiment of the present application writes tinter using Javascript codes, a series of conversion rule can be pre-established
Javascript codes are then realized to the conversion of former tinter character string, can compatible original webGL and tinter variable lead to
Letter, realizes the mathematic interpolation of varying variables.A specific example is as follows:
The code of former tinter:
The javascript codes simulated in tinter write in the present embodiment using JS:
The shader code of processing is debugged in simulation tinter to be generated according to default transformation rule translation before
The corresponding character string of former tinter that page 3D is started with.Code turns between specific simulation tinter and former tinter
Change rule and communication mode, function loading call etc. and can apply according to the default Programming language of use and specifically ring
Border design needs to set., can be described in a kind of a kind of embodiment for page coloring device code debugging method that the application is provided
Default transformation rule is configured to, and can be included:
S301:Shader code after debugging is translated into the character string of former tinter according to the prefix information of variable, become
Communication execution and call function between amount is identical with former tinter.
In the present embodiment application scenarios, the javascript code translations debugged in simulation tinter into WebGL
During color device code, it can only need to be translated according to the prefix of variable.For example:
Var vec4_a_Position are translated into:attribute vect4a_Position
Var vec4_v_Color translate into varying vec4v_Color;
Then, open debugging when, be switched to the simulation that the embodiment of the present application is write webGL environment (simulate
Color device), the communication of processing attribute variables and uniform variables, such as:
WebGL environment:
Var gl=initContext (' webgl');
Debug environment:
Var gl=initContext (' debug ');
The communication mode of attribute variables and uniform variables and call/loading function is constant:
Var u_xformMatrix=gl.getUniformLocation (gl.program, ' u_xformMatrix');
gl.uniformMatrix4fv(u_matrix,false,projMatrix.elements);
In actual job, the different code running environment of switching can be realized by the call parameters of user, such as
Operating personnel writes the shader code of completion, shader code can be locally directly compiled into webGL code, is adjusting
Determine loading according to the parameter of call by passing during examination is simulation tinter or original webGL tinters to run tinter generation
Code.And the problem of environment changing described above, can add corresponding in code at the beginning in some computer design languages
Statement description.As in the present embodiment application scenarios, tinter is simulated using JS written in code, " debug can be defined as herein
Environment " (debugging enironment), shown in following code:
//webGL environment:
Var gl=initContext (' webgl');
//debug environment:
Var gl=initContext (' debug ');
2 files of generation can be compiled when page debugging business item is generated, one is JS versions, and one is
WebGL versions.The different mode that can be switched according to user loads corresponding file.Therefore, a kind of page that the application is provided
In another implementation of shader code adjustment method, it can also be wrapped in triggering shader code debugging foregoing description method
Include:
S0:The code file of the former tinter of compiling generation and the code file of simulation tinter, the generation of the former tinter
The code file of code file and simulation tinter is provided with corresponding startup call parameters;
Accordingly, the simulation tinter of the former tinter of loading includes basis during the shader code debugging of the triggering page
Incoming Start-up and Adjustment parameter determines the simulation tinter of the former tinter of loading.
Fig. 3 is a kind of method flow signal of another implementation for page coloring device code debugging method that the application is provided
Figure.It is specific to implement in processing procedure, such as in the above-mentioned application scenarios for defining " debug environment " (debugging enironment), when with
Family is browser generation wbgl objects toward what is called inside initContext functions during transmission ' webgl '.When incoming is
During ' debug ' parameter, return be the application write simulation tinter in webgl objects.Image rendering processing below
Process can then give the JS codes in simulation tinter to handle.User can adjust according to the image result of simulation tinter
Parameter, is debugged to the shader code of the page.Certainly, webgl pairs is carried out in the simulation tinter write using the application
JS codes during as debugging can be handled by CPU (Central Processing Unit, central processing unit).After CPU debugging
Shader code the character string of the former tinter needed for GPU is performed is translated into according still further to default transformation rule before, and can
The corresponding code position of former tinter is embedded into the tinter after these are debugged.Specific code position can also root
It is determined according to incoming parameter or the debugging node of setting etc..
Further, coloured by shader code debugging and transition translation that the page is carried out in simulation tinter into original
After the character string that device needs, the shader code including the corresponding character string of former tinter after the conversion can be loaded into
Run in GPU.The debugging of shader code is such as carried out in debug environment by parameter call, after the completion of debugging, in webGL
The character string that automatically can be needed this section of JS code translation into former tinter under environment, then will include character after these debugging
The former shader code of string is loaded into GPU and run, the page 3D operational effects checked after debugging.Fig. 4 is the application offer
A kind of another embodiment of page coloring device code debugging method method flow schematic diagram, as shown in figure 4, methods described is also
It can include:
S4:The shader code of the page in the former tinter is loaded into graphics processor.
So, the embodiment of the present application can determine it is the webGL rings for starting the simulation write by different incoming parameters
Border or original webGL running environment., can be normally right using JS codes in the simulation tinter of offer when needing debugging
Shader code is debugged.The character string for needing the JS code translation members tinter of these debugging during without debugging,
And can be embedded into real webGL codes, run for GPU.Web terminal can be effectively solved using the embodiment of the present application scheme
The tinter debugging problem during processing of the 3D pages can not be debugged, tinter debugging efficiency and page development effect is effectively improved.
The application can provide simulation tinter when web terminal is debugged in page coloring device, and operating personnel can be in simulation
In tinter carry out shader code debugging, then can by the Content Transformation of debugging into real webGL tinters character string,
It is embedded into real webGL shader codes and runs, realizes the debugging of original webGL tinters.Present application addresses web terminal without
The problem of method debugs tinter, and effect is changed with performance, tinter debugging efficiency can be significantly improved, following web terminal is entered
Row 3D exploitations, VR/AR exploitations provide strong technical support.
Based on a kind of page coloring device adjustment method described herein, the application also provides a kind of page coloring device debugging
Device.Described device can be included using that can enter the simulation tinter of edlin debugging in CPU one end, to realize on web
Carried out during 3D graphical developments the debugging of webGL shader codes.Fig. 5 is a kind of page coloring device debugging that the application is provided
A kind of modular structure schematic diagram of embodiment of device, as shown in figure 5, described device can include:
Load-on module 101 is debugged, be can be used for when triggering the shader code debugging of the page, the mould of the former tinter of loading
Intend tinter, the simulation tinter is configured to using default Programming language and simulates the running environment volume of former tinter
Translate generation;
Processing module 102 is debugged, can be used in the simulation tinter, the shader code of the page is adjusted
Examination;
Code conversion module 103, can be used for the shader code after being debugged in the simulation tinter according to pre-
If transformation rule translate into the corresponding character string of the former tinter, and the character string is embedded into the former tinter
Corresponding code position.
The embodiment of the present application provides a kind of page coloring device code debugging device, can use the JS of such as adjustable programming
Written in code simulates tinter, can together be worked with former tinter during commissioning test, is then carried out in simulation tinter former
The debugging of shader code.Then former tinter can be embedded into by common JS code translations into the character string of former tinter
In corresponding code, the debugging of original webGL tinters is realized.The problem of tinter can not being debugged present application addresses web terminal, and
And effect is changed with performance, tinter debugging effect and debugging efficiency can be significantly improved, 3D exploitations, VR/ are carried out to following web terminal
AR exploitations provide strong technical support.
Former tinter described herein is primarily referred to as that in page development running code debugging can not be carried out
Tinter, and the Programming language that described simulation tinter, which can then use local cpu, to be debugged with direct compilation is write
Form.It is described in the tinter used for the 3D drawing marks webGL of targeted mainstream, a kind of embodiment that the application is provided
Former tinter is webGL tinters, and the simulation tinter is using the generation of JS written in code.Certainly, as preceding method is implemented
Example description is described, and in another embodiment of herein described building, the default transformation rule can include:According to variable
The communication that prefix information is translated into the shader code after debugging between the character string of former tinter, variable performs and called letter
Number is identical with former tinter.
In actual job, the different code running environment of switching can be realized by the call parameters of user, such as
Operating personnel writes the shader code of completion, shader code can be locally directly compiled into webGL code, is adjusting
Determine loading according to the parameter of call by passing during examination is simulation tinter or original webGL tinters to run tinter generation
Code.And the problem of environment changing described above, can add corresponding in code at the beginning in some computer design languages
Statement description.In specific implementation process, 2 files of generation can be compiled, one is JS versions, and one is webGL versions.Can
Corresponding file is loaded with the different mode switched according to user.Fig. 6 is a kind of page coloring device debugging dress that the application is provided
A kind of modular structure schematic diagram of embodiment is put, as shown in fig. 6, described device can also include:
Collector 100, can be used for the code file of the former tinter of compiling generation and the code file of simulation tinter,
The code file of the former tinter and the code file of simulation tinter are provided with corresponding startup call parameters;
Accordingly, the debugging load-on module 101 former tinter of loading when triggering the shader code debugging of the page
Simulate the simulation tinter that tinter includes determining the former tinter of loading according to incoming Start-up and Adjustment parameter.
Further, coloured by shader code debugging and transition translation that the page is carried out in simulation tinter into original
After the character string that device needs, the shader code including the corresponding character string of former tinter after the conversion can be loaded into
Run in GPU.The debugging of shader code is such as carried out in debug environment by parameter call, after the completion of debugging, in webGL
The character string that automatically can be needed this section of JS code translation into former tinter under environment, then will include character after these debugging
The former shader code of string is loaded into GPU and run, the page 3D operational effects checked after debugging.Fig. 7 is the application offer
A kind of a kind of modular structure schematic diagram of embodiment of page coloring device debugging apparatus, as shown in fig. 7, described device can also be wrapped
Include:
Code load-on module 104, can be used for the shader code of the page in the former tinter being loaded at image
Manage in device and run.
Fig. 8 is that a kind of implementation framework of the method or apparatus scheme progress page 3D graphic plottings provided using the application is shown
It is intended to.As shown in figure 8, the page coloring device code debugging method of the embodiment of the present application offer, device, can be provided using for example
The simulation tinter of the JS codes of adjustable programming, can together work with former tinter during commissioning test, then simulate
The debugging of former shader code is carried out in color device.Without debugging when can by common JS code translations into former tinter word
Symbol string, is then embedded into the corresponding code of former tinter.The application can provide mould in page coloring device when web terminal is debugged
Intend tinter, operating personnel can debug row shader code in simulation tinter, then can be by the Content Transformation of debugging
Into real webGL tinters character string, it is embedded into real webGL shader codes and runs, realizes original webGL tinters
Debugging.The problem of tinter can not being debugged present application addresses web terminal, and effect is changed with performance, it can significantly improve
Color device debugging efficiency, 3D exploitations, VR/AR exploitations are carried out to following web terminal and provides strong technical support.
Although being mentioned in teachings herein using the communication between JS written in code simulation tinter, tinter each variable
And the page of the transformation rule of code, parameter call mode or the like is set between numerical computations, simulation tinter and former tinter
The description of language, regular definition, interacting message etc. is counted, still, the application is not limited to meet the standard page in the industry
Situation described by design language, message transmission, parameter call or embodiment.Some professional standards use self-defined mode
Or embodiment amended slightly can also realize that above-described embodiment is identical, be equal or phase on the practice processes of embodiment description
The implementation result closely or after deformation being anticipated that.Using the implementation of the acquisitions such as judgement, the processing mode after these modifications or deformation
Within the scope of example, the optional embodiment that still may belong to the application.
Although this application provides the method operating procedure as described in embodiment or flow chart, based on conventional or noninvasive
The means for the property made can include more or less operating procedures.The step of being enumerated in embodiment order is only numerous steps
A kind of mode in execution sequence, unique execution sequence is not represented., can be with when device in practice or end product execution
Performed according to embodiment or method shown in the drawings order or parallel execution (such as parallel processor or multiple threads
Environment, even distributed data processing environment).Term " comprising ", "comprising" or its any other variant are intended to
Nonexcludability is included, so that process, method, product or equipment including a series of key elements not only will including those
Element, but also other key elements including being not expressly set out, or also include being this process, method, product or equipment
Intrinsic key element.In the absence of more restrictions, be not precluded from the process including the key element, method, product or
Also there are other identical or equivalent elements in person's equipment.
Unit, device or module that above-described embodiment is illustrated etc., can specifically be realized by computer chip or entity, or
Realized by the product with certain function.For convenience of description, describe to be divided into various modules point during apparatus above with function
Do not describe.Certainly, when implementing the application can the function of each module in same or multiple softwares and/or hardware it is real
It is existing, the module for realizing same function can also be realized by the combination of multiple submodule or subelement etc..Dress described above
It is only schematical to put embodiment, for example, the division of the unit, only a kind of division of logic function, when actually realizing
There can be other dividing mode, such as multiple units or component can combine or be desirably integrated into another system, or one
A little features can be ignored, or not perform.Another, shown or discussed communication connection each other can be connect by some
Mouthful, the INDIRECT COUPLING or communication connection of device or unit can be electrical, machinery or other forms.
It is also known in the art that in addition to realizing controller in pure computer readable program code mode, it is complete
Controller can be caused with gate, switch, application specific integrated circuit, programmable by the way that method and step is carried out into programming in logic entirely
Logic controller realizes identical function with the form of embedded microcontroller etc..Therefore this controller is considered one kind
Hardware component, and the device for realizing various functions included to its inside can also be considered as the structure in hardware component.Or
Person even, not only can be able to will be the software module of implementation method but also can be hardware for realizing that the device of various functions is considered as
Structure in part.
The application can be described in the general context of computer executable instructions, such as program
Module.Usually, program module includes performing particular task or realizes routine, program, object, the group of particular abstract data type
Part, data structure, class etc..The application can also be put into practice in a distributed computing environment, in these DCEs,
Task is performed by the remote processing devices connected by communication network.In a distributed computing environment, program module can
With positioned at including in the local and remote computer-readable storage medium including storage device.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can
Realized by the mode of software plus required general hardware platform.Understood based on such, the technical scheme essence of the application
On the part that is contributed in other words to prior art can be embodied in the form of software product, the computer software product
It can be stored in storage medium, such as ROM/RAM, magnetic disc, CD, including some instructions are to cause a computer equipment
(can be personal computer, mobile terminal, server, or network equipment etc.) performs each embodiment of the application or implementation
Method described in some parts of example.
Each embodiment in this specification is described by the way of progressive, same or analogous portion between each embodiment
Divide mutually referring to what each embodiment was stressed is the difference with other embodiment.The application can be used for crowd
In more general or special purpose computing system environments or configuration.For example:Personal computer, server computer, handheld device or
Portable set, laptop device, multicomputer system, the system based on microprocessor, set top box, programmable electronics are set
Standby, network PC, minicom, DCE of mainframe computer including any of the above system or equipment etc..
Although depicting the application by embodiment, it will be appreciated by the skilled addressee that the application have it is many deformation and
Change is without departing from spirit herein, it is desirable to which appended claim includes these deformations and changed without departing from the application's
Spirit.