[ create a new paste ] login | about

Link: http://codepad.org/4zviSmWz    [ raw code | output | fork ]

C, pasted on Dec 26:
<html>

<head>
<title>任意半径圆</title>
<style type = "text/css">
#divfilter
{
	background-color:#FF0000;
	width:500px;
	height:500px;
}

</style>
</head>

<body>
<div id = "divfilter">
<canvas id="drawView"style="width: 100%; height: 100%"></canvas>
</div>
<script type = "text/javascript">
var webgl = null;

var programObject = null;
var v4PositionIndex;

function webglInit() {
    var myCanvasObject = document.getElementById("drawView");
    var myDivObject = document.getElementById("divfilter");
    webgl = myCanvasObject.getContext("experimental-webgl");
    if (webgl == null) alert("你的浏览器不支持webgl");
    webgl.viewport(0, 0, myDivObject.clientWidth, myDivObject.clientHeight);
}

var vertexShaderObject;
var fragmentShaderObject;
function shaderInitWithVertexAndFragmentShader(vsh, fsh) {
    webgl.shaderSource(vertexShaderObject, vsh);
    webgl.shaderSource(fragmentShaderObject, fsh);
    webgl.compileShader(vertexShaderObject);
if(vertexShaderObject == null) alert("vertexshader compile error");
    webgl.compileShader(fragmentShaderObject);
if(fragmentShaderObject == null) alert("fragmentShader compileError");
}
function initShaderProgram(positionName) {
    programObject = webgl.createProgram();
    webgl.attachShader(programObject, vertexShaderObject);
    webgl.attachShader(programObject, fragmentShaderObject);
    webgl.bindAttribLocation(programObject, v4PositionIndex, positionName);
    webgl.linkProgram(programObject);
    if (!webgl.getProgramParameter(programObject, webgl.LINK_STATUS)) {
        alert(webgl.getProgramInfoLog(programObject));
        return;
    }
    webgl.useProgram(programObject);
}
function renderWebGL(vertices, vSize, vLen, vsh, fsh, positionName) {
    webglInit();
    shaderInitWithVertexAndFragmentShader(vsh, fsh);
    initShaderProgram(positionName);
    var buffer = webgl.createBuffer();
    webgl.bindBuffer(webgl.ARRAY_BUFFER, buffer);
    webgl.bufferData(webgl.ARRAY_BUFFER, new Float32Array(vertices), webgl.STATIC_DRAW);
    webgl.enableVertexAttribArray(v4PositionIndex);
    webgl.vertexAttribPointer(v4PositionIndex, vSize, webgl.FLOAT, false, 0, 0);
    webgl.clearColor(0.0, 0.0, 0.0, 1.0);
    webgl.clear(webgl.COLOR_BUFFER_BIT);
    webgl.drawArrays(webgl.TRIANGLE_STRIP, 0, vLen);
}
function run()
{
    var vertices = 
    [
        1.0, 1.0,
        1.0, -1.0,
        -1.0, 1.0,
        -1.0, -1.0
    ];
    var vsh = 
        "precision mediump float;" + 
        "attribute vec4 position;" +
        "varying vec2 textureCoordinate;" +
        "void main()" +
        "{" +
        "    gl_Position = position;" +
        "    textureCoordinate = position.xy;" +
        "}";
    var fsh = 
        "precision mediump float;" +
        "varying vec2 textureCoordinate;" +
        "void main()" +
        "{" +
        "    if(length(textureCoordinate)<"+Math.random()*10.0f+")" +
        "        gl_FragColor = vec4(textureCoordinate + 0.5, 0.0, 1.0);" +
        "    else gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);" +
        "}";    
    renderWebGL(vertices, 2, 4, vsh, fsh, "position");
}
</script>
<input type = "button" value = "Render" onclick = "run()"/>
</body>
</html>


Output:
Line 1: error: expected identifier or '(' before '<' token
Line 4: error: stray '\344' in program
Line 4: error: stray '\273' in program
Line 4: error: stray '\273' in program
Line 4: error: stray '\346' in program
Line 4: error: stray '\204' in program
Line 4: error: stray '\217' in program
Line 4: error: stray '\345' in program
Line 4: error: stray '\215' in program
Line 4: error: stray '\212' in program
Line 4: error: stray '\345' in program
Line 4: error: stray '\276' in program
Line 4: error: stray '\204' in program
Line 4: error: stray '\345' in program
Line 4: error: stray '\234' in program
Line 4: error: stray '\206' in program
Line 1: error: invalid preprocessing directive #divfilter
Line 8: error: stray '#' in program
Line 7: error: invalid suffix "px" on integer constant
Line 8: error: invalid suffix "px" on integer constant
Line 13: error: expected identifier or '(' before '<' token
Line 23: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'programObject'
Line 24: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'v4PositionIndex'
Line 26: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'webglInit'
Line 34: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'vertexShaderObject'
Line 35: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fragmentShaderObject'
Line 36: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'shaderInitWithVertexAndFragmentShader'
Line 44: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'initShaderProgram'
Line 56: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'renderWebGL'
Line 69: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'run'
Line 98: error: expected identifier or '(' before '<' token


Create a new paste based on this one


Comments: