The subject is the question…
AFAIK there is no easy way to do this. You have to draw concentric circles, tesselate them and set vertices color so that it produces the desired effect.
Not really hard per se (at least for a radial gradient), but IMO Java2D is more suited for this task.
A quick and dirty may be to draw lines from center to perimeter with the two gradient color.
WTF? This is dead easy, just make a circle from a triangle fan with its root at the center and use vertex colours for the gradient. Cleaner, simpler, better quality result.
Oops my mistake :-[
Dunno why, I thought long thin triangles had to be avoided. I can’t remember where I read it, but it was probably related to some special case which is irrelevant there
[quote]WTF? This is dead easy, just make a circle from a triangle fan with its root at the center and use vertex colours for the gradient. Cleaner, simpler, better quality result.
[/quote]
can you provide sample code, please? I 'm sorry, but I am new to Open GL.
One more thing? is it posible to combine Java2D and jogl?
This draws a 2D circle centered on (0,0) :
public void radialGradientCircle(GL gl, float[] innerColor, float[] outerColor, int slices, float radius)
{
float incr = (float) (2 * Math.PI / slices);
gl.glBegin(GL.GL_TRIANGLE_FAN);
gl.glColor3fv(innerColor);
gl.glVertex2f(0.0f, 0.0f);
gl.glColor3fv(outerColor);
for(int i = 0; i < slices; i++)
{
float angle = incr * i;
float x = (float) Math.cos(angle) * radius;
float y = (float) Math.sin(angle) * radius;
gl.glVertex2f(x, y);
}
gl.glVertex2f(radius, 0.0f);
gl.glEnd();
}
thanx, man, you rock!