mirror of
https://github.com/danbulant/node-x11
synced 2026-06-14 12:11:26 +00:00
draw first frame immediately
This commit is contained in:
parent
d2f6b9c7fc
commit
e712fdb0a5
1 changed files with 25 additions and 21 deletions
|
|
@ -18,7 +18,7 @@ x11.createClient(function(display) {
|
|||
var visuals = display.screen[0].depths[24];
|
||||
for (visual in visuals) {
|
||||
if (visuals[visual].class == 4 || visuals[visual].class == 5)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
var win = X.AllocID();
|
||||
|
|
@ -27,6 +27,28 @@ x11.createClient(function(display) {
|
|||
var ctx = X.AllocID();
|
||||
GLX.CreateContext(ctx, visual, 0, 0, 0);
|
||||
GLX.MakeCurrent(win, ctx, 0, function(err, ctx) {}); // do we need to wait for reply here?
|
||||
|
||||
function draw(ev) {
|
||||
var gl = GLX.renderPipeline();
|
||||
gl.Enable(0x0B71);
|
||||
gl.Viewport(0, 0, 800, 800);
|
||||
gl.MatrixMode(0x1701);
|
||||
gl.LoadIdentity();
|
||||
gl.Ortho(-30.0, 30.0, -30.0, 30.0, -300.0, 300.0);
|
||||
//gl.Frustum(-30.0, 30.0, -30.0, 30.0, 30, 300.0);
|
||||
|
||||
gl.Rotatef(ev.y, 0, 0, 1);
|
||||
gl.Rotatef(ev.x, 1, 0, 0);
|
||||
gl.MatrixMode(0x1700);
|
||||
gl.ClearColor(0.3,0.3,0.3,0.0);
|
||||
gl.Clear(0x00004000|0x00000100);
|
||||
gl.ShadeModel(0x1D01);
|
||||
gl.LoadIdentity();
|
||||
gl.CallList(listId);
|
||||
gl.render(ctx);
|
||||
GLX.SwapBuffers(ctx, win);
|
||||
}
|
||||
|
||||
GLX.GenLists(ctx, 1, function(err, startListIndex) {
|
||||
listId = startListIndex;
|
||||
GLX.NewList(ctx, listId, 0x00001300);
|
||||
|
|
@ -40,28 +62,10 @@ x11.createClient(function(display) {
|
|||
gl.End();
|
||||
gl.render(ctx);
|
||||
GLX.EndList(ctx);
|
||||
draw({x: 10, y: 10});
|
||||
});
|
||||
|
||||
X.on('event', function(ev) {
|
||||
var gl = GLX.renderPipeline();
|
||||
gl.Enable(0x0B71);
|
||||
gl.Viewport(0, 0, 800, 800);
|
||||
gl.MatrixMode(0x1701);
|
||||
gl.LoadIdentity();
|
||||
gl.Ortho(-30.0, 30.0, -30.0, 30.0, -300.0, 300.0);
|
||||
//gl.Frustum(-30.0, 30.0, -30.0, 30.0, 30, 300.0);
|
||||
|
||||
gl.Rotatef(ev.y, 0, 0, 1);
|
||||
gl.Rotatef(ev.x, 1, 0, 0);
|
||||
gl.MatrixMode(0x1700);
|
||||
gl.ClearColor(0.3,0.3,0.3,0.0);
|
||||
gl.Clear(0x00004000|0x00000100);
|
||||
gl.ShadeModel(0x1D01);
|
||||
gl.LoadIdentity();
|
||||
gl.CallList(listId);
|
||||
gl.render(ctx);
|
||||
GLX.SwapBuffers(ctx, win);
|
||||
});
|
||||
X.on('event', draw);
|
||||
});
|
||||
X.on('error', function(err) { console.log(err); });
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue