Hi There
I am trying to use glVertexPointer ( and all those Pointers ), however. I get an error with a FloatBuffer (one of the arguments required ). Oh, and I do not know exactlly how to use FloatBuffer. Please help me to point out the err in my logic.
I am tyring to draw simple quad in here
declaration
private final float quadVertices[] = { 1f, 1f, -5,
-1f, -1f, -5,
1f, -1f, -5,
1f, 1f, -5 };
and in the create mode
GL11.glVertexPointer( 3, GL11.GL_FLOAT, FloatBuffer.wrap( quadVertices ));
error
java.lang.IllegalArgumentException: FloatBuffer is not direct
Again, as in my GLUT topic I am just trying to follow my new OpenGL book and this time it seems that the technique is cool but a shame is I cannot port it into Java.
Regards
:D
You need to create a direct float buffer.
You could use BufferUtils.createFloatBuffer
Hey
Thanks for the reply. I am almost done with it, however. It looks like there is a mistake in my code and I cannot find it. Here is what I got: (mehtod to render simple quad )
public void quad(){
GL11.glEnableClientState( GL11.GL_VERTEX_ARRAY );
GL11.glEnableClientState( GL11.GL_COLOR_ARRAY );
GL11.glPolygonMode( GL11.GL_FRONT, GL11.GL_FILL );
GL11.glRotatef( rot, 0f, 0f, 1f );
FloatBuffer colorsBuffer = BufferUtils.createFloatBuffer( 12 );
FloatBuffer quadBuffer = BufferUtils.createFloatBuffer( 12 );
colorsBuffer.put( quadColors );
quadBuffer.put( quadVertices );
GL11.glColorPointer( 3, GL11.GL_FLOAT, colorsBuffer );
GL11.glVertexPointer( 3,GL11.GL_FLOAT, quadBuffer );
}
The problem is that the Quad I am trying to draw is not being rendered. Any ideas?
You need to call a render method for the arrays you set up:
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 12);
(Or something simmilar :lol: )
Thanks a lot that actually help. Silly me, I was reading book and stopped to jump into codeing without reading further on that topic.
Regards
Oh and if anyone else has a problem with that, drop me a note and I will post a code.
Quote from: "DustWorm2"
Oh and if anyone else has a problem with that, drop me a note and I will post a code.
Hi. I am a Direct3D programmer.
I am having trouble making VBs work with LWJGL.
I would appreciate if you post the code.
Thank you in advance
Tiago