forked from regl-project/regl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request regl-project#331 from regl-project/elements-count
Infer element count/length for empty constructor
- Loading branch information
Showing
3 changed files
with
73 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var tape = require('tape') | ||
var createContext = require('./util/create-context') | ||
var createREGL = require('../regl') | ||
|
||
tape('elements - length', function (t) { | ||
var gl = createContext(5, 5) | ||
var regl = createREGL(gl) | ||
|
||
var N = 5 | ||
|
||
var cellsBuffer = regl.elements({ | ||
type: 'uint16', | ||
usage: 'dynamic', | ||
primitive: 'triangles', | ||
count: N * 3 | ||
}) | ||
|
||
t.equals(cellsBuffer._elements.buffer.byteLength, N * 3 * 2, 'count') | ||
|
||
var cells2Buffer = regl.elements({ | ||
type: 'uint16', | ||
usage: 'dynamic', | ||
primitive: 'triangles', | ||
length: N * 2 * 3 | ||
}) | ||
|
||
t.equals(cells2Buffer._elements.vertCount, N * 3, 'count') | ||
|
||
regl.destroy() | ||
createContext.destroy(gl) | ||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters