color
glColorPointer(int i, int j, int k, byte abyte0[])
glColorPointer(int i, int j, int k, short aword0[]);
normal
glNormalPointer(int i, int j, byte abyte0[])
glNormalPointer(int i, int j, short aword0[])
texcoord
glTexCoordPointer(int i, int j, int k, byte abyte0[])
glTexCoordPointer(int i, int j, int k, short aword0[])
vertex
glVertexPointer(int i, int j, int k, byte abyte0[])
glVertexPointer(int i, int j, int k, short aword0[])
please help me how to change the above methods that can run in LWJGL!!
You have to use a NIO Buffer (int, float, depending on the method signature).
See the LWJGL documentation for more details.
http://www.lwjgl.org/javadoc/
glColorPointer
public static void glColorPointer(int size,
int stride,
java.nio.DoubleBuffer pointer)
glColorPointer
public static void glColorPointer(int size,
int stride,
java.nio.FloatBuffer pointer)
but the LWJGL just support FloatBuffer or DoubleBuffer... how to deal with the byte array or short array?
// imports...
FloatBuffer myFloatBuffer = ByteBuffer.allocateDirect(sizeOfArray).asFloatBuffer();
myFloatBuffer.put(myFloatArray);
myFloatBuffer.flip();
// data is in, use it
glColorPointer(sizeOfArray,???,myFloatBuffer);
@???: I think that the stride parameter takes care of the color. i.e. RGB (3) or RGBA (4). THe OpenGL Documentation should clarify this, I do not have a copy of it here at work ;)
//edit: Instead of creating the buffer by yourself you can use the BufferUtils class from the "org.lwjgl" packge.
//edit 2: ByteBuffers are also accepted. Only no shortbuffers. There is no need for them. Because opengl itself uses only floats.
Quote
FloatBuffer myFloatBuffer = ByteBuffer.allocateDirect(sizeOfArray).asFloatBuffer();
It technically should be:
FloatBuffer myFloatBuffer = ByteBuffer.allocateDirect(sizeOfArray).order(ByteOrder.nativeOrder()).asFloatBuffer();
@Evil-Devil. the method you gave is wrong, its this:
glColorPointer(4, 0, myFloatBuffer);
The first argument is 4 if RGBA, and 3 if its RGB. 0 is how much to skip in the myFloatBuffer to obtain the next colour; useful for interleaved arrays.
DP
In GL4JAVA, there has the method as following:
glColorPointer(int i, int j, int k, short aword0[]);
how can I port this method to LWJGL???
Quote from: "darkprophet"
The first argument is 4 if RGBA, and 3 if its RGB. 0 is how much to skip in the myFloatBuffer to obtain the next colour; useful for interleaved arrays.
Ah, thats the stride for :) good to know, need to read more in the ogl bible.
@buffer: I know that it should be ordered by native order, but for the example it should still working. Or he uses the BufferUtils as mentioned.
QuoteIn GL4JAVA, there has the method as following:
glColorPointer(int i, int j, int k, short aword0[]);
how can I port this method to LWJGL???
There is no need to port it (to my knowledge). Just use floats (If Evil-Devil is right (of course he is :lol: ), OpenGL uses floats internally anyways). I think you just divide all the shorts by 255 to get the equivalent float value.