Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does webGL contain push/popMatrix?

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

like image 691
CyanPrime Avatar asked Jun 27 '12 17:06

CyanPrime


1 Answers

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.

like image 93
Justin Meiners Avatar answered Sep 19 '22 06:09

Justin Meiners