lightice11
lightice11

Reputation: 19

Correctly using glVertexPointer?

Whenever I look a tutorials that explain how to use the glDrawArrays and the glVertexPointer commands, the arguments they use are different from the ones I have available.

For example : a tutorial calls glVertexPointer with parameters like this : (Vertices is an array of floats)

glVertexPointer(3, GL_FLOAT, 0, Vertices);

The parameters that I have available are :

glVertexPointer(int size, int stride, FloatBuffer pointer);

My question is : What is the correct way to use glVertexPointer()?

Upvotes: 0

Views: 1190

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473407

glVertexPointer, as the name suggests, is based on using pointers. You're using Java, where pointers don't exist. Therefore, the Java equivalent has to work differently. It has to take a special memory array object, which can internally be converted into a C pointer that will be passed to the actual glVertexPointer call.

Because Java puts a type on the buffer's contents, you don't need an explicit type field. There are several overloads of glVertexPointer in LWJGL, each of which takes a different type of buffer.

Upvotes: 2

Related Questions