Computer Graphics - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Computer Graphics

Description:

Computer Graphics. CS 385. February 14, 2005. 3-dimensional gasket ... #include GL/glut.h // define a point data type. typedef struct { float x,y,z;} point; ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 9
Provided by: homeSou5
Category:

less

Transcript and Presenter's Notes

Title: Computer Graphics


1
Computer Graphics
  • CS 385
  • February 14, 2005

2
3-dimensional gasket
3
  • include ltstdlib.hgtinclude
    ltGL/glut.hgt/ define a point data type
    /typedef struct float x,y,z point

4
  • include ltstdlib.h
  • include ltGL/glut.hgt
  • // define a point data type
  • typedef struct float x,y,z point
  • point vertices40,0,0,250,500,100,500,250,
    250,250,100,250
  • // A tetrahedron
  • int j
  • point noo, old250,100,250

5
  • include ltstdlib.h
  • include ltGL/glut.hgt
  • // define a point data type
  • typedef struct float x,y,z point
  • point vertices40,0,0,250,500,100,500,250,
    250,250,100,250
  • // A tetrahedron
  • int j
  • point noo, old250,100,250
  • void clear(void)
  • glClear(GL_COLOR_BUFFER_BIT)

6
  • include ltstdlib.h
  • include ltGL/glut.hgt
  • // define a point data type
  • typedef struct float x,y,z point
  • point vertices40,0,0,250,500,100,500,250,
    250,250,100,250
  • // A tetrahedron
  • int j
  • point noo, old250,100,250
  • void clear(void)
  • glClear(GL_COLOR_BUFFER_BIT)
  • void display(void)
  • int rand()
  • jrand()4 / pick a vertex at random /
  • noo.x (old.xverticesj.x)/2
  • noo.y (old.yverticesj.y)/2

7
  • void mouse(int btn, int state, int x, int y)
  • if(btnGLUT_LEFT_BUTTONstateGLUT_DOWN)
    glutIdleFunc(display)
  • if(btnGLUT_MIDDLE_BUTTONstateGLUT_DOWN)
    glutIdleFunc(NULL)
  • if(btnGLUT_RIGHT_BUTTONstateGLUT_DOWN)
    exit(0)

8
  • void mouse(int btn, int state, int x, int y)
  • if(btnGLUT_LEFT_BUTTONstateGLUT_DOWN)
    glutIdleFunc(display)
  • if(btnGLUT_MIDDLE_BUTTONstateGLUT_DOWN)
    glutIdleFunc(NULL)
  • if(btnGLUT_RIGHT_BUTTONstateGLUT_DOWN)
    exit(0)
  • int main(int argc, char argv)
  • glutInit(argc,argv)
  • glutInitDisplayMode (GLUT_SINGLE GLUT_RGB)
  • glutInitWindowSize(500,500)
  • glutInitWindowPosition(0,0)
  • glutCreateWindow("Sierpinski Gasket")
  • glutIdleFunc (display)
  • glutMouseFunc (mouse)
  • glClearColor(.80, .80, .80, .80 ) / white
    background /
  • glColor3f(1.0, 0.0, 0.0)
Write a Comment
User Comments (0)
About PowerShow.com