framebuffer - WebGL: Display Depth Texture -


i'm new webgl , trying implement depth textures later usage in shadow maps. below code of initilisation of framebuffer. in function drawtest first bind buffers needed , draw vertices of model framebuffer attached texture. shouldn't work? got white screen , no error.

this.drawtest = function (model1) {      this.model1 = model1;           if (model1.image.readystate === true && model1.ready === false) {             this.preparemodel(model1);         }         if (model1.ready) {             gl.bindbuffer(gl.array_buffer, this.model1.vertices);             gl.vertexattribpointer(this.vertexposition, 3, gl.float, false, 0, 0);             gl.bindbuffer(gl.element_array_buffer, model1.triangles);         }          gl.bindframebuffer(gl.framebuffer, this.depthframebuffer);          gl.clear(gl.depth_buffer_bit);          gl.drawelements(gl.triangles, model1.numitems, gl.unsigned_short, 0);     }   this.initdrawdepth = function(size) {          this.depthtextureext = gl.getextension("webgl_depth_texture"); // or browser-appropriate prefix         if(!this.depthtextureext) {              console.log("webgl_depth_texture extension not available!");              return;          }          // create color texture         this.colortexture = gl.createtexture();         gl.bindtexture(gl.texture_2d, this.colortexture);         gl.texparameteri(gl.texture_2d, gl.texture_mag_filter, gl.nearest);         gl.texparameteri(gl.texture_2d, gl.texture_min_filter, gl.nearest);         gl.texparameteri(gl.texture_2d, gl.texture_wrap_s, gl.clamp_to_edge);         gl.texparameteri(gl.texture_2d, gl.texture_wrap_t, gl.clamp_to_edge);         gl.teximage2d(gl.texture_2d, 0, gl.rgba, size, size, 0, gl.rgba, gl.unsigned_byte, null);          this.depthtexture = gl.createtexture();         gl.bindtexture(gl.texture_2d, this.depthtexture);         gl.texparameteri(gl.texture_2d, gl.texture_mag_filter, gl.nearest);         gl.texparameteri(gl.texture_2d, gl.texture_min_filter, gl.nearest);         gl.texparameteri(gl.texture_2d, gl.texture_wrap_s, gl.clamp_to_edge);         gl.texparameteri(gl.texture_2d, gl.texture_wrap_t, gl.clamp_to_edge);         gl.teximage2d(gl.texture_2d, 0, gl.depth_component, size, size, 0, gl.depth_component, gl.unsigned_short, null);         // var framebuffer = gl.createframebuffer();         this.depthframebuffer = gl.createframebuffer();         gl.bindframebuffer(gl.framebuffer, this.depthframebuffer);         gl.framebuffertexture2d(gl.framebuffer, gl.color_attachment0, gl.texture_2d, this.colortexture, 0);         gl.framebuffertexture2d(gl.framebuffer, gl.depth_attachment, gl.texture_2d, this.depthtexture, 0);          if(!gl.checkframebufferstatus(gl.framebuffer) === gl.framebuffer_complete) {             console.log("framebuffer incomplete!");         }          //reset framebuffer         gl.bindframebuffer(gl.framebuffer, null);          this.depthtexturesize = size;      } 

i managed solve problem. had function causing trouble original buffers. tried figure out problem.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -