weex-gcanvas
Advanced tools
Comparing version 0.5.1 to 0.5.2
182
gwebgl.js
@@ -34,2 +34,3 @@ var GBridge = require("./gutil").GBridge; | ||
var type = 0x60000000; //ContextType.ContextWebGL << 30 | MethodType.Sync << 29 | ||
GLog.d("WebGLCallNative command: " + cmdArgs); | ||
@@ -43,2 +44,3 @@ if( G_UseGBridge ) | ||
} | ||
return null; | ||
} | ||
@@ -57,2 +59,6 @@ | ||
GInitWebGLEnum(this); | ||
GInitWebGLFuncIdExt(this); | ||
GInitWebGLEnumExt(this); | ||
GInitWebGLParams(params); | ||
@@ -239,8 +245,2 @@ | ||
obj.viewportId=(i++)+","; | ||
//extension for OES_vertex_array_object | ||
obj.bindVertexArrayOESId=(i++)+","; | ||
obj.deleteVertexArraysOESId=(i++)+","; | ||
obj.genVertexArraysOESId=(i++)+"," | ||
obj.isVertexArrayOESId=(i++)+"," | ||
} | ||
@@ -547,7 +547,37 @@ | ||
// obj.BROWSER_DEFAULT_WEBGL = 0x9244; | ||
} | ||
//extsion | ||
///////////////////////////////////////////// | ||
// WebGL Extension | ||
///////////////////////////////////////////// | ||
function GInitWebGLFuncIdExt(obj) | ||
{ | ||
var i=300; //offset=300 | ||
//extension method for ANGLE_instanced_arrays | ||
obj.drawArraysInstancedANGLEId=(i++)+","; | ||
obj.drawElementsInstancedANGLEId=(i++)+","; | ||
obj.vertexAttribDivisorANGLEId=(i++)+","; | ||
//extension method for OES_vertex_array_object | ||
obj.createVertexArrayOESId=(i++)+","; | ||
obj.deleteVertexArrayOESId=(i++)+","; | ||
obj.isVertexArrayOESId=(i++)+","; | ||
obj.bindVertexArrayOESId=(i++)+","; | ||
} | ||
function GInitWebGLEnumExt(obj) | ||
{ | ||
//extension flag | ||
obj.OES_vertex_array_object = 1; | ||
obj.OES_texture_float = 1; | ||
obj.OES_element_index_uint = 1; | ||
//extension const for ANGLE_instanced_arrays | ||
//#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE | ||
obj.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE; | ||
//extension const for OES_vertex_array_object | ||
//#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 | ||
obj.VERTEX_ARRAY_BINDING_OES = 0x85B5; | ||
} | ||
@@ -607,5 +637,14 @@ | ||
function createGWebGLActiveInfoByString(infoString) | ||
GWebGLActiveInfo.convertFormString = function(infoString) | ||
{ | ||
if( !infoString ) return null; | ||
var infoArray = infoString.split(","); | ||
if( infoArray.length < 3 ) return null; | ||
var activeInfo = new GWebGLActiveInfo(); | ||
activeInfo.type = infoArray[0]; | ||
activeInfo.size = infoArray[1]; | ||
activeInfo.name = infoArray[2]; | ||
return activeInfo; | ||
} | ||
@@ -624,6 +663,10 @@ | ||
////////////////////////////////////////////////////////////////////////// | ||
// GWebGLActiveInfos | ||
// https://developer.mozilla.org/en-US/docs/Web/API/WebGLActiveInfos | ||
// GContextWebGLExtension | ||
////////////////////////////////////////////////////////////////////////// | ||
function GContextWebGLExtension(gl) | ||
{ | ||
this.gl = gl; | ||
} | ||
GContextWebGL.prototype.render = function() { | ||
@@ -925,6 +968,4 @@ var commands = this._drawCommands; | ||
var cmd = (this.getActiveAttribId + program + "," + index + ";"); | ||
var result = WebGLCallNative(this.componentId, cmd); | ||
//TODO convert result -> GWebGLActiveInfo | ||
var activeInfo = new GWebGLActiveInfo(); | ||
return activeInfo; | ||
var resultString = WebGLCallNative(this.componentId, cmd); | ||
return GWebGLActiveInfo.convertFormString(resultString); | ||
}; | ||
@@ -934,6 +975,4 @@ | ||
var cmd = (this.getActiveUniformId + program + "," + index + ";"); | ||
var result = WebGLCallNative(this.componentId, cmd); | ||
//TODO convert result -> GWebGLActiveInfo | ||
var activeInfo; | ||
return activeInfo; | ||
var resultString = WebGLCallNative(this.componentId, cmd); | ||
return GWebGLActiveInfo.convertFormString(resultString); | ||
}; | ||
@@ -971,6 +1010,30 @@ | ||
//new | ||
GContextWebGL.prototype.getExtension = function(name) { | ||
var cmd = (this.getExtensionId + name + ";"); | ||
return WebGLCallNative(this.componentId, cmd); | ||
GContextWebGL.prototype.getExtension = function(name) | ||
{ | ||
var ext = null; | ||
if( name == "ANGLE_instanced_arrays" ) | ||
{ | ||
var gl = this; | ||
ext = new GContextWebGLExtension(gl); | ||
ext.drawArraysInstancedANGLE = gl.drawArraysInstancedANGLE; | ||
ext.drawElementsInstancedANGLE = gl.drawElementsInstancedANGLE; | ||
ext.vertexAttribDivisorANGLE = gl.vertexAttribDivisorANGLE; | ||
} | ||
else if( name == "OES_vertex_array_object" ) | ||
{ | ||
var gl = this; | ||
ext = new GContextWebGLExtension(gl); | ||
ext.createVertexArrayOES = gl.createVertexArrayOES; | ||
ext.deleteVertexArrayOES = gl.deleteVertexArrayOES; | ||
ext.isVertexArrayOES = gl.isVertexArrayOES; | ||
ext.bindVertexArrayOES = gl.bindVertexArrayOES; | ||
} | ||
else if( name == "OES_texture_float" ) | ||
{ | ||
var gl = this; | ||
ext = new GContextWebGLExtension(gl); | ||
} | ||
return ext; | ||
}; | ||
@@ -1009,3 +1072,3 @@ | ||
case 6: return resultArray[1]; | ||
default: return nil; | ||
default: return null; | ||
} | ||
@@ -1508,26 +1571,69 @@ }; | ||
//////////////////////////////////////////// | ||
//extension for ANGLE_instanced_arrays | ||
GContextWebGL.prototype.drawArraysInstancedANGLE = function(mode, first, count, primcount) { | ||
var gl = this; | ||
if( this instanceof GContextWebGLExtension ){ | ||
gl = this.gl; | ||
} | ||
var cmd = (gl.drawArraysInstancedANGLEId + mode + "," + first + "," + count + "," + primcount + ";"); | ||
WebGLCallNative(gl.componentId, cmd); | ||
} | ||
GContextWebGL.prototype.drawElementsInstancedANGLE = function(mode, count, type, offset, primcount) { | ||
var gl = this; | ||
if( this instanceof GContextWebGLExtension ){ | ||
gl = this.gl; | ||
} | ||
var cmd = (gl.drawElementsInstancedANGLEId + mode + "," + count + "," + type + "," + offset + "," + primcount + ";"); | ||
WebGLCallNative(gl.componentId, cmd); | ||
} | ||
GContextWebGL.prototype.vertexAttribDivisorANGLE = function(index, divisor) { | ||
var gl = this; | ||
if( this instanceof GContextWebGLExtension ){ | ||
gl = this.gl; | ||
} | ||
var cmd = (gl.vertexAttribDivisorANGLEId + index + "," + divisor + ";"); | ||
WebGLCallNative(gl.componentId, cmd); | ||
} | ||
//extension for OES_vertex_array_object | ||
GContextWebGL.prototype.bindVertexArrayOES = function(array) { | ||
var cmd = (this.bindVertexArrayOESId + array + ";"); | ||
WebGLCallNative(this.componentId, cmd); | ||
GContextWebGL.prototype.deleteVertexArrayOES = function(array) { | ||
var gl = this; | ||
if( this instanceof GContextWebGLExtension ){ | ||
gl = this.gl; | ||
} | ||
var cmd = (gl.deleteVertexArrayOESId + array + ";"); | ||
WebGLCallNative(gl.componentId, cmd); | ||
}; | ||
GContextWebGL.prototype.deleteVertexArraysOES = function(size, arrayRef) { | ||
var cmd = (this.deleteVertexArraysOESId + size + "," + arrayRef + ";"); | ||
WebGLCallNative(this.componentId, cmd); | ||
GContextWebGL.prototype.createVertexArrayOES = function() { | ||
var gl = this; | ||
if( this instanceof GContextWebGLExtension ){ | ||
gl = this.gl; | ||
} | ||
var cmd = (gl.createVertexArrayOESId + ";"); | ||
return WebGLCallNative(gl.componentId, cmd); | ||
}; | ||
GContextWebGL.prototype.genVertexArraysOES = function(size, arrayRef) { | ||
// var cmd = (this.genVertexArraysOESId + size + "," + arrayRef + ";"); | ||
var args = (this.genVertexArraysOESId + size + "," + arrayRef + ";"); | ||
WebGLCallNative(this.componentId, cmd); | ||
GContextWebGL.prototype.isVertexArrayOES = function(array) { | ||
var gl = this; | ||
if( this instanceof GContextWebGLExtension ){ | ||
gl = this.gl; | ||
} | ||
var cmd = (gl.isVertexArrayOESId + array + ";") | ||
return WebGLCallNative(gl.componentId, cmd); | ||
}; | ||
GContextWebGL.prototype.isVertexArrayOES = function(array) { | ||
var cmd = (this.isVertexArrayOESId + array + ";") | ||
return WebGLCallNative(this.componentId, cmd); | ||
GContextWebGL.prototype.bindVertexArrayOES = function(array) { | ||
var gl = this; | ||
if( this instanceof GContextWebGLExtension ){ | ||
gl = this.gl; | ||
} | ||
var cmd = (gl.bindVertexArrayOESId + array + ";"); | ||
WebGLCallNative(gl.componentId, cmd); | ||
}; | ||
module.exports = GContextWebGL; |
{ | ||
"name": "weex-gcanvas", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"main":"gcanvas.js", | ||
@@ -5,0 +5,0 @@ "platform": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
140163
10
3214