Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include "PieChart.h"
  2. #include <Windows.h>
  3. #include <gl/GL.h>
  4. #include <math.h>
  5.  
  6. PieChart::PieChart()
  7. {
  8.  
  9. }
  10.  
  11. PieChart::~PieChart()
  12. {
  13.  
  14. }
  15.  
  16. void PieChart::Render()
  17. {
  18.     glEnable(GL_BLEND);
  19.     glEnable(GL_POLYGON_SMOOTH);
  20.     glShadeModel(GL_FLAT);
  21.     glBegin(GL_TRIANGLE_FAN);
  22.  
  23.     //center of fan
  24.     glVertex2f(0.0f, 0.0f);
  25.  
  26.     for (angle = 0.0f; angle <= (25.0f * GL_PI); angle += (GL_PI / 30.0f))
  27.     {
  28.         //calculate x and y position of the next vertex
  29.         y = 300.0f*sin(angle);
  30.         x = 300.0f*cos(angle);
  31.  
  32.         //alternate colours
  33.         if (pivot)
  34.         {
  35.             pivot = false;
  36.             glColor3f(1.0f, .0f, 0.0f);
  37.         }
  38.         else
  39.         {
  40.             pivot = true;
  41.             glColor3f(0.0f, 0.0f, 1.0f);
  42.         }
  43.  
  44.         //specify the next vertex
  45.         glVertex2f(x, y);
  46.     }
  47.  
  48.     glEnd();
  49. }
  50.  
  51. bool PieChart::MouseMove(int x, int y)
  52. {
  53.     return true;
  54. }
  55.  
  56. bool PieChart::MouseLBUp(int x, int y)
  57. {
  58.     return true;
  59. }
  60. bool PieChart::MouseLBDown(int x, int y)
  61. {
  62.     return true;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement