OK…so I ‘m attempting to learn Java and porting some C++/C# code to Java to start to learn JOGL. I have libraries built for all my objects and types but I am really struggling with the omission of pointers in Java amongst others. I am having trouble trying to determine what JOGL wants when arrays are required by OpenGL from my more complex data structures.
I see that glGetIntegerv(int,int,int) for example required a third parameter where the third parameter is the index I assume into the array.
int viewport = new int;
gl.glGetIntegerv(gl.GL_VIEWPORT, viewport); // Fail
gl.glGetIntegerv(gl.GL_VIEWPORT, viewport, 0); // OK
My more complex data structures are compilations of several data structures. None of which are out of the ordinary but I cannot figure out how to pass these complex data structures to the JOGL methods and the compiler messages are vague.
NOTE: I am doing all of this command line as I cannot install an IDE other than Visual Studio where I am located. I’m sure Eclipse would help somewhat if I could install.
An example of a call and data type I am attempting to port is glLoadMatrixf(float) and my structure is…
Matrix4f containing 4 Vector4f for each row; each Vector4f has 4 floats X, Y, Z, W. So I’d like to pass to JOGL Matrix.Row0.X. Assuming Java organizes data like C++/C# I’d suspect the four Vector4f are contiguous and the four floats are contiguous resulting in 16 contiguous floats. Passing a reference to Row0.X should pass an address of the first byte of the contiguous block of floats.
I’m finding that creating a 16 byte float array and passing glLoadMatrixf(m, 0); compiles. Can I even attempt what I am porting or will Java require an entirely different approach?
Matrix4f proj = Matrix4f.CreateProjection(fovRadians, aspect, near, far);
gl.glLoadMatrixf(proj.Row0.X); // gl is passed in GL2 object
Cannot find symbol; method glLoadMatrix(float); interface javax.media.opengl.GL2.