利用边界标志算法,将三角形从顶点表点阵表示。
#include <GL/glut.h> // OPenGL实用工具库
//#include "include/glut.h"
#include <math.h>
int dx=0, dy=0; // 平移变量
float angle=0; // 旋转角度
int mouseX=0,mouseY=0; //鼠标位置
const int XL=100,XR=300,YB=100,YT=300;
bool a[200][200]={false};
void Line(int x1,int y1,int x2,int y2){
int step;
int dx=x2-x1;
int dy=y2-y1;
float xDelta,yDelta,x=x1,y=y1;
if(abs(dx)>abs(dy))
step=abs(dx);
else
step=abs(dy);
xDelta = float(dx)/step;
yDelta = float(dy)/step;
float xPre, yPre;
for(int i=0;i<step;i++){
xPre = x; yPre = y;
x+=xDelta;
y+=yDelta;
if (int(y + 0.5) != int(yPre