计算机图形学中简单光照模型的全部代码

[复制链接]
查看11 | 回复1 | 2010-7-12 16:46:47 | 显示全部楼层 |阅读模式
要一个简单光照模型的全部代码 比如下面这个DAA直线的全部代码
#include
#include
#include
#include
void setPixel(GLint x, GLint y){
glBegin(GL_POINTS);
glVertex2i(x, y);
Sleep (5);
glEnd();
glFlush();
}
void init(void)
{//初始化工作
glClearColor (1.0, 1.0, 1.0, 0.0);// 指定清空颜色(背景色)为白色}
gluOrtho2D (0.0, 400.0, 0.0, 400.0); //指定坐标系上显示的区域
}
/* Bresenham line-drawing procedure for |m|xEnd) {
x = xEnd;
y = yEnd;
xEnd = x0;
}
else {
x = x0;
y = y0;
}
setPixel (x, y);
while (x < xEnd) {
x++;
if (p < 0)
p += twoDy;
else {
y++;
p += twoDyMinusDx;
}
setPixel (x, y);
}
}
void myDisplay(void)
{//图形绘制
glClear (GL_COLOR_BUFFER_BIT);// 清空显示窗口
glColor3f (0.0, 0.0, 1.0);
// 指定前景色(当前绘制颜色)为蓝色
lineBres (10,10,400,400);
glEnd();
glFlush();
}
void main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(100, 100);
glutInitWindowSize(400, 400);
glutCreateWindow("窗口名称");
init();
glutDisplayFunc(&myDisplay);
glutMainLoop();
}

回复

使用道具 举报

千问 | 2010-7-12 16:46:47 | 显示全部楼层
作业看得是效果。没有简单的模型,怎么看光照模型的效果啊?画几个球体试试?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行