PDA

View Full Version : Can GLM be used in Java? OpenGL LWJGL



Hugo_the_Dwarf
07-17-2013, 01:33 PM
Hey I've been trying to get some Multi-Texturing to work for my own Game Engine and I'm following this:http://3dgep.com/?p=1116
Yes it's in C++ and i'm doing mine in Java, however the use of "glm::<command>" has be deterred as:
1. I have no idea what those commands do in the background, so I have no idea how to replicate that.
2. I have no access to any glm::commands (and i'm sure anything that has a "::" is a C++ only operator)

So question(s) is:
-Can I use glm features in Java (if so how? Download and import, simple import that is in OpenGL already?)
-If glm features are C++ (or any C related OpenGL) then what do these commands do?
--glm::normalize( m_NormalBuffer[i] );
--glm::saturate( glm::dot( m_NormalBuffer[i], UP ) - 0.1f );

I've been stuck on this problem for way to long and would like to move onto other parts of the engine, and I'm really new to OpenGL so all this is a bit much to take in all at once and understand
(not a new programmer, just new to OpenGL and even the Java Code)

PS:
If my coded is needed to be posted I'll do so. Some of it is commented and other parts are not.

Alfonse Reinheart
07-17-2013, 02:20 PM
GLM is a C++ library. If you want to use a C++ library in Java, you're going to have to write some interface from the C++ library to Java.

carsten neumann
07-17-2013, 02:25 PM
GLM (http://glm.g-truc.net/) is a vector/matrix math library that (to the extent possible in C++) follows the syntax of the OpenGL shading language GLSL. You can not use GLM from Java since it is a C++ library, but I'm sure there are vector/matrix libraries for use with OpenGL for Java - unfortunately I'm not very familiar with the library landscape for Java so can not recommend one. You can look at the GLSL reference pages (http://www.opengl.org/sdk/docs/manglsl/) or the GLSL spec for the meaning of specific functions.

Hugo_the_Dwarf
07-17-2013, 04:35 PM
GLM is a C++ library. If you want to use a C++ library in Java, you're going to have to write some interface from the C++ library to Java.

Ah thank you, I had a suspension that it was C++ only, but didn't want to fully assume


GLM (http://glm.g-truc.net/) is a vector/matrix math library that (to the extent possible in C++) follows the syntax of the OpenGL shading language GLSL. You can not use GLM from Java since it is a C++ library, but I'm sure there are vector/matrix libraries for use with OpenGL for Java - unfortunately I'm not very familiar with the library landscape for Java so can not recommend one. You can look at the GLSL reference pages (http://www.opengl.org/sdk/docs/manglsl/) or the GLSL spec for the meaning of specific functions.

And that reference link is really helpful saddly it lacks saturate but I can kinda guess what it does since i's using glm::dot

Thanks guys

rakketh
07-18-2013, 12:01 AM
I'm new to OpenGL, so this might be bad information, but I'm also using it from Java (JOGL) and have been wondering about vector/matrix libraries too. I have seen that the android libraries have a Matrix class (developer.android.com/reference/android/opengl/Matrix.html) and some GLutilities classes for camera view and such, so I was thinking I might import that library even for desktop usage. I can't see any specific vertex utilities there for dot/cross product, etc., but this link might be helpful: code.google.com/p/android-gl/source/browse/trunk/AndroidGL/src/edu/union/MatrixUtils.java

(Can't post as links for some reason, maybe because I am new to the forums?)