aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/webglrenderingcontext/bindbuffer/index.html
blob: bb65be620b488ec6c87c6749af191f5fc21357a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: WebGLRenderingContext.bindBuffer()
slug: Web/API/WebGLRenderingContext/bindBuffer
translation_of: Web/API/WebGLRenderingContext/bindBuffer
---
<div>{{APIRef("WebGL")}}</div>

<p><strong><code>ebGLRenderingContext.bindBuffer()</code></strong> метод <a href="/en-US/docs/Web/API/WebGL_API">WebGL API</a> связывает {{domxref("WebGLBuffer")}} c точкой связывания(Атрибут регистром).</p>

<h2 id="Синтаксис">Синтаксис</h2>

<pre class="syntaxbox">void <var>gl</var>.bindBuffer(<var>target</var>, <var>buffer</var>);
</pre>

<h3 id="Параметры">Параметры</h3>

<dl>
 <dt>target</dt>
 <dd>{{domxref("GLenum")}} определяет точку связывания (target). Возможные значения:
 <ul>
  <li><code>gl.ARRAY_BUFFER</code>: Буфер содержащий вершинные атрибуты, такие как координаты, текстурные коориднаты(UV) или цвет вершины.</li>
  <li><code>gl.ELEMENT_ARRAY_BUFFER</code>: Буфер использующий для индексирования элементов.</li>
  <li>When using a {{domxref("WebGL2RenderingContext", "WebGL 2 context", "", 1)}}, the following values are available additionally:
   <ul>
    <li><code>gl.COPY_READ_BUFFER</code>: Buffer for copying from one buffer object to another.</li>
    <li><code>gl.COPY_WRITE_BUFFER</code>: Buffer for copying from one buffer object to another.</li>
    <li><code>gl.TRANSFORM_FEEDBACK_BUFFER</code>: Buffer for transform feedback operations.</li>
    <li><code>gl.UNIFORM_BUFFER</code>: Buffer used for storing uniform blocks.</li>
    <li><code>gl.PIXEL_PACK_BUFFER</code>: Buffer used for pixel transfer operations.</li>
    <li><code>gl.PIXEL_UNPACK_BUFFER</code>: Buffer used for pixel transfer operations.</li>
   </ul>
  </li>
 </ul>
 </dd>
 <dt>buffer</dt>
 <dd>{{domxref("WebGLBuffer")}} с которым осуществляется связывание.</dd>
</dl>

<h3 id="Return_value">Return value</h3>

<p>Нет.</p>

<h3 id="Exceptions">Exceptions</h3>

<p>Only one target can be bound to a given {{domxref("WebGLBuffer")}}. An attempt to bind the buffer to another target will throw an <code>INVALID_OPERATION</code> error and the current buffer binding will remain the same.</p>

<h2 id="Examples">Examples</h2>

<h3 id="Binding_a_buffer_to_a_target">Binding a buffer to a target</h3>

<pre class="brush: js">var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
var buffer = gl.createBuffer();

gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
</pre>

<h3 id="Getting_current_bindings">Getting current bindings</h3>

<p>To check the current buffer bindings, query the <code>ARRAY_BUFFER_BINDING</code> and <code>ELEMENT_ARRAY_BUFFER_BINDING</code> constants.</p>

<pre class="brush: js">gl.getParameter(gl.ARRAY_BUFFER_BINDING);
gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('WebGL', "#5.14.5", "bindBuffer")}}</td>
   <td>{{Spec2('WebGL')}}</td>
   <td>Initial definition for WebGL.</td>
  </tr>
  <tr>
   <td>{{SpecName('OpenGL ES 2.0', "glBindBuffer.xml", "glBindBuffer")}}</td>
   <td>{{Spec2('OpenGL ES 2.0')}}</td>
   <td>Man page of the (similar) OpenGL ES 2 API.</td>
  </tr>
  <tr>
   <td>{{SpecName('WebGL2', "#3.7.1", "bindBuffer")}}</td>
   <td>{{Spec2('WebGL2')}}</td>
   <td>
    <p>Updated definition for WebGL 2.</p>

    <p>Adds new <code>target</code> buffers:<br>
     <code>gl.COPY_READ_BUFFER</code>,<br>
     <code>gl.COPY_WRITE_BUFFER</code>,<br>
     <code>gl.TRANSFORM_FEEDBACK_BUFFER</code>,<br>
     <code>gl.UNIFORM_BUFFER</code>,<br>
     <code>gl.PIXEL_PACK_BUFFER</code>,<br>
     <code>gl.PIXEL_UNPACK_BUFFER</code></p>
   </td>
  </tr>
  <tr>
   <td>{{SpecName('OpenGL ES 3.0', "glBindBuffer.xhtml", "glBindBuffer")}}</td>
   <td>{{Spec2('OpenGL ES 3.0')}}</td>
   <td>Man page of the (similar) OpenGL ES 3 API.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</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.bindBuffer")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("WebGLRenderingContext.createBuffer()")}}</li>
 <li>{{domxref("WebGLRenderingContext.deleteBuffer()")}}</li>
 <li>{{domxref("WebGLRenderingContext.isBuffer()")}}</li>
 <li>Other buffers: {{domxref("WebGLFramebuffer")}}, {{domxref("WebGLRenderbuffer")}}</li>
</ul>