GenTextures, TexCoord2D, BindTexture, TextureParameterf, TexEnvf

This commit is contained in:
Andrey Sidorov 2013-02-20 12:00:10 +11:00
parent 14d126f9c1
commit 3f1b8e5442
2 changed files with 56 additions and 1 deletions

View file

@ -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++;

View file

@ -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);