computer graphics at openGL (2)

427 views

Published on

computer graphics at openGL

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
427
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

computer graphics at openGL (2)

  1. 1. Gl_point Two points: #include<GL/glut.h> void display() { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.0f,0.0f,0.0f,0.0f); glPointSize(10.0f); glBegin(GL_POINTS); glColor3f(1.0,1.0,0.0); glVertex2f(0.0f,0.0f); glVertex2f(0.2f,0.5f); glEnd(); glFlush(); } void main(intargc,char**argv) { glutInit(&argc,argv); glutInitWindowSize(420,320); glutInitWindowPosition(50,50); glutCreateWindow("GL_POINTS Example"); glutDisplayFunc(display); glutMainLoop(); }
  2. 2. Four Points: #include<GL/glut.h> void display() { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.0f,0.0f,0.0f,0.0f); glPointSize(10.0f); glPointSize(30.0f); glBegin(GL_POINTS); glColor3f(1.0,0.0,0.0); glVertex2f(0.0f,0.2f); glColor3f(1.0,0.0,1.0); glVertex2f(0.0f,0.5f); glPointSize(60.0f); glBegin(GL_POINTS); glColor3f(0.0,1.0,0.0); glVertex2f(0.5f,0.2f); glColor3f(0.0,0.0,1.0); glVertex2f(0.5f,0.5f); glEnd(); glFlush(); } void main(intargc,char**argv) { glutInit(&argc,argv); glutInitWindowSize(420,320); glutInitWindowPosition(50,50); glutCreateWindow("GL_POINTS Example"); glutDisplayFunc(display); glutMainLoop(); }
  3. 3. GL_LINES #include<GL/glut.h> void display(){ glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.0f,0.0f,0.0f,0.0f); glPointSize(100.0f); glBegin(GL_LINES); glColor3f(1.0,0.0,0.0); glVertex2f(0.0f,0.0f); glVertex2f(0.7f,0.5f); glPointSize(100.0f); glBegin(GL_LINES); glColor3f(0.0,1.0,0.0); glVertex2f(-0.2f,0.0f); glVertex2f(-0.7f,0.5f); glEnd(); glFlush(); } void main(intargc,char**argv){ glutInit(&argc,argv); glutInitWindowSize(420,320); glutInitWindowPosition(50,50); glutCreateWindow("GL_LINES Example"); glutDisplayFunc(display); glutMainLoop(); }
  4. 4. #include<GL/glut.h> void display(){ glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.0f,0.0f,0.0f,0.0f); glPointSize(100.0f); glBegin(GL_LINES); glColor3f(1.0,0.0,0.0); glVertex2f(0.5f,0.5f); glVertex2f(-0.5f,0.5f); glPointSize(100.0f); glBegin(GL_LINES); glColor3f(0.0,0.0,1.0); glVertex2f(-0.5f,0.5f); glVertex2f(0.5f,-0.5f); glPointSize(100.0f); glBegin(GL_LINES); glColor3f(1.0,1.0,1.0); glVertex2f(0.5f,-0.5f); glVertex2f(-0.5f,-0.5f); glPointSize(100.0f);
  5. 5. glBegin(GL_LINES); glColor3f(1.0,0.0,1.0); glVertex2f(-0.5f,-0.5f); glVertex2f(0.5f,0.5f); glEnd(); glFlush(); } void main(intargc,char**argv){ glutInit(&argc,argv); glutInitWindowSize(420,320); glutInitWindowPosition(50,50); glutCreateWindow("GL_LINES Example"); glutDisplayFunc(display); glutMainLoop(); }

×