Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test bed #110

Merged
merged 3 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions demo/html5canvas/testbed.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<script type="text/javascript">
var Box2D;
if (!Box2D) Box2D = (typeof Box2D !== 'undefined' ? Box2D : null) || Module;
Box2D = Box2D();
Module = Box2D;
window.onload = function() {
using(Box2D, "b2.+")
init();
Expand Down
12 changes: 6 additions & 6 deletions helpers/embox2d-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ function scaledVec2(vec, scale) {
// http://stackoverflow.com/questions/12792486/emscripten-bindings-how-to-create-an-accessible-c-c-array-from-javascript
function createChainShape(vertices, closedLoop) {
var shape = new Box2D.b2ChainShape();
var buffer = Box2D.allocate(vertices.length * 8, 'float', Box2D.ALLOC_STACK);
var buffer = Box2D._malloc(vertices.length * 8);
var offset = 0;
for (var i=0;i<vertices.length;i++) {
Box2D.setValue(buffer+(offset), vertices[i].get_x(), 'float'); // x
Box2D.setValue(buffer+(offset+4), vertices[i].get_y(), 'float'); // y
Box2D.HEAPF32[buffer + offset >> 2] = vertices[i].get_x();
Box2D.HEAPF32[buffer + (offset + 4) >> 2] = vertices[i].get_y();
offset += 8;
}
var ptr_wrapped = Box2D.wrapPointer(buffer, Box2D.b2Vec2);
Expand All @@ -59,11 +59,11 @@ function createChainShape(vertices, closedLoop) {

function createPolygonShape(vertices) {
var shape = new Box2D.b2PolygonShape();
var buffer = Box2D.allocate(vertices.length * 8, 'float', Box2D.ALLOC_STACK);
var buffer = Box2D._malloc(vertices.length * 8);
var offset = 0;
for (var i=0;i<vertices.length;i++) {
Box2D.setValue(buffer+(offset), vertices[i].get_x(), 'float'); // x
Box2D.setValue(buffer+(offset+4), vertices[i].get_y(), 'float'); // y
Box2D.HEAPF32[buffer + offset >> 2] = vertices[i].get_x();
Box2D.HEAPF32[buffer + (offset + 4) >> 2] = vertices[i].get_y();
offset += 8;
huy-nguyen marked this conversation as resolved.
Show resolved Hide resolved
}
var ptr_wrapped = Box2D.wrapPointer(buffer, Box2D.b2Vec2);
Expand Down