<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 30. OpenGL Circle Drawing</title>
	<atom:link href="http://www.swiftless.com/tutorials/opengl/circle.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.swiftless.com/tutorials/opengl/circle.html</link>
	<description>Game Programming and Computer Graphics Tutorials</description>
	<lastBuildDate>Wed, 01 Feb 2012 09:19:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Bob</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-4208</link>
		<dc:creator>Bob</dc:creator>
		<pubDate>Sat, 07 Jan 2012 18:47:17 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-4208</guid>
		<description>6.28f is simply 2 * PI. PI is 3.14159.... which you will see in geometry books. It is the constant that maps a circle radius to its circumference.</description>
		<content:encoded><![CDATA[<p>6.28f is simply 2 * PI. PI is 3.14159&#8230;. which you will see in geometry books. It is the constant that maps a circle radius to its circumference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: durga</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-3681</link>
		<dc:creator>durga</dc:creator>
		<pubDate>Wed, 14 Dec 2011 08:11:55 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-3681</guid>
		<description>Bob,

  How did you arrive at the  constant 6.28f in the below lines

onst int kSegments = 30;
const GLfloat kRadianIncr = 6.28f/kSegments;</description>
		<content:encoded><![CDATA[<p>Bob,</p>
<p>  How did you arrive at the  constant 6.28f in the below lines</p>
<p>onst int kSegments = 30;<br />
const GLfloat kRadianIncr = 6.28f/kSegments;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tuhin</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1916</link>
		<dc:creator>tuhin</dc:creator>
		<pubDate>Tue, 12 Jul 2011 00:00:11 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1916</guid>
		<description>very nice presentation.
i try this code 
&quot;
#include 
#include 
#include 

GLfloat d;

float p1x=0.0;
float p1y=0.0;
float p1z=0.0;

const float p1radius = 8.0;
const float p2radius = 8.0;
float yRotationAngle = 0.0f;
int k=0,l=0;
float p2x=0.0;
float p2y=0.0;
float p2z=0.0;

void collision (void) {
d = sqrt(((p1x - p2x) * (p1x - p2x)) + ((p1y - p2y) * (p1y - p2y))+ ((p1z - p2z) * (p1z - p2z)));
}

void pointz (void) {
glPushMatrix();
if (d 2.0)
k=1;
if(p1x2.0)
l=1;
if(p2y 360.0f) // If we have rotated beyond 360 degrees (a full rotation)
yRotationAngle -= 360.0f; // Subtract 360 degrees off of our rotation

}

void reshape (int w, int h) {
    glViewport (0, 0, (GLsizei)w, (GLsizei)h);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();
    gluPerspective (60, (GLfloat)w / (GLfloat)h, 1.0, 100.0);
    glMatrixMode (GL_MODELVIEW);
}

void keyboard (unsigned char key, int x, int y) {
if (key==&#039;q&#039;) {
p1z = p1z - 0.1;
}

if (key==&#039;z&#039;) {
p1z = p1z + 0.1;
}

if (key==&#039;w&#039;) {
p1y = p1y + 0.1;
}

if (key==&#039;s&#039;) {
p1y = p1y - 0.1;
}

if (key==&#039;a&#039;) {
p1x = p1x - 0.1;
}

if (key==&#039;d&#039;) {
p1x = p1x + 0.1;
}

if (key==&#039;i&#039;) {
p2y = p2y + 0.1;
}

if (key==&#039;k&#039;) {
p2y = p2y - 0.1;
}

if (key==&#039;j&#039;) {
p2x = p2x - 0.1;
}

if (key==&#039;l&#039;) {
p2x = p2x + 0.1;
}

if (key==27) { //27 is the ascii code for the ESC key
    exit (0); //end the program
}
}

int main (int argc, char **argv) {
    glutInit (&amp;argc, argv);
    glutInitDisplayMode (GLUT_DOUBLE); //set up the double buffering
    glutInitWindowSize (500, 500);
    glutInitWindowPosition (100, 100);
    glutCreateWindow (&quot;A basic OpenGL Window&quot;);
    glutDisplayFunc (display);
    glutIdleFunc (display);
    glutReshapeFunc (reshape);
    glutKeyboardFunc (keyboard);//the call for the keyboard function.
    glutMainLoop ();
    return 0;
}
but there is no collision?
plz clear me this topic.
thanks in advance.
&quot;</description>
		<content:encoded><![CDATA[<p>very nice presentation.<br />
i try this code<br />
&#8221;<br />
#include<br />
#include<br />
#include </p>
<p>GLfloat d;</p>
<p>float p1x=0.0;<br />
float p1y=0.0;<br />
float p1z=0.0;</p>
<p>const float p1radius = 8.0;<br />
const float p2radius = 8.0;<br />
float yRotationAngle = 0.0f;<br />
int k=0,l=0;<br />
float p2x=0.0;<br />
float p2y=0.0;<br />
float p2z=0.0;</p>
<p>void collision (void) {<br />
d = sqrt(((p1x &#8211; p2x) * (p1x &#8211; p2x)) + ((p1y &#8211; p2y) * (p1y &#8211; p2y))+ ((p1z &#8211; p2z) * (p1z &#8211; p2z)));<br />
}</p>
<p>void pointz (void) {<br />
glPushMatrix();<br />
if (d 2.0)<br />
k=1;<br />
if(p1x2.0)<br />
l=1;<br />
if(p2y 360.0f) // If we have rotated beyond 360 degrees (a full rotation)<br />
yRotationAngle -= 360.0f; // Subtract 360 degrees off of our rotation</p>
<p>}</p>
<p>void reshape (int w, int h) {<br />
    glViewport (0, 0, (GLsizei)w, (GLsizei)h);<br />
    glMatrixMode (GL_PROJECTION);<br />
    glLoadIdentity ();<br />
    gluPerspective (60, (GLfloat)w / (GLfloat)h, 1.0, 100.0);<br />
    glMatrixMode (GL_MODELVIEW);<br />
}</p>
<p>void keyboard (unsigned char key, int x, int y) {<br />
if (key==&#8217;q') {<br />
p1z = p1z &#8211; 0.1;<br />
}</p>
<p>if (key==&#8217;z') {<br />
p1z = p1z + 0.1;<br />
}</p>
<p>if (key==&#8217;w') {<br />
p1y = p1y + 0.1;<br />
}</p>
<p>if (key==&#8217;s') {<br />
p1y = p1y &#8211; 0.1;<br />
}</p>
<p>if (key==&#8217;a') {<br />
p1x = p1x &#8211; 0.1;<br />
}</p>
<p>if (key==&#8217;d') {<br />
p1x = p1x + 0.1;<br />
}</p>
<p>if (key==&#8217;i') {<br />
p2y = p2y + 0.1;<br />
}</p>
<p>if (key==&#8217;k') {<br />
p2y = p2y &#8211; 0.1;<br />
}</p>
<p>if (key==&#8217;j') {<br />
p2x = p2x &#8211; 0.1;<br />
}</p>
<p>if (key==&#8217;l') {<br />
p2x = p2x + 0.1;<br />
}</p>
<p>if (key==27) { //27 is the ascii code for the ESC key<br />
    exit (0); //end the program<br />
}<br />
}</p>
<p>int main (int argc, char **argv) {<br />
    glutInit (&#038;argc, argv);<br />
    glutInitDisplayMode (GLUT_DOUBLE); //set up the double buffering<br />
    glutInitWindowSize (500, 500);<br />
    glutInitWindowPosition (100, 100);<br />
    glutCreateWindow (&#8220;A basic OpenGL Window&#8221;);<br />
    glutDisplayFunc (display);<br />
    glutIdleFunc (display);<br />
    glutReshapeFunc (reshape);<br />
    glutKeyboardFunc (keyboard);//the call for the keyboard function.<br />
    glutMainLoop ();<br />
    return 0;<br />
}<br />
but there is no collision?<br />
plz clear me this topic.<br />
thanks in advance.<br />
&#8220;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bob</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1699</link>
		<dc:creator>bob</dc:creator>
		<pubDate>Thu, 02 Jun 2011 00:03:47 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1699</guid>
		<description>I believe using a GL_TRIANGLE_FAN drawing mode reuses the center vertex for better performance.</description>
		<content:encoded><![CDATA[<p>I believe using a GL_TRIANGLE_FAN drawing mode reuses the center vertex for better performance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: spinout</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1698</link>
		<dc:creator>spinout</dc:creator>
		<pubDate>Wed, 01 Jun 2011 02:44:39 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1698</guid>
		<description>I would stray away from everything GLUT related.</description>
		<content:encoded><![CDATA[<p>I would stray away from everything GLUT related.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bob</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1690</link>
		<dc:creator>bob</dc:creator>
		<pubDate>Fri, 27 May 2011 07:27:14 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1690</guid>
		<description>You are not passing in radians to the trig functions. I made your algorithm more mathematically clear. For example the number of segments now can be be adjusted for circle resolution (30 segments is good enough for my example). kSegments = 5 gives a pentagon ! Also only one glVertex call using GL_LINE_LOOP. I took out the translation h, k for simplicity:


static void drawCircle (int r) {
    CIRCLE circle;
    glBegin(GL_LINE_LOOP);
    int i = 0;
    const int kSegments = 30;
    const GLfloat kRadianIncr = 6.28f/kSegments;
    for (i = 0; i &lt; kSegments; i++)
    {
        GLfloat angleRadians = kRadianIncr*i;
        circle.x = r * cos(angleRadians);
        circle.y = r * sin(angleRadians);
        glVertex3f(circle.x,circle.y,0);
    }
    glEnd();
}</description>
		<content:encoded><![CDATA[<p>You are not passing in radians to the trig functions. I made your algorithm more mathematically clear. For example the number of segments now can be be adjusted for circle resolution (30 segments is good enough for my example). kSegments = 5 gives a pentagon ! Also only one glVertex call using GL_LINE_LOOP. I took out the translation h, k for simplicity:</p>
<p>static void drawCircle (int r) {<br />
    CIRCLE circle;<br />
    glBegin(GL_LINE_LOOP);<br />
    int i = 0;<br />
    const int kSegments = 30;<br />
    const GLfloat kRadianIncr = 6.28f/kSegments;<br />
    for (i = 0; i &lt; kSegments; i++)<br />
    {<br />
        GLfloat angleRadians = kRadianIncr*i;<br />
        circle.x = r * cos(angleRadians);<br />
        circle.y = r * sin(angleRadians);<br />
        glVertex3f(circle.x,circle.y,0);<br />
    }<br />
    glEnd();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swiftless</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1547</link>
		<dc:creator>Swiftless</dc:creator>
		<pubDate>Thu, 03 Mar 2011 05:37:48 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1547</guid>
		<description>Hi Olgis,

Yes you can, but the point of this tutorial is to show you don&#039;t need a third party library to make these shapes. This also gives you more control, you can put this inside of a VBO easily, unlike glu methods.

Cheers,
Swiftless</description>
		<content:encoded><![CDATA[<p>Hi Olgis,</p>
<p>Yes you can, but the point of this tutorial is to show you don&#8217;t need a third party library to make these shapes. This also gives you more control, you can put this inside of a VBO easily, unlike glu methods.</p>
<p>Cheers,<br />
Swiftless</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olgis</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1535</link>
		<dc:creator>Olgis</dc:creator>
		<pubDate>Mon, 28 Feb 2011 11:50:36 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1535</guid>
		<description>Hi 
 Nice post. 
You can get the same result with 	gluDisk(gluNewQuadric(), inner, outer, slices, loops), for more details see 
http://www.talisman.org/opengl-1.1/Reference/gluDisk.html
and if you need to draw part of a circle you can use gluPartialDisk.

 Cheers, o.</description>
		<content:encoded><![CDATA[<p>Hi<br />
 Nice post.<br />
You can get the same result with 	gluDisk(gluNewQuadric(), inner, outer, slices, loops), for more details see<br />
<a href="http://www.talisman.org/opengl-1.1/Reference/gluDisk.html"  rel="nofollow">http://www.talisman.org/opengl-1.1/Reference/gluDisk.html</a><br />
and if you need to draw part of a circle you can use gluPartialDisk.</p>
<p> Cheers, o.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Swiftless</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1065</link>
		<dc:creator>Swiftless</dc:creator>
		<pubDate>Sun, 05 Dec 2010 23:31:46 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1065</guid>
		<description>Hey Pisit,

Sure, just make sure you add a glVertex call before and after the loop to set the start and end points. 

Cheers,
Swiftless</description>
		<content:encoded><![CDATA[<p>Hey Pisit,</p>
<p>Sure, just make sure you add a glVertex call before and after the loop to set the start and end points. </p>
<p>Cheers,<br />
Swiftless</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fakhir</title>
		<link>http://www.swiftless.com/tutorials/opengl/circle.html/comment-page-1#comment-1058</link>
		<dc:creator>Fakhir</dc:creator>
		<pubDate>Fri, 26 Nov 2010 20:28:51 +0000</pubDate>
		<guid isPermaLink="false">http://swiftless.com/wordpress/?p=206#comment-1058</guid>
		<description>Sorry, missed glBegin(GL_LINE_LOOP); in the beginning =]</description>
		<content:encoded><![CDATA[<p>Sorry, missed glBegin(GL_LINE_LOOP); in the beginning =]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

