diff --git a/lib/ext/glx.js b/lib/ext/glx.js index c9b1869..63d3c05 100644 --- a/lib/ext/glx.js +++ b/lib/ext/glx.js @@ -156,6 +156,34 @@ exports.requireExt = function(display, callback) X.pack_stream.flush(); } + ext.GenTextures = function(ctx, count, callback) + { + X.seq_num++; + X.pack_stream.pack('CCSLL', [ext.majorOpcode, 145, 3, ctx, count]); + X.replies[X.seq_num] = [ + function(buf, opt) { + var format = Buffer(count); + format.fill('L'); + return buf.unpack(format.toString()); + }, + callback + ]; + X.pack_stream.flush(); + } + + ext.IsTexture = function(ctx, texture, callback) + { + X.seq_num++; + X.pack_stream.pack('CCSLL', [ext.majorOpcode, 146, 3, ctx, texture]); + X.replies[X.seq_num] = [ + function(buf, opt) { + return buf.unpack('CCCCCCCCCCCCCCCCCCCCCCCCCC'); + }, + callback + ]; + X.pack_stream.flush(); + } + ext.MakeCurrent = function(drawable, ctx, oldctx, callback) { X.seq_num++; diff --git a/lib/ext/glxrender.js b/lib/ext/glxrender.js index c30fbf1..f81f947 100644 --- a/lib/ext/glxrender.js +++ b/lib/ext/glxrender.js @@ -87,6 +87,13 @@ module.exports = function(GLX, ctx) { buffers.push(res); } + function serialize2f(opcode, f1, f2) { + var res = commandBuffer(opcode, 12); + res.writeFloatLE(f1, 4); + res.writeFloatLE(f2, 8); + buffers.push(res); + } + function serialize2i(opcode, i1, i2) { var res = commandBuffer(opcode, 12); res.writeUInt32LE(i1, 4); @@ -94,6 +101,14 @@ module.exports = function(GLX, ctx) { buffers.push(res); } + function serialize2i1f(opcode, i1, i2, f1) { + var res = commandBuffer(opcode, 16); + res.writeUInt32LE(i1, 4); + res.writeUInt32LE(i2, 8); + res.writeFloatLE(f1, 12); + buffers.push(res); + } + function serialize2i4f(opcode, i1, i2, f1, f2, f3, f4) { var res = commandBuffer(opcode, 28); res.writeUInt32LE(i1, 4); @@ -205,6 +220,18 @@ module.exports = function(GLX, ctx) { }, Hint: function(target, mode) { serialize2i(85, target, mode); + }, + BindTexture: function(target, texture) { + serialize2i(4117, target, texture); + }, + TexEnvf: function(target, pname, param) { + serialize2i1f(112, target, pname, param); + }, + TexParameterf: function(target, pname, param) { + serialize2i1f(105, target, pname, param); + }, + TexCoords2f: function(x, y) { + serialize2f(54, x, y); } }; @@ -213,7 +240,7 @@ module.exports = function(GLX, ctx) { renderContext[c] = constants[c]; // bind some glx functions - 'NewList EndList GenLists SwapBuffers Finish'.split(' ').forEach(function(name) { + 'NewList EndList GenLists GenTextures IsTexture SwapBuffers Finish'.split(' ').forEach(function(name) { // todo: small camelCase ? to be consistent with webgl api //renderContext[name] = GLX[name].bind(GLX, ctx);