Drawing many shapes in WebGL

后端 未结 3 1364
小鲜肉
小鲜肉 2020-11-27 07:36

I was reading tutorials from here.



        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 08:06

    Create your buffers separately for each object you want on the scene otherwise they won't be able to move and use shader effects independently.

    But that is in case your objects are different. From what I got here I think you just want to draw the same shape more than once on different positions right?

    The way you go about that is you just set that translationLocation uniform right there with a different translation matrix after drawing the shape for the first time. That way when you draw the shape again it will be located somewhere else and not in top of the other one so you can see it. You can set all those transformation matrices differently and then just call gl.drawElements again since you're going to draw the same buffers that are already in use.

提交回复
热议问题