0

I need to draw voxels using a float array like this:

{ v1.x, v1.y, v1.z, v1.size, v2.x, [...] }

which in my case, for testing purposes looks like this:

{ -0.6f, -0.4f, -0.0f, 1, 0.6f, -0.4f, -0.0f, 1, 0.f, 0.6f, -0.0f, 1, }

How do I load those up to the GPU and how do I then get the position and size values in the shaders?

genpfault
  • 51,148
  • 11
  • 85
  • 139
l'arbre
  • 719
  • 2
  • 10
  • 29

1 Answers1

1

You need to create a Buffer object of Vertices, then pass it to the GPU using specific APIs. In the shader, you can access data for each vertex. Take a look at the API glBufferData, for example in https://open.gl/drawing.

I am not sure if you would really need the Size/number of the vertices, but if you need it, you would need it to pass it as an uniform via glUniform1f.

Prabindh
  • 3,356
  • 2
  • 23
  • 25