mirror of
https://github.com/danbulant/node-x11
synced 2026-06-24 17:21:47 +00:00
add ProgramString and BindProgram
This commit is contained in:
parent
a9c2254aed
commit
13d3f680b9
1 changed files with 24 additions and 8 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
var constants = require('./glxconstants');
|
var constants = require('./glxconstants');
|
||||||
|
|
||||||
var MAX_SMALL_RENDER=65000;
|
var MAX_SMALL_RENDER=65536-16;
|
||||||
|
|
||||||
module.exports = function(GLX, ctx) {
|
module.exports = function(GLX, ctx) {
|
||||||
buffers = [];
|
buffers = [];
|
||||||
|
|
@ -10,14 +10,10 @@ module.exports = function(GLX, ctx) {
|
||||||
|
|
||||||
function commandBuffer(opcode, len) {
|
function commandBuffer(opcode, len) {
|
||||||
if (currentLength + len > MAX_SMALL_RENDER) {
|
if (currentLength + len > MAX_SMALL_RENDER) {
|
||||||
console.log("Flushing buffer ", currentLength);
|
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
if (len > MAX_SMALL_RENDER)
|
if (len > MAX_SMALL_RENDER)
|
||||||
{
|
throw Error('Buffer too big. Make sure you are using RenderLarge for large commands');
|
||||||
throw Error('Buffer too big. Please implement RenderLarge request');
|
|
||||||
// renderLarge();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentLength += len;
|
currentLength += len;
|
||||||
var res = Buffer(len);
|
var res = Buffer(len);
|
||||||
|
|
@ -322,11 +318,19 @@ module.exports = function(GLX, ctx) {
|
||||||
render();
|
render();
|
||||||
|
|
||||||
var dataLen = res.length;
|
var dataLen = res.length;
|
||||||
var maxSize = 65536*4 - 16 - 8;
|
var maxSize = 262124;
|
||||||
var totalRequests = 1 + parseInt(dataLen / maxSize) - 1;
|
var totalRequests = 1 + parseInt(dataLen / maxSize) - 1;
|
||||||
if (dataLen % maxSize)
|
if (dataLen % maxSize)
|
||||||
totalRequests++;
|
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 pos = 0;
|
||||||
var reqNum = 1;
|
var reqNum = 1;
|
||||||
while(dataLen > 0) {
|
while(dataLen > 0) {
|
||||||
|
|
@ -340,8 +344,20 @@ module.exports = function(GLX, ctx) {
|
||||||
reqNum++;
|
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) {
|
TexCoord2f: function(x, y) {
|
||||||
serialize2f(54, x, y);
|
serialize2f(54, x, y);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue