Questions about Struct and StructBuffer

Started by p3dr0n, January 05, 2024, 23:40:08

Previous topic - Next topic

p3dr0n

Hello, everyone. I'm new here. I was kinda forced to create an account today because I found nothing that could help me with this thing.
I tried searching for tutorials, articles and videos but found nothing.
My problem regards implementing my own Struct<T> to use a StructBuffer<T>, as you might have guessed.
I got somewhere thanks to Netbeans complaints about methods I had to implement.


class Vertex extends Struct<Vertex> {
  public float x, y, z;
  public float u, v;
  
  protected Vertex(long l, ByteBuffer bb) {
    super(l, bb);
  }
  
  @Override
  protected Vertex create(long l, ByteBuffer bb) {
    // I really have no idea what to do here. Maybe read from bb using l?
    // Or use l to allocate something, but how?
  }

  @Override
  public int sizeof() {
    return 5 * Float.BYTES; // this makes sense
  }
}


I also don't have a glue if I need to do anything other than implementing Struct<Vertex>.create to get going.
Sorry to take your time and thank you for it. I also apologize for any misuse inside the forum.

Edit: Forgot to mention that I'm using lwjgl 3.3.3
Edit2: I just noted that there was a better "area" to post this. Sorry again...