Does webGL contain push/popMatrix?

橙三吉。 提交于 2019-12-22 05:18:33

问题


Does webGL contain push/popMatrix? and if not, how would I go about recreating them?


回答1:


No, WebGL is based off of OpenGL ES 2.0, so there is no built in matrix management or fixed function pipeline. The model view and projection matrices need to be completely managed in your own code and passed to shaders at draw time. You really don't need push and pop matrix if you are using a scene graph or some kind of other similar scene management system. All you really need is a good matrix and vector math library.

If you are still set on using push and pop matrix, you could simply use an array of matrices, and write functions like push and pop that simply save your current matrix into the array and push or pop the index down.

I would get the OpenGL ES 2.0 programming guide if you need more help with transitioning to WebGL. The book's website here: http://opengles-book.com/ contains a download link to some source code with demos for a variety of platforms and languages including WebGL. It also contains a decent math library if you need it.




回答2:


From what I see here and there, there is no native support but you can easily build such a stack with an Array.



来源:https://stackoverflow.com/questions/11231619/does-webgl-contain-push-popmatrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!