drawing - webGL : draw two separate rect with one buffer -
my problem simple, build array 2 square coord :
var vertices = [ -64, -32, 0.0, 64, -32, 0.0, 64, 32, 0.0, -64, -32, 0.0, -64, 32, 0.0, 64, 32, 0.0 ]; vertices.push( -64 + 200, -32, 0.0, 64 + 200, -32, 0.0, 64 + 200, 32, 0.0, -64 + 200, -32, 0.0, -64 + 200, 32, 0.0, 64 + 200, 32, 0.0 );
but resulting drawing looks :
expected result should 2 separate rect black color between them. , don't understand behavior.
when using triangle strips vertices implicitly indexed:
draws series of triangles (three-sided polygons) using vertices v0, v1, v2, v2, v1, v3 (note order), v2, v3, v4, , on. ordering ensure triangles drawn same orientation strip can correctly form part of surface.
if 1 want have separate triangles using triangle strips, 1 need add "stop vertices" generate degenerated triangle.
read answer explanation(with images) of triangle_strip
, triangle_fan
.
however triangle strips(and fans) can quite cumbersome work if you're not planning explicitly build strips or fans. , looking @ vertex layout i'm assuming want use plain triangles
render geometry.
Comments
Post a Comment