--- title: WebGLRenderingContext.createProgram() slug: Web/API/WebGLRenderingContext/createProgram translation_of: Web/API/WebGLRenderingContext/createProgram --- <div>{{APIRef("WebGL")}}</div> <p><a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> の <strong><code>WebGLRenderingContext.createProgram()</code></strong> メソッドは、{{domxref("WebGLProgram")}} オブジェクトを作成、初期化します。</p> <h2 id="構文">構文</h2> <pre class="syntaxbox">WebGLProgram <var>gl</var>.createProgram(); </pre> <h3 id="引数">引数</h3> <p>ありません。</p> <h3 id="返り値">返り値</h3> <p>{{domxref("WebGLProgram")}} オブジェクトは、2 つのコンパイルされた {{domxref("WebGLShader")}} の組み合わせで、頂点シェーダーとフラグメントシェーダー (どちらも GLSL で書かれる) で成り立ちます。そして、これらを使用可能なプログラムへとリンクします。</p> <h2 id="例">例</h2> <h3 id="WebGL_プログラムの作成">WebGL プログラムの作成</h3> <pre class="brush: js">var program = gl.createProgram(); // Attach pre-existing shaders gl.attachShader(program, vertexShader); gl.attachShader(program, fragmentShader); gl.linkProgram(program); if ( !gl.getProgramParameter( program, gl.LINK_STATUS) ) { var info = gl.getProgramInfoLog(program); throw 'Could not compile WebGL program. \n\n' + info; } </pre> <p>{{domxref("WebGLShader")}} を参照すると、上記サンプルの <code>vertexShader</code> と <code>fragmentShader</code> の作成についての情報が得られます。</p> <h2 id="仕様策定状況">仕様策定状況</h2> <table class="standard-table"> <tbody> <tr> <th scope="col">仕様</th> <th scope="col">策定状況</th> <th scope="col">コメント</th> </tr> <tr> <td>{{SpecName('WebGL', "#5.14.9", "createProgram")}}</td> <td>{{Spec2('WebGL')}}</td> <td>初回定義。</td> </tr> <tr> <td>{{SpecName('OpenGL ES 2.0', "glCreateProgram.xml", "glCreateProgram")}}</td> <td>{{Spec2('OpenGL ES 2.0')}}</td> <td> <p>OpenGL API (と同様の) マニュアルページ。</p> </td> </tr> </tbody> </table> <h2 id="ブラウザーの対応">ブラウザーの対応</h2> <p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> <p>{{Compat("api.WebGLRenderingContext.createProgram")}}</p> <h2 id="関連項目">関連項目</h2> <ul> <li>{{domxref("WebGLRenderingContext.deleteProgram()")}}</li> <li>{{domxref("WebGLRenderingContext.isProgram()")}}</li> <li>{{domxref("WebGLRenderingContext.linkProgram()")}}</li> <li>{{domxref("WebGLRenderingContext.useProgram()")}}</li> <li>{{domxref("WebGLRenderingContext.validateProgram()")}}</li> <li>{{domxref("WebGLRenderingContext.getProgramParameter()")}}</li> <li>{{domxref("WebGLRenderingContext.getProgramInfoLog()")}}</li> </ul>