First, the simplest way to do what I think you are asking is
   gl = canvas.getContext('webgl', {preserveDrawingBuffer: true});

Second, after visiting http://127.0.0.1:65001/tgsj I noticed that arrow
keys were inert (and I did not explore the option of typing a command).
Hopefully this just reflects your current state of development and not
something I did wrong?

Thanks,

-- 
Raul



On Sat, Mar 8, 2014 at 2:18 PM, Brian Schott <[email protected]> wrote:

> I have successfully drawn gl.LINES in my adaptation of Eric's demogl1.ijs,
> but each time I draw a new line that the user's command produces (for
> example, say `forward 2` produces a line from 0,0,0 to 0,2,0)  all of the
> graphics on the incumbent canvas are erased, and that line (from 0,0,0 to
> 0,2,0) is all that shows. What can I do to keep the incumbent graphics to
> stay and the new line to show, also?
>
> Eric's code executes the function drawPrimitve() (see below) multiple times
> with multiple lines and they all draw. The only differences are that
>
> (1) when Eric does this, all of the calls to drawPrimitve() are in the same
> function draw(), while my function is named drawLines(), and
>
> (2) my function drawLines() is called after ajax stuff is used to get the
> new line.
>
> I have looked into lots of alternatives, but cannot see an answer myself.
>
> function drawLines(linecolor,vertices) {
>     gl.lineWidth(4);
>     drawPrimitive( gl.LINES, linecolor, vertices);
>     gl.lineWidth(1);
> }
>
> // Copied directly from demogl1.ijs
> function drawPrimitive( primitiveType, color, vertices ) {
>      gl.enableVertexAttribArray(aCoords);
>      gl.bindBuffer(gl.ARRAY_BUFFER,aCoordsBuffer);
>      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices),
> gl.STREAM_DRAW);
>      gl.uniform4fv(uColor, color);
>      gl.vertexAttribPointer(aCoords, 3, gl.FLOAT, false, 0, 0);
>      gl.drawArrays(primitiveType, 0, vertices.length/3);
> }
>
> Thanks,
>
> --
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to