OpenGL viewport 0,0 is in bottom left corner
0,h——-w,h
| |
| |
0,0——-w,0
module.exports.viewport = function(x, y, w, h) {
var gl = Context.currentContext;
gl.viewport(x, y, w, h);
return this;
};
module.exports.scissor = function(x, y, w, h) {
var gl = Context.currentContext;
if (x === false) {
gl.disable(gl.SCISSOR_TEST);
}
else if (x.width != null) {
var rect = x;
gl.enable(gl.SCISSOR_TEST);
gl.scissor(rect.x, rect.y, rect.width, rect.height);
}
else {
gl.enable(gl.SCISSOR_TEST);
gl.scissor(x, y, w, h);
}
return this;
};
module.exports.cullFace = function(enabled) {
enabled = (enabled !== undefined) ? enabled : true
var gl = Context.currentContext;
if (enabled)
gl.enable(gl.CULL_FACE);
else
gl.disable(gl.CULL_FACE);
gl.cullFace(gl.BACK);
return this;
};
module.exports.lineWidth = function(width) {
var gl = Context.currentContext;
gl.lineWidth(width);
return this;
}