LWJGL Forum

Programming => OpenGL => Topic started by: deepthought on July 27, 2011, 19:45:10

Title: matrix operations in java
Post by: deepthought on July 27, 2011, 19:45:10
since we're now supposed to come up with our own modelview and projection matrices, does anybody have a java implementation of ortho(), perspective(), glulookat(), and possibly a camera class that generates the matrices?
Title: Re: matrix operations in java
Post by: CodeBunny on July 28, 2011, 12:22:34
Um... why don't you use the glOrth(), gluLookAt(), etc. methods already in LWJGL? They work...

Also, if my understanding of what you're attempting to do instead is correct (create a matrix and send it over to the GPU once it has been constructed), I don't really see how that would be faster - especially because you have to send an entire matrix down the graphics pipeline every time you want to make a change.
Title: Re: matrix operations in java
Post by: jediTofu on July 29, 2011, 03:15:19
Is this like for a homework assignment?  Mesa3d is an open source implementation of the OpenGL specification (I believe ???), so you could download the source code and look at the math there (for the specific methods) and do a good old copy&paste.  Then manipulate it to your liking.  It's probably in C, which shouldn't be hard to translate to Java.

Otherwise...do a google search?
Title: Re: matrix operations in java
Post by: deepthought on July 29, 2011, 23:57:49
in the current version of opengl, these functions are deprecated, and in opengl ES, totally absent. we are now supposed to come up with it ourselves and load it as a uniform into a shader.
Title: Re: matrix operations in java
Post by: Grabix on July 30, 2011, 22:46:14
ortho(), perspective(), glulookat()

Every of such transforamtion are basen on multiplication of vector [x y z 1] by same matrix, this matrix are also a multiplication of same basic matrixes; each of such methode produce one of them and this is described in documentation of OpenGL:

for reference:
http://www.opengl.org/sdk/docs/man/xhtml/glTranslate.xml
http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml
http://www.opengl.org/sdk/docs/man/xhtml/glScale.xml

about your question:
http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml
http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml

I think this is more complicated (not sure, I don't want to read :P)
http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml