Ferrous Moon
http://www.ferrousmoon.com:80/forums/

OpenGL translucent circle near the center
http://www.ferrousmoon.com:80/forums/viewtopic.php?f=45&t=1915
Page 1 of 1

Author:  eddieringle [Sun Sep 27, 2009 8:18 am ]
Post subject:  OpenGL translucent circle near the center

I've got this "efficient" circle drawing method I found on the web, and what I want to do with it is give it a translucent effect. It's a bit complex though, I want it solid around the perimeter of the circle and gradually turn transparent/translucent as it gets to the circle center. Is there a way to do this with blending/GLSL, or will I have to make an image and work with that? Keep in mind that I'll be rendering many of these circles.
Code:
void drawCircle(float segments, float radius, float sx, float sy) { float theta = 2 * 3.1415926 / segments; float tan_factor = tanf(theta); float radial_factor = cosf(theta); float x = radius; float y = 0; glBegin(GL_POLYGON); for (int ii = 0; ii < segments; ii++) { glVertex2f(x + sx, y + sy); float tx = -y; float ty = x; x += tx * tan_factor; y += ty * tan_factor; x *= radial_factor; y *= radial_factor; } glEnd(); }

Author:  prophile [Sun Sep 27, 2009 9:56 am ]
Post subject:  Re: OpenGL translucent circle near the center

Yes, there is. Make it a triangle fan, draw a point in the middle of the circle with the colour set to transparent and then draw the points round the outside with the colour set to fully opaque, making sure that you put in the first point twice.

It's a similar story with GLSL. Also, immediate mode is the work of the devil, don't ever let me see you using it again, ever.

Author:  eddieringle [Sun Sep 27, 2009 9:59 am ]
Post subject:  Re: OpenGL translucent circle near the center

Quote:
Yes, there is. Make it a triangle fan, draw a point in the middle of the circle with the colour set to transparent and then draw the points round the outside with the colour set to fully opaque, making sure that you put in the first point twice.
That will make it fade to transparent/translucent as it gets to the center?
Quote:
Also, immediate mode is the work of the devil, don't ever let me see you using it again, ever.
I looked at Display Lists, but apparently color information is stored in there too, I want to only store the circle and color them individually. Can I do that?

Author:  eddieringle [Sun Sep 27, 2009 11:06 am ]
Post subject:  Re: OpenGL translucent circle near the center

Okay, I got the circle working properly, now here is my problem:
There will be many (and I mean many) of these circles in the game at one time. Each circle will belong to a group, and each group has certain properties. Also, each individual circle will have it's own radius and (x,y) position.
Based on what I've read about display lists, you can't pass arguments to lists in order to meet the above requirements. Help?

Author:  prophile [Sun Sep 27, 2009 11:14 am ]
Post subject:  Re: OpenGL translucent circle near the center

Did I say 'display lists'? I was referring to vertex buffer objects.

Author:  eddieringle [Sun Sep 27, 2009 11:44 am ]
Post subject:  Re: OpenGL translucent circle near the center

Okay, I've googled everywhere and am having a hard time finding an understandable/up-to-date tutorial on using VBOs.

EDIT: Or, maybe someone can give an example of how I would use VBOs to draw many of these circles?

Page 1 of 1 All times are UTC-05:00
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/