diff --git a/README.md b/README.md index 9b03c06..898c656 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ Tarek Sherif writes a really helpful [WebGL 2 Examples](https://github.com/tsher |[fbo_rtt_draw_buffers](http://webglsamples.org/WebGL2Samples/#fbo_rtt_draw_buffers)|:white_check_mark:|TODO|:white_check_mark:|TODO| |[fbo_rtt_texture_array](http://webglsamples.org/WebGL2Samples/#fbo_rtt_texture_array)|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:| |[fbo_rtt_depth_texture](http://webglsamples.org/WebGL2Samples/#fbo_rtt_depth_texture)|:white_check_mark:|TODO|:white_check_mark:|TODO| +|[fbo_read_pixels](http://webglsamples.org/WebGL2Samples/#fbo_read_pixels)|:white_check_mark:|TODO|:white_check_mark:|TODO| |[fbo_blit](http://webglsamples.org/WebGL2Samples/#fbo_blit)|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:| |[fbo_multisample](http://webglsamples.org/WebGL2Samples/#fbo_multisample)|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:| |[fbo_new_blend_equation](http://webglsamples.org/WebGL2Samples/#fbo_new_blend_equation)|:white_check_mark:|:white_check_mark:|:white_check_mark:|:white_check_mark:| diff --git a/index.html b/index.html index 9b0b67f..87d4d67 100644 --- a/index.html +++ b/index.html @@ -205,7 +205,8 @@
+ This sample demonstrates rendering to texture in a frame buffer using a texture array. And readpixels from this frame buffer. The data read is printed in the console. +
+ + + + + + + + + + + + + + + diff --git a/samples/fbo_rtt_texture_array.html b/samples/fbo_rtt_texture_array.html index 8d303ad..b3b496a 100644 --- a/samples/fbo_rtt_texture_array.html +++ b/samples/fbo_rtt_texture_array.html @@ -13,7 +13,7 @@- This sample demonstrates rendering to texture in a frame buffer using a texture array. And readpixels from this frame buffer. + This sample demonstrates rendering to texture in a frame buffer using a texture array.
- + diff --git a/samples/glsl_flat_smooth_interpolators.html b/samples/glsl_flat_smooth_interpolators.html index 1ba4035..d07e2a1 100644 --- a/samples/glsl_flat_smooth_interpolators.html +++ b/samples/glsl_flat_smooth_interpolators.html @@ -260,7 +260,7 @@ // -- Render loop (function render() { gl.clearColor(0.0, 0.0, 0.0, 1.0); - gl.clear(gl.COLOR_BUFFER_BIT); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); mat4.rotateY(modelView, modelView, rotatationSpeedY); diff --git a/samples/query_occlusion.html b/samples/query_occlusion.html index 0260735..8346198 100644 --- a/samples/query_occlusion.html +++ b/samples/query_occlusion.html @@ -21,11 +21,11 @@ precision highp float; precision highp int; - layout(location = POSITION_LOCATION) in vec2 pos; + layout(location = POSITION_LOCATION) in vec3 pos; void main() { - gl_Position = vec4(pos,0.0,1.0); + gl_Position = vec4(pos, 1.0); } @@ -38,7 +38,7 @@ void main() { - color = vec4(1.0,0.5,0.0,1.0); + color = vec4(1.0, 0.5, 0.0, 1.0); } @@ -64,12 +64,17 @@ // -- Init Program var program = createProgram(gl, getShaderSource('vs'), getShaderSource('fs')); gl.useProgram(program); + gl.enable(gl.DEPTH_TEST); // -- Init Buffer var vertices = new Float32Array([ - -0.3, -0.5, - 0.3, -0.5, - 0.0, 0.5 + -0.3, -0.5, 0.0, + 0.3, -0.5, 0.0, + 0.0, 0.5, 0.0, + + -0.3, -0.5, 0.5, + 0.3, -0.5, 0.5, + 0.0, 0.5, 0.5 ]); var vertexPosBuffer = gl.createBuffer(); gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer); @@ -81,7 +86,7 @@ var vertexPosLocation = 0; // set with GLSL layout qualifier gl.enableVertexAttribArray(vertexPosLocation); - gl.vertexAttribPointer(vertexPosLocation, 2, gl.FLOAT, false, 0, 0); + gl.vertexAttribPointer(vertexPosLocation, 3, gl.FLOAT, false, 0, 0); gl.bindVertexArray(null); @@ -90,12 +95,14 @@ // -- Render gl.clearColor(0.0, 0.0, 0.0, 1.0); - gl.clear(gl.COLOR_BUFFER_BIT); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); gl.bindVertexArray(vertexArray); + gl.drawArrays(gl.TRIANGLES, 0, 3); + gl.beginQuery(gl.ANY_SAMPLES_PASSED, query); - gl.drawArraysInstanced(gl.TRIANGLES, 0, 3, 2); + gl.drawArrays(gl.TRIANGLES, 3, 3); gl.endQuery(gl.ANY_SAMPLES_PASSED); (function tick() { @@ -117,6 +124,6 @@ gl.deleteVertexArray(vertexArray); })(); - +