add ProgramString and BindProgram

This commit is contained in:
Andrey Sidorov 2014-03-06 10:50:35 +11:00
parent a9c2254aed
commit 13d3f680b9

View file

@ -2,7 +2,7 @@
var constants = require('./glxconstants');
var MAX_SMALL_RENDER=65000;
var MAX_SMALL_RENDER=65536-16;
module.exports = function(GLX, ctx) {
buffers = [];
@ -10,14 +10,10 @@ module.exports = function(GLX, ctx) {
function commandBuffer(opcode, len) {
if (currentLength + len > MAX_SMALL_RENDER) {
console.log("Flushing buffer ", currentLength);
render();
}
if (len > MAX_SMALL_RENDER)
{
throw Error('Buffer too big. Please implement RenderLarge request');
// renderLarge();
}
throw Error('Buffer too big. Make sure you are using RenderLarge for large commands');
currentLength += len;
var res = Buffer(len);
@ -320,12 +316,20 @@ module.exports = function(GLX, ctx) {
// bake sure buffer for glxRender request is emptied first
render();
var dataLen = res.length;
var maxSize = 65536*4 - 16 - 8;
var maxSize = 262124;
var totalRequests = 1 + parseInt(dataLen / maxSize) - 1;
if (dataLen % maxSize)
totalRequests++;
// for some reason RenderLarge does not like everything to be sent in one go
// add one extra buffer request for small requests
if (dataLen < maxSize) {
GLX.RenderLarge(ctx, 1, 2, res);
GLX.RenderLarge(ctx, 2, 2, Buffer(0));
return;
}
var pos = 0;
var reqNum = 1;
@ -340,7 +344,19 @@ module.exports = function(GLX, ctx) {
reqNum++;
}
}
},
ProgramString: function(target, format, src) {
serialize3i(target, format, src);
buffers.push(Buffer(src));
},
BindProgram: function(target, program) {
serialize2i(target, format, src);
},
TexCoord2f: function(x, y) {
serialize2f(54, x, y);