<p>Enabling the extension is as simple as:</p>

<pre><code>var uints_for_indices = gl.getExtension("OES_element_index_uint");
</code></pre>

<p>if <code>uints_for_indices</code> is null then the extension is not available and you'll have to split your data anyway.</p>

<p>If it's not null then you can now pass <code>gl.UNSIGNED_INT</code> for the index type into <code>gl.drawElements</code>.</p>

CC BY-SA 3.0
2016-06-17T13:00:36.523Z
`OES_element_index_uint` extension is available but it's not rendering the buffers. Strange.
q9f
CC BY-SA 3.0
2016-06-17T13:10:03.973Z
have you changed the index buffer to store ints?
ratchet freak
CC BY-SA 3.0
2016-06-17T12:00:41.297Z
2016-06-17T12:00:41.297Z
ratchet freak
<p>WebGL 1.0 specification does not allow <a href="https://www.khronos.org/webgl/public-mailing-list/archives/1102/msg00093.php" rel="nofollow noreferrer">to create 32-bit index buffers</a>. Now I'm in trouble, I'm trying to render huge objects with 100 thousands to 1 million indices. In OpenGL this is no issue at all, and I think it will be no issue in WebGL too, in most cases.</p>

<p>I am not able <a href="https://stackoverflow.com/a/5189502/1260906">to split my data into smaller subsets</a> as I'm already working with split data sets and can't divide it further without breaking up my full program logic.</p>

<p>Now I came across a new extension for WebGL from 2012, <a href="https://www.khronos.org/registry/webgl/extensions/OES_element_index_uint/" rel="nofollow noreferrer">OES_element_index_uint</a>, which looks like it enables unsigned integers (32 bit) for <code>drawElements</code> calls. </p>

<pre><code>/* draw geometry lines by indices */
gl.drawElements(gl.LINES, getIndexBuffer().length, gl.UNSIGNED_INT, idxBuffer);
</code></pre>

<p>But when I try to use the <code>gl.UNSIGNED_INT</code> I run into the following error:</p>

<pre><code>Error: WebGL: drawElements: Invalid `type`: 0x1405
uncaught exception: gl.INVALID_ENUM was caused by call to drawElements
</code></pre>

<p>How to use 32 bit Integers for Element Indices in WebGL 1.0? How to enable this extension in Chrome or Firefox?</p>

<p>Does this mean in general such a call won't be compatible with most devices running WebGL 1.0?</p>

<webgl><drawing><types>
How to use 32 bit Integers for Element Indices in WebGL 1.0?
q9f
# How to use 32 bit Integers for Element Indices in WebGL 1.0?

(Asked by: username_0 on 2016-06-17)

WebGL 1.0 specification does not allow to create 32-bit index buffers. Now I'm in trouble, I'm trying to render huge objects with 100 thousands to 1 million indices. In OpenGL this is no issue at all, and I think it will be no issue in WebGL too, in most cases.
I am not able to split my data into smaller subsets as I'm already working with split data sets and can't divide it further without breaking up my full program logic.
Now I came across a new extension for WebGL from 2012, OES_element_index_uint, which looks like it enables unsigned integers (32 bit) for drawElements calls. 
/* draw geometry lines by indices */
gl.drawElements(gl.LINES, getIndexBuffer().length, gl.UNSIGNED_INT, idxBuffer);

But when I try to use the gl.UNSIGNED_INT I run into the following error:
Error: WebGL: drawElements: Invalid `type`: 0x1405
uncaught exception: gl.INVALID_ENUM was caused by call to drawElements

How to use 32 bit Integers for Element Indices in WebGL 1.0? How to enable this extension in Chrome or Firefox?
Does this mean in general such a call won't be compatible with most devices running WebGL 1.0?

**Tags:** webgl, drawing, types

---

## 1 answers

### Answer by username_1 on 2016-06-17. Score: 5 | Accepted answer

Enabling the extension is as simple as:
var uints_for_indices = gl.getExtension("OES_element_index_uint");

if uints_for_indices is null then the extension is not available and you'll have to split your data anyway.
If it's not null then you can now pass gl.UNSIGNED_INT for the index type into gl.drawElements.

> **Comments:**
> **username_0**: `OES_element_index_uint` extension is available but it's not rendering the buffers. Strange.  
> **username_1**: have you changed the index buffer to store ints?  

---

