要求:1.给定窗口中绘制坐标系
2.给定坐标系内绘制三角形
3.完成平移、旋转等变换后的三角形绘制
4.采用OpenGL绘制
代码:
#include<windows.h>
#include <GL/glut.h>
#include <stdlib.h>
#include<iostream>
#include<cmath>
#include<math.h>
using namespace std;
GLfloat a, b, n;
GLdouble c;
class wcPt2D
{
public:
GLfloat x, y;
};
typedef GLfloat Matrix3x3[3][3];
Matrix3x3 matComposite;
const GLdouble pi = 3.1415926;
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
}
void matrix3x3SetIdentity(Matrix3x3 matIdent3x3)
{
GLint row, col;
for (row = 0; row < 3; row++)
for (col = 0; col < 3; col++)
matIdent3x3[row][col] = (row == col);
}
void matrix3x3PreMultiply(Matrix3x3 m1, Matrix3x3 m2)
{
GLint row, col;
Matrix3x3 matTemp;
for (row = 0; row < 3; row++)
for (col = 0; col < 3; col++)
matTemp[row][col] = m1