加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
global.d.ts 2.77 KB
一键复制 编辑 原始数据 按行查看 历史
darkpalm 提交于 2018-05-19 14:10 . 溶解特效
declare module cc {
/**
* 实现WebGL program的类,用来做shader编程
*/
export class GLProgram{
/**
* 实现WebGL program的类,用来做shader编程
*/
constructor();
/**
* 使用顶点shader字符串和片段shader字符串初始化cc.GLProgram
* @param vertShaderStr 顶点shader字符串
* @param fragShaderStr 片段shader字符串
*/
initWithString(vertShaderStr: string, fragShaderStr: string): boolean;
/**
* It will add a new attribute to the shader
* @param attributeName
* @param index
*/
addAttribute(attributeName: number, index: number);
/**
* Initializes the cc.GLProgram with a vertex and fragment with string
* @param vertShaderStr
* @param fragShaderStr
*/
initWithVertexShaderByteArray(vertShaderStr: string, fragShaderStr: string):boolean;
/**
* 连接 glprogram
*/
link(): boolean;
/**
* 这个函数创建4个统一变量即uniform
* cc.macro.UNIFORM_PMATRIX
* cc.macro.UNIFORM_MVMATRIX
* cc.macro.UNIFORM_MVPMATRIX
* cc.macro.UNIFORM_SAMPLER
*/
updateUniforms();
/**
* it will call gl.useProgram()
*/
use();
/**
* calls retrieves the named uniform location for this shader program.
* @param name
*/
getUniformLocationForName(name: string): number;
/**
* calls glUniform1f only if the values are different than the previous call for this same shader program.
* @param location
* @param f1
*/
setUniformLocationWith1f(location, f1);
/**
* calls glUniform2f only if the values are different than the previous call for this same shader program.
* @param location
* @param f1
* @param f2
*/
setUniformLocationWith2f(location, f1, f2);
/**
* calls glUniform1i only if the values are different than the previous call for this same shader program.
* @param location WebGLUniformLocation
* @param i1
*/
setUniformLocationWith1i(location:WebGLUniformLocation, i1);
}
export class GLProgramState{
static getOrCreateWithGLProgram(program:GLProgram):any;
}
export class gl{
/**
* If the texture is not already bound to a given unit, it binds it.<br/>If cc.macro.ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly.
* @param textureUnit
* @param texture
*/
static bindTexture2DN(textureUnit:number, texture:Texture2D);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化