void gl OrthoGLdouble left GLdouble right GLdouble bottom
Ортографическая проекция void gl. Ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); void glu. Ortho 2 D(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); // (left, bottom, near) – левый нижний угол ближней отсекающей рамки; // (right, top, near) – правый верхний угол ближней отсекающей рамки; // far – положение задней отсекающей рамки.
Отображение вершин GL_POINTS GL_TRIANGLE_STRIP GL_LINES GL_TRIANGLE_FUN GL_LINE_STRIP GL_QUADS GL_LINE_LOOP GL_QUAD_STRIP GL_TRIANGLES GL_POLYGON
Формирование геометрических примитивов gl. Rectd(GLdouble x 1, GLdouble y 1, GLdouble x 2, GLdouble y 2); - формирует прямоугольник void glu. Cylinder(GLUquadric. Obj * qobj, GLdouble base. Radius, GLdouble top. Radius, GLdouble height, GLint slices, GLint stacks); - формирует цилиндр void glu. Disk(GLUquadric. Obj * qobj, GLdouble inner. Radius, GLdouble outer. Radius, GLint slices, GLint loops); - формирует диск void glu. Sphere(GLUquadric. Obj * qobj, GLdouble radius, GLint slices, GLint stacks); - формирует сферу
Рисование шпальной миры int target; void Init() { target = gl. Gen. Lists(1); if (target != 0) { int n=5; double dx=1. /n; double x=-1. +dx/2. ; void Draw(void) { gl. Clear(GL_COLOR_BUFFER_BIT); gl. Color 3 d(1. 0, 1. 0); gl. Push. Matrix(); gl. Translated(-25. , 0. ); gl. Scaled(15. , 1. ); gl. Call. List(target); gl. Pop. Matrix(); gl. Push. Matrix(); gl. Translated(-25. , 0. ); gl. Scaled(15. , 1. ); gl. Rotated(90, 0. , 1. ); gl. Call. List(target); gl. Pop. Matrix(); gl. New. List(target, GL_COMPILE); gl. Begin(GL_QUADS); for(int i=0; i<n; ++i) { gl. Vertex 2 d(x, 1. ); gl. Vertex 2 d(x, -1. ); gl. Vertex 2 d(x+dx, 1. ); x+=2*dx; } gl. End(); gl. Push. Matrix(); gl. Translated(25. , -25. , 0. ); gl. Scaled(15. , 1. ); gl. Rotated(45, 0. , 1. ); gl. Call. List(target); gl. Pop. Matrix(); gl. End. List(); gl. Push. Matrix(); gl. Translated(25. , 0. ); gl. Scaled(15. , 1. ); gl. Rotated(-45, 0. , 1. ); gl. Call. List(target); gl. Pop. Matrix(); } } gl. Flush(); }
Рисование координатных осей void Draw(void) { //Очистка цветового буфера gl. Clear. Color(1. 0, 1. 0); gl. Clear(GL_COLOR_BUFFER_BIT); //Установка цвета отображения gl. Color 3 d(0. 0, 0. 0); //Рисование горизонтальной оси gl. Begin(GL_LINES); gl. Vertex 2 d(-50. , . 0); gl. Vertex 2 d(50. , . 0); for(int i=-50; i<=50; i++) { gl. Vertex 2 d(i, . 0); if(i % 5) { gl. Vertex 2 d(i, -1. ); } else if(i % 10) { gl. Vertex 2 d(i, -2. ); } else { gl. Vertex 2 d(i, -3. ); //Рисование вертикальной оси gl. Begin(GL_LINES); gl. Vertex 2 d(. 0, -50. ); gl. Vertex 2 d(. 0, 50. ); for(int j=-50; j<=50; j++) { gl. Vertex 2 d(. 0, j); if(j % 5) { gl. Vertex 2 d(-1. , j); } else if(j % 10) { gl. Vertex 2 d(-2. , j); } else { gl. Vertex 2 d(-3. , j); } } gl. End(); //Завершить выполнение
Рисование координатных осей void Init(void) { //Формирование оси axis = gl. Gen. Lists(1); if (axis != 0) { gl. New. List(axis, GL_COMPILE); gl. Begin(GL_LINES); gl. Vertex 2 d(0. , . 0); gl. Vertex 2 d(100. , . 0); int axis; for(int i=0. ; i<97; i++) { gl. Vertex 2 d(i, . 0); if(i % 5) { gl. Vertex 2 d(i, 1. ); } else if(i % 10) { gl. Vertex 2 d(i, 2. ); } else { gl. Vertex 2 d(i, 3. ); } gl. End(); gl. End. List(); } } //Рисование горизонтальной оси gl. Push. Matrix(); gl. Translated(-50. , 0. ); gl. Rotated(180. , 1. , 0. ); gl. Call. List(axis); gl. Pop. Matrix(); void Draw(void) { //Очистка цветового буфера gl. Clear(GL_COLOR_BUFFER_BIT); //Установка цвета отображения gl. Color 3 d(1. 0, 0. 0); //Рисование вертикальной оси gl. Push. Matrix(); gl. Translated(0. , -50. , 0. ); gl. Rotated(90. , 1. ); gl. Call. List(axis); gl. Pop. Matrix(); //Завершить выполнение команд gl. Flush(); }
- Slides: 20