I am having a image that I am reading in server side and pushing to web browser via AJAX call. I have a requirement where I have to render them line by line using WebGL.
For Example : Image is 640X480 where 640 is width and 480 is height. Now the total number of pixels will be 640*480 = 307200 pixels. So, I want to render the whole image in 640(total width) intervals in a loop using WebGL.
Now I have texture2D(as per my knowledge) in webgl to do so, but not getting any idea of where to start . I also having the ArrayBuffer with me , only thing is using Texture2D I want to render it slowly ,line by line.
I am ready to go for any js libraries ,if they are satisfying the requirements.
Tagging Babylon.js and Three.js ,incase those guys have a answer to my question with what they already have.
Adding some code to explain my requirement :
//Recieve data
Code :
var imageDataFromServer = single line data from server;
var imageLineData = new ArrayBuffer(imageDataFromServer.length);
var imageUintArray = new Uint8Array(imageLineData);
for (var i = 0; i < width(i.e.640) ;i++) //because I know one line length =640.
{
//how to put data in texture2D using Three.js or Babylon.js or just plain WebGL
}
So, to write a image line by line we can do something like this.
Vertex Shader
Fragment Shader
Javascript For rendering pixel by pixel
Ok, below is the working code 1) put it into .html file 2) load image (see comment in initTextures function)
In this code is also added vertex and fragment shaders