Learning WebGL
    WebGL
     nakamura001
Lesson 1 URL
http://learningwebgl.com/blog/?p=28
https://github.com/gpjt/webgl-lessons
https://sites.google.com/site/hackthewebgl/learning-
         webglhon-yaku/the-lessons/lesson-1
HTML
<body onload="webGLStart();">
  <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt;
Back to Lesson 1</a><br />

  <canvas id="lesson01-canvas" style="border: none;"
width="500" height="500"></canvas>

  <br/>
  <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt;
Back to Lesson 1</a><br />
</body>
HTML
<body onload="webGLStart();">
  <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt;
Back to Lesson 1</a><br />

  <canvas id="lesson01-canvas" style="border: none;"
width="500" height="500"></canvas>

  <br/>
  <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt;
Back to Lesson 1</a><br />
</body>
HTML
<body onload="webGLStart();">
  <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt;
Back to Lesson 1</a><br />

  <canvas id="lesson01-canvas" style="border: none;"
width="500" height="500"></canvas>

  <br/>
  <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt;
Back to Lesson 1</a><br />
</body>
JavaScript
  function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
gl.
OpenGL ES              WebGL


    (※Learning WebGL      )
gl.
OpenGL ES              WebGL


    (※Learning WebGL       )



         gl.clearColor()
                 ↓
         glClearColor()
gl.
    OpenGL ES              WebGL


        (※Learning WebGL      )



gl.clearColor()
        ↓
glClearColor()
glTranslate()

                    glTranslated()

                    glTranslatef()

void glTranslated(GLdouble x, GLdouble y, GLdouble z)
void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
OpenGL

          OpenGL    OpenGL ES




http://d.hatena.ne.jp/nakamura001/20080918/1221738923
initGL()
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
var gl;
function initGL(canvas) {
  try {
    gl = canvas.getContext("experimental-webgl");
    gl.viewportWidth = canvas.width;
    gl.viewportHeight = canvas.height;
  } catch(e) {
  }
  if (!gl) {
    alert("Could not initialise WebGL, sorry :-(");
  }
}
initBuffers()
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
var triangleVertexPositionBuffer;
  var squareVertexPositionBuffer;
  function initBuffers() {
    triangleVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER,
triangleVertexPositionBuffer);
    var vertices = [
         0.0, 1.0, 0.0,
        -1.0, -1.0, 0.0,
         1.0, -1.0, 0.0
    ];
(X,Y,Z)   3
var triangleVertexPositionBuffer;
  var squareVertexPositionBuffer;
  function initBuffers() {
    triangleVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER,
triangleVertexPositionBuffer);
    var vertices = [
         0.0, 1.0, 0.0,
        -1.0, -1.0, 0.0,
         1.0, -1.0, 0.0
    ];
var triangleVertexPositionBuffer;
  var squareVertexPositionBuffer;
  function initBuffers() {
    triangleVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER,
triangleVertexPositionBuffer);
    var vertices = [
         0.0, 1.0, 0.0,
        -1.0, -1.0, 0.0,
         1.0, -1.0, 0.0
    ];
var triangleVertexPositionBuffer;
  var squareVertexPositionBuffer;
  function initBuffers() {
    triangleVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER,
triangleVertexPositionBuffer);
    var vertices = [
         0.0, 1.0, 0.0,
        -1.0, -1.0, 0.0,
         1.0, -1.0, 0.0
    ];
var triangleVertexPositionBuffer;
  var squareVertexPositionBuffer;
  function initBuffers() {
    triangleVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER,
triangleVertexPositionBuffer);
    var vertices = [
         0.0, 1.0, 0.0,
        -1.0, -1.0, 0.0,
         1.0, -1.0, 0.0
    ];
var triangleVertexPositionBuffer;
  var squareVertexPositionBuffer;
  function initBuffers() {
    triangleVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER,
triangleVertexPositionBuffer);
    var vertices = [
         0.0, 1.0, 0.0,
        -1.0, -1.0, 0.0,
         1.0, -1.0, 0.0
    ];
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array
(vertices), gl.STATIC_DRAW);
    triangleVertexPositionBuffer.itemSize = 3;
    triangleVertexPositionBuffer.numItems = 3;
triangleVertexPositionBuffer.itemSize = 3;
    triangleVertexPositionBuffer.numItems = 3;


                          .itemSize     .numItems
                                         (           )
※OpenGL ES




※            gl.vertexAttribPointer()    gl.drawArrays()
squareVertexPositionBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER,
squareVertexPositionBuffer);
    vertices = [
         1.0, 1.0, 0.0,
        -1.0, 1.0, 0.0,
         1.0, -1.0, 0.0,
        -1.0, -1.0, 0.0
    ];
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array
(vertices), gl.STATIC_DRAW);
    squareVertexPositionBuffer.itemSize = 3;
    squareVertexPositionBuffer.numItems = 4;
drawScene()
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
function drawScene() {
    gl.viewport(0, 0, gl.viewportWidth,
gl.viewportHeight);
    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
•


•       (   )   DirectX
    Z
perspective(45, gl.viewportWidth / gl.viewportHeight,
0.1, 100.0);




                      gluPerspective
loadIdentity();

mvTranslate([-1.5, 0.0, -7.0]);
loadIdentity();

mvTranslate([-1.5, 0.0, -7.0]);
                                  glTranslate
gl.drawArrays(gl.TRIANGLES, 0,
triangleVertexPositionBuffer.numItems);
gl.drawArrays(gl.TRIANGLES, 0,
triangleVertexPositionBuffer.numItems);




      ※                                   1
                          1
gl.drawArrays(gl.TRIANGLE_STRIP, 0,
squareVertexPositionBuffer.numItems);
gl.drawArrays(gl.TRIANGLE_STRIP, 0,
squareVertexPositionBuffer.numItems);




            2      +      1
gl.drawArrays(gl.TRIANGLE_STRIP, 0,
         squareVertexPositionBuffer.numItems);




                     2      +      1


                 GL_TRIANGLE_STRIP
http://d.hatena.ne.jp/nakamura001/20081231/1230719279
initShaders()
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
function webGLStart() {
    var canvas = document.getElementById("lesson01-
canvas");
    initGL(canvas);
    initShaders();
    initBuffers();

      gl.clearColor(0.0, 0.0, 0.0, 1.0);

      gl.clearDepth(1.0);

      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);

      setInterval(drawScene, 15);
  }
var shaderProgram;
function initShaders() {
  var fragmentShader = getShader(gl, "shader-fs");
  var vertexShader = getShader(gl, "shader-vs");

  shaderProgram = gl.createProgram();
GLSL(OpenGL Shading Language)



   http://d.hatena.ne.jp/nakamura001/20090927/1254058173
<script id="shader-fs" type="x-shader/x-fragment">
  #ifdef GL_ES
  precision highp float;
  #endif

  void main(void) {
    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
  }
</script>
<script id="shader-fs" type="x-shader/x-fragment">
  #ifdef GL_ES
  precision highp float;
  #endif

  void main(void) {
    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
  }
</script>
triangleVertexPositionBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER,
    triangleVertexPositionBuffer);
        var vertices = [
             0.0, 1.0, 0.0,
            -1.0, -1.0, 0.0,
             1.0, -1.0, 0.0
        ];
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array
    (vertices), gl.STATIC_DRAW);
        triangleVertexPositionBuffer.itemSize = 3;
        triangleVertexPositionBuffer.numItems = 3;

※              (gl.TRIANGLE_STRIP)
triangleVertexPositionBuffer = gl.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER,
    triangleVertexPositionBuffer);
        var vertices = [
             0.0, 1.0, 0.0,
            -1.0, -1.0, 0.0,
             1.0, -1.0, 0.0
        ];
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array
    (vertices), gl.STATIC_DRAW);
        triangleVertexPositionBuffer.itemSize = 3;
        triangleVertexPositionBuffer.numItems = 3;

※              (gl.TRIANGLE_STRIP)
•


•
<script type="text/javascript" src="sylvester.js"></
script>
<script type="text/javascript" src="glUtils.js"></script>




     Sylvester
     http://sylvester.jcoglan.com/
     ※sylvester.src.js

Learning WebGLで学ぶWebGL入門

  • 1.
    Learning WebGL WebGL nakamura001
  • 3.
  • 4.
  • 5.
  • 8.
    HTML <body onload="webGLStart();"> <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt; Back to Lesson 1</a><br /> <canvas id="lesson01-canvas" style="border: none;" width="500" height="500"></canvas> <br/> <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt; Back to Lesson 1</a><br /> </body>
  • 9.
    HTML <body onload="webGLStart();"> <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt; Back to Lesson 1</a><br /> <canvas id="lesson01-canvas" style="border: none;" width="500" height="500"></canvas> <br/> <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt; Back to Lesson 1</a><br /> </body>
  • 10.
    HTML <body onload="webGLStart();"> <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt; Back to Lesson 1</a><br /> <canvas id="lesson01-canvas" style="border: none;" width="500" height="500"></canvas> <br/> <a href="http://learningwebgl.com/blog/?p=28">&lt;&lt; Back to Lesson 1</a><br /> </body>
  • 11.
    JavaScript functionwebGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 12.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 13.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 14.
    gl. OpenGL ES WebGL (※Learning WebGL )
  • 15.
    gl. OpenGL ES WebGL (※Learning WebGL ) gl.clearColor() ↓ glClearColor()
  • 16.
    gl. OpenGL ES WebGL (※Learning WebGL ) gl.clearColor() ↓ glClearColor()
  • 17.
    glTranslate() glTranslated() glTranslatef() void glTranslated(GLdouble x, GLdouble y, GLdouble z) void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
  • 18.
    OpenGL OpenGL OpenGL ES http://d.hatena.ne.jp/nakamura001/20080918/1221738923
  • 20.
  • 21.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 22.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 23.
    var gl; function initGL(canvas){ try { gl = canvas.getContext("experimental-webgl"); gl.viewportWidth = canvas.width; gl.viewportHeight = canvas.height; } catch(e) { } if (!gl) { alert("Could not initialise WebGL, sorry :-("); } }
  • 24.
  • 25.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 26.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 27.
    var triangleVertexPositionBuffer; var squareVertexPositionBuffer; function initBuffers() { triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ];
  • 28.
  • 35.
    var triangleVertexPositionBuffer; var squareVertexPositionBuffer; function initBuffers() { triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ];
  • 36.
    var triangleVertexPositionBuffer; var squareVertexPositionBuffer; function initBuffers() { triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ];
  • 37.
    var triangleVertexPositionBuffer; var squareVertexPositionBuffer; function initBuffers() { triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ];
  • 38.
    var triangleVertexPositionBuffer; var squareVertexPositionBuffer; function initBuffers() { triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ];
  • 39.
    var triangleVertexPositionBuffer; var squareVertexPositionBuffer; function initBuffers() { triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array (vertices), gl.STATIC_DRAW); triangleVertexPositionBuffer.itemSize = 3; triangleVertexPositionBuffer.numItems = 3;
  • 40.
    triangleVertexPositionBuffer.itemSize = 3; triangleVertexPositionBuffer.numItems = 3; .itemSize .numItems ( ) ※OpenGL ES ※ gl.vertexAttribPointer() gl.drawArrays()
  • 41.
    squareVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer); vertices = [ 1.0, 1.0, 0.0, -1.0, 1.0, 0.0, 1.0, -1.0, 0.0, -1.0, -1.0, 0.0 ]; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array (vertices), gl.STATIC_DRAW); squareVertexPositionBuffer.itemSize = 3; squareVertexPositionBuffer.numItems = 4;
  • 42.
  • 43.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 44.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 45.
    function drawScene() { gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
  • 48.
    • • ( ) DirectX Z
  • 49.
    perspective(45, gl.viewportWidth /gl.viewportHeight, 0.1, 100.0); gluPerspective
  • 50.
  • 51.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
    gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems); 2 + 1 GL_TRIANGLE_STRIP http://d.hatena.ne.jp/nakamura001/20081231/1230719279
  • 58.
  • 59.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 60.
    function webGLStart() { var canvas = document.getElementById("lesson01- canvas"); initGL(canvas); initShaders(); initBuffers(); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.clearDepth(1.0); gl.enable(gl.DEPTH_TEST); gl.depthFunc(gl.LEQUAL); setInterval(drawScene, 15); }
  • 61.
    var shaderProgram; function initShaders(){ var fragmentShader = getShader(gl, "shader-fs"); var vertexShader = getShader(gl, "shader-vs"); shaderProgram = gl.createProgram();
  • 68.
    GLSL(OpenGL Shading Language) http://d.hatena.ne.jp/nakamura001/20090927/1254058173
  • 70.
    <script id="shader-fs" type="x-shader/x-fragment"> #ifdef GL_ES precision highp float; #endif void main(void) { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); } </script>
  • 71.
    <script id="shader-fs" type="x-shader/x-fragment"> #ifdef GL_ES precision highp float; #endif void main(void) { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); } </script>
  • 72.
    triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array (vertices), gl.STATIC_DRAW); triangleVertexPositionBuffer.itemSize = 3; triangleVertexPositionBuffer.numItems = 3; ※ (gl.TRIANGLE_STRIP)
  • 73.
    triangleVertexPositionBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); var vertices = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ]; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array (vertices), gl.STATIC_DRAW); triangleVertexPositionBuffer.itemSize = 3; triangleVertexPositionBuffer.numItems = 3; ※ (gl.TRIANGLE_STRIP)
  • 74.
  • 82.
    <script type="text/javascript" src="sylvester.js"></ script> <scripttype="text/javascript" src="glUtils.js"></script> Sylvester http://sylvester.jcoglan.com/ ※sylvester.src.js