Jump to content
  • Advertisement
Sign in to follow this  
Fenix1186

OpenGL Help using GL_TRIANGLE_FAN to create a circle at mouse click

This topic is 3534 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm new to the forums and a beginner OpenGL programmer. I am attempting to make a simple circle using GL_TRIANGLE_FAN at the position on the screen that the user clicks the mouse. I have the coordinates correct where the user clicks and made a glVertex2f(x,y) for the origin. The problem is the origin is created where the user clicks but the rest of the circle is created at the (0,0) origin with a long cone connecting the origin the user selected with the mouse click and the rest of the circle back at (0,0). Any help would be appreciated. Here is a screenshot of the output: http://i173.photobucket.com/albums/w80/Tiburon1186/Untitled.jpg Here is my display function: void my_display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ; glColor3f(color1,color2,color3) ; if(enable == 1) { int i; int sections = 20; GLfloat radius = 0.02; //radius GLfloat twoPi = 2.0 * 3.14159; glBegin(GL_TRIANGLE_FAN); glVertex2f(my_x/window_w, 1 - my_y/window_h); // origin for(i = 0; i <= sections;i++) { glVertex2f(radius * cos(i * twoPi / sections), radius* sin(i * twoPi / sections)); } glEnd(); } glutSwapBuffers(); return ;

Share this post


Link to post
Share on other sites
Advertisement
in your for loop where you draw the vertices, you are not adding the mouse click coordinates to the vertices

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!