Currently I am trying to convert browser based client side volume rendering
code to server side pure javascript based rendering.
I use node-webgl at server side. My main goal is to send the canvas content
of server to client, later this image data is displayed on the client.
But before this I need to check whether the rendering is proper. So I used
canvas.toDataURL() to extract canvas data and want to display it on a
separate window. But I am facing the error.
Below is my code:
Entry point javascript code:
var nodejs=true,
WebGL = require('./node_modules/node-webgl/index'),
document = WebGL.document();
document.setTitle("Lesson02");
requestAnimationFrame = document.requestAnimationFrame;
alert=console.error;
//Read and eval library
fs=require('fs');eval(fs.readFileSync(__dirname+
'/sylvester.js','utf8'));eval(fs.readFileSync(__dirname+
'/glUtils.js','utf8'));eval(fs.readFileSync(__dirname+
'/glAux.js','utf8'));eval(fs.readFileSync(__dirname+
'/volumercserver.js','utf8'));
volumerc_main('./raycast-color.frag','./aorta-high512.jpg','./tfold.png');
volumetricserver.js excerpt:
var Image = require("node-webgl").Image;
var canvas = document.createElement("canvas");
canvas.id = 'canvas_win';
canvas.width= 512;
canvas.height= 512;
var gl;
var canvas1 = document.createElement("canvas");
canvas1.width= 512;
canvas1.height= 512;
var ctx = canvas1.getContext('2d');
try {
gl = canvas.getContext("webgl", {premultipliedAlpha: false}) ||
canvas.getContext("experimental-webgl",{premultipliedAlpha: false});
} catch (e) {
}
if (!gl) {
alert("Could not initialise WebGL, sorry :-(");
}
// All computations take place here
//................
//..................
//.............
var dataURLstring = canvas.toDataURL();
var img1 = new Image;
img1.src = dataURLstring;
// img1.onload = function(){
ctx.drawImage(img1,0,0); // Or at whatever offset you like
// };
Error:
C:\Users\z003npra\Desktop\node>node exp.js
Status: Using GLEW 1.13.0
Status: Using GLEW 1.13.0
I am here
undefined:457
var dataURLstring = canvas.toDataURL();
^
TypeError: canvas.toDataURL is not a function
at drawVolume (eval at <anonymous>
(C:\Users\z003npra\Desktop\node\exp.js:18
:9), <anonymous>:457:30)
at Timer.listOnTimeout (timers.js:92:15)
Please let me the issue. Is toDataURL not supported in node-WebGL? any
alternative?
Regards,
Prajwal
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/3a3de077-d940-4374-9ba8-d9ddc6aff94d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.