text example updated
This commit is contained in:
parent
422b60662c
commit
7fff2f52ba
18 changed files with 153 additions and 131 deletions
|
@ -126,71 +126,57 @@
|
|||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
||||
PIXI.shaderFragmentSrc = [ "precision mediump float;",
|
||||
"varying vec2 vTextureCoord;",
|
||||
"varying float vColor;",
|
||||
"uniform sampler2D uSampler;",
|
||||
"void main(void) {",
|
||||
"gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));",
|
||||
"gl_FragColor = gl_FragColor * vColor;",
|
||||
"}"];
|
||||
|
||||
PIXI.shaderVertexSrc = [ "attribute vec2 aVertexPosition;",
|
||||
"attribute vec2 aTextureCoord;",
|
||||
"attribute float aColor;",
|
||||
"uniform mat4 uMVMatrix;",
|
||||
"varying vec2 vTextureCoord;",
|
||||
"varying float vColor;",
|
||||
"void main(void) {",
|
||||
"gl_Position = uMVMatrix * vec4(aVertexPosition, 1.0, 1.0);",
|
||||
"vTextureCoord = aTextureCoord;",
|
||||
"vColor = aColor;",
|
||||
"}"]
|
||||
PIXI.shaderFragmentSrc = [
|
||||
"precision mediump float;",
|
||||
"varying vec2 vTextureCoord;",
|
||||
"varying float vColor;",
|
||||
"uniform sampler2D uSampler;",
|
||||
"void main(void) {",
|
||||
"gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));",
|
||||
"gl_FragColor = gl_FragColor * vColor;",
|
||||
"}"
|
||||
];
|
||||
|
||||
PIXI.shaderVertexSrc = [
|
||||
"attribute vec2 aVertexPosition;",
|
||||
"attribute vec2 aTextureCoord;",
|
||||
"attribute float aColor;",
|
||||
"uniform mat4 uMVMatrix;",
|
||||
"varying vec2 vTextureCoord;",
|
||||
"varying float vColor;",
|
||||
"void main(void) {",
|
||||
"gl_Position = uMVMatrix * vec4(aVertexPosition, 1.0, 1.0);",
|
||||
"vTextureCoord = aTextureCoord;",
|
||||
"vColor = aColor;",
|
||||
"}"
|
||||
];
|
||||
|
||||
PIXI.CompileVertexShader = function(gl, shaderSrc)
|
||||
{
|
||||
var src = "";
|
||||
|
||||
for (var i=0; i < shaderSrc.length; i++) {
|
||||
src += shaderSrc[i];
|
||||
};
|
||||
|
||||
var shader;
|
||||
shader = gl.createShader(gl.VERTEX_SHADER);
|
||||
|
||||
gl.shaderSource(shader, src);
|
||||
gl.compileShader(shader);
|
||||
|
||||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
||||
alert(gl.getShaderInfoLog(shader));
|
||||
return null;
|
||||
}
|
||||
|
||||
return shader;
|
||||
return PIXI._CompileShader(gl, shaderSrc, gl.VERTEX_SHADER);
|
||||
}
|
||||
|
||||
PIXI.CompileFragmentShader = function(gl, shaderSrc)
|
||||
{
|
||||
var src = "";
|
||||
|
||||
for (var i=0; i < shaderSrc.length; i++) {
|
||||
src += shaderSrc[i];
|
||||
};
|
||||
|
||||
var shader;
|
||||
shader = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
|
||||
gl.shaderSource(shader, src);
|
||||
gl.compileShader(shader);
|
||||
|
||||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
||||
alert(gl.getShaderInfoLog(shader));
|
||||
return null;
|
||||
}
|
||||
|
||||
return shader;
|
||||
return PIXI._CompileShader(gl, shaderSrc, gl.FRAGMENT_SHADER);
|
||||
}
|
||||
|
||||
PIXI._CompileShader = function(gl, shaderSrc, shaderType)
|
||||
{
|
||||
var src = shaderSrc.join("\n");
|
||||
var shader = gl.createShader(shaderType);
|
||||
gl.shaderSource(shader, src);
|
||||
gl.compileShader(shader);
|
||||
|
||||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
||||
alert(gl.getShaderInfoLog(shader));
|
||||
return null;
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue