However Java does not support ptrs and must be passed a buffer instead.
Would this be a Java side issue of converting a class to a buffer? In that case I guess I may have to ask this question somewhere else?
I’m quite lost here so any suggestions would be greatly appreciated.
After doing a bit more research and using some different keywords I’ve come across a stackoverflow answer that describes converting my entire class into a single float array and then converting that array to a bytebuffer.
To get my class values of:
public class Node
{
public float pos;
public float h;
public float g;
public float f;
}
What java library are you using for the OpenGL bindings?
If it is LWJGL then your approach will not work as you need to set the buffers byte order and you also have to rewind it. If you are new to LWJGL I would recommend reading its documentation and many tutorials.
I’m not entirely sure what this means, I’ve seen a lot of information about JOGL and LWJGL online but I don’t believe I’ve been in contact with any of these.
I’m using Android Studio and I’m using OpenGLES3.1.
I followed Google’s documentation to get OpenGL working in my Android Application.
The answer would be the same for desktop GL as for ES. The problem is (at least from my perspective) Java.
OpenGL, of either form, was designed for C. And thus, OpenGL’s layout rules for buffer-backed interface blocks are built around what you can do with C. You can design C structs to match OpenGL’s standardized layout rules, such that you just do a memcpy from your array of structs into a buffer object.
That’s not really possible in Java. Which means that every Java implementation of OpenGL has to find some way of getting arbitrary data into a buffer object. Thus, the only people who could help you are those who are Java programmers, OpenGL ES programmers, using the Android OpenGL ES implementation, and who are using modern OpenGL techniques like UBOs and SSBO.
Outside of an Android forum, Stack Overflow is probably your best bet, considering that your problem rests at the intersection of so many distinct issues.
Do note that it is very important to follow the layout rules (PDF). And if you’re using this Vector2f struct in GLSL (instead of vec2), then that can impact how the object is laid out in memory. So your array of floats approach can work, but you need to make sure that you’re padding it correctly.