Last visit was: It is currently Mon Dec 10, 2018 12:13 am


All times are UTC-05:00




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
 Post subject: OpenGL translucent circle near the center
PostPosted: Sun Sep 27, 2009 8:18 am 
User avatar
 

Joined: Sun Feb 12, 2006 8:56 pm
Posts: 1019
Website: http://eddieringle.com
Location: Detroit, MI
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(); }

_________________
-- Eddie Ringle

Check out Elysian Shadows and consider backing us on Kickstarter!

====================================

Image


Top
Offline   
 Post subject: Re: OpenGL translucent circle near the center
PostPosted: Sun Sep 27, 2009 9:56 am 
Connoisseur of the Godawful
User avatar
 

Joined: Tue Mar 01, 2005 9:00 am
Posts: 456
ICQ: 286315965
Website: http://rabidtinker.mine.nu/
Yahoo Messenger: alistair_lynn
AOL: Agent_Vast@mac.com
Location: 127.0.0.1
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.

_________________
Alastair Lynn / Alumnus / Onlink Team


Top
Offline   
 Post subject: Re: OpenGL translucent circle near the center
PostPosted: Sun Sep 27, 2009 9:59 am 
User avatar
 

Joined: Sun Feb 12, 2006 8:56 pm
Posts: 1019
Website: http://eddieringle.com
Location: Detroit, MI
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?

_________________
-- Eddie Ringle

Check out Elysian Shadows and consider backing us on Kickstarter!

====================================

Image


Top
Offline   
 Post subject: Re: OpenGL translucent circle near the center
PostPosted: Sun Sep 27, 2009 11:06 am 
User avatar
 

Joined: Sun Feb 12, 2006 8:56 pm
Posts: 1019
Website: http://eddieringle.com
Location: Detroit, MI
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?

_________________
-- Eddie Ringle

Check out Elysian Shadows and consider backing us on Kickstarter!

====================================

Image


Top
Offline   
 Post subject: Re: OpenGL translucent circle near the center
PostPosted: Sun Sep 27, 2009 11:14 am 
Connoisseur of the Godawful
User avatar
 

Joined: Tue Mar 01, 2005 9:00 am
Posts: 456
ICQ: 286315965
Website: http://rabidtinker.mine.nu/
Yahoo Messenger: alistair_lynn
AOL: Agent_Vast@mac.com
Location: 127.0.0.1
Did I say 'display lists'? I was referring to vertex buffer objects.

_________________
Alastair Lynn / Alumnus / Onlink Team


Top
Offline   
 Post subject: Re: OpenGL translucent circle near the center
PostPosted: Sun Sep 27, 2009 11:44 am 
User avatar
 

Joined: Sun Feb 12, 2006 8:56 pm
Posts: 1019
Website: http://eddieringle.com
Location: Detroit, MI
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?

_________________
-- Eddie Ringle

Check out Elysian Shadows and consider backing us on Kickstarter!

====================================

Image


Top
Offline   
Display posts from previous:  Sort by  
Post new topic  Reply to topic

All times are UTC-05:00


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created by Miah with assistance from hyprnova