Skip to content

Commit

Permalink
Change to use v8-typed-array.
Browse files Browse the repository at this point in the history
  • Loading branch information
puffnfresh committed May 29, 2011
1 parent 8780802 commit 59f9499
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 136 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Building
-------- --------


node-waf configure build node-waf configure build
npm install https://github.com/pufuwozu/v8-typed-array/tarball/master


Testing Testing
------- -------
Expand Down
4 changes: 2 additions & 2 deletions examples/example-include.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ function init(canvas, nodejs) {


if(nodejs) { if(nodejs) {
var webgl = require('../webgl'); var webgl = require('../webgl');
ArrayBuffer = require('buffer').Buffer; ArrayBuffer = require('typed-array').ArrayBuffer;
Float32Array = webgl.Float32Array; Float32Array = require('typed-array').Float32Array;
Image = webgl.Image; Image = webgl.Image;
} }


Expand Down
14 changes: 7 additions & 7 deletions src/glcontext.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <node.h> #include <node.h>
#include <node_events.h> #include <node_events.h>


#include "typedarray.h"
#include "image.h" #include "image.h"


using namespace v8; using namespace v8;
Expand Down Expand Up @@ -185,11 +184,12 @@ class GLContext : public ObjectWrap {
BufferData (const Arguments& args) { BufferData (const Arguments& args) {
HandleScope scope; HandleScope scope;


Float32Array *fa = Unwrap<Float32Array>(args[1]->ToObject()); Local<Object> array = args[1]->ToObject();
Local<Object> buffer = array->GetHiddenValue(String::New("_buffer"))->ToObject();


GLenum target = args[0]->Uint32Value(); GLenum target = args[0]->Uint32Value();
GLsizei size = fa->Length(); GLsizei size = buffer->Get(String::New("byteLength"))->Uint32Value();
const GLvoid* data = fa->GetData(); const GLvoid* data = array->GetIndexedPropertiesExternalArrayData();
GLenum usage = args[2]->Uint32Value(); GLenum usage = args[2]->Uint32Value();


glBufferData(target, size, data, usage); glBufferData(target, size, data, usage);
Expand Down Expand Up @@ -274,12 +274,12 @@ class GLContext : public ObjectWrap {
UniformMatrix4fv (const Arguments &args) { UniformMatrix4fv (const Arguments &args) {
HandleScope scope; HandleScope scope;


Float32Array *fa = Unwrap<Float32Array>(args[2]->ToObject()); Local<Object> array = args[2]->ToObject();


GLint location = args[0]->IntegerValue(); GLint location = args[0]->IntegerValue();
GLsizei count = fa->Length() / sizeof(float); GLsizei count = array->GetIndexedPropertiesExternalArrayDataLength();
GLboolean transpose = args[1]->BooleanValue(); GLboolean transpose = args[1]->BooleanValue();
const GLfloat *value = (float *)fa->GetData(); const GLfloat *value = (float *)array->GetIndexedPropertiesExternalArrayData();
glUniformMatrix4fv(location, count, transpose, value); glUniformMatrix4fv(location, count, transpose, value);


return Undefined(); return Undefined();
Expand Down
125 changes: 0 additions & 125 deletions src/typedarray.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/webgl.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <node_events.h> #include <node_events.h>


#include "glcontext.h" #include "glcontext.h"
#include "typedarray.h"
#include "image.h" #include "image.h"


using namespace v8; using namespace v8;
Expand Down Expand Up @@ -190,7 +189,6 @@ init (Handle<Object> target) {
HandleScope scope; HandleScope scope;


GLContext::Initialize(target); GLContext::Initialize(target);
Float32Array::Initialize(target);
Image::Initialize(target); Image::Initialize(target);
Window::Initialize(target); Window::Initialize(target);
} }

0 comments on commit 59f9499

Please sign in to comment.