Problem with glDrawArrays

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with glDrawArrays

Matteo Battaglio
Hi,
i'm sure this is a stupid problem, but I'm unable to make glDrawArrays work.
I'm trying to display a simple triangle: if I use glVertex3f(...) for each vertex it works, while if I use glDrawArrays(...) it doesn't.

I've attached my code: Renderer.java
Reply | Threaded
Open this post in threaded view
|

Re: Problem with glDrawArrays

gouessej
Administrator
Where is glColorPointer???
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Problem with glDrawArrays

Matteo Battaglio
I think that if GL_COLOR_ARRAY isn't enabled you can specify the color using glColor4f(...) even if you are using glVertexPointer/glDrawArrays...
However I updated my code and added glColorPointer and the color array, but it still shows nothing.

Here's the code: Renderer.java

Any hints?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with glDrawArrays

gouessej
Administrator
Maybe try to disable explicitly the color array.

Edit.: Don't do this:
Matteo Battaglio wrote
triangle = ByteBuffer.allocateDirect(triangleSizeInBytes).asFloatBuffer();
Use Buffers.newFloatBuffer.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Problem with glDrawArrays [SOLVED]

Matteo Battaglio
gouessej wrote
Don't do this:
Matteo Battaglio wrote
triangle = ByteBuffer.allocateDirect(triangleSizeInBytes).asFloatBuffer();
Use Buffers.newFloatBuffer.
Yeah!!
It solved my problem.
Many thanks for your support!
Reply | Threaded
Open this post in threaded view
|

Re: Problem with glDrawArrays [SOLVED]

gouessej
Administrator
You're welcome. Actually, what you did didn't take into account the native order of your buffers, several beginners here made the same mistake.

You can have a look at my source code if you want to know how to use JOGL (even though I still use JOGL 1.1.1a :(). I looked at it to understand why your code was not working.

Demoscene Passivist and Sven have a lot of examples too.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Problem with glDrawArrays [SOLVED]

Matteo Battaglio
gouessej wrote
You're welcome. Actually, what you did didn't take into account the native order of your buffers, several beginners here made the same mistake.
I understand, damned byte order!

gouessej wrote
You can have a look at my source code if you want to know how to use JOGL (even though I still use JOGL 1.1.1a :(). I looked at it to understand why your code was not working.

Demoscene Passivist and Sven have a lot of examples too.
Thanks for the hint! I'll take a look at your code and examples when I don't understand something...