最近通过看《Computer Graphics Using OpenGL Second Edition》来学习计算机图形学。
当然是边看边学,用OpenGL在VC++下编了个谢尔平斯基镂垫(Sierpinski gasket), 效果如下:
这是我在visual studio 2005 下编译通过的源代码:
//
Draw sierpinski gasket
// P49 in <Computer Graphics Using OpenGL>
#include " GLintPoint.h "
#include < iostream >
using std::cout;
using std::cin;
using std::endl;
// Create a number between 0 and m(a number which will be given)
// the input m must be less than 32767 according to P49 in <Computer Graphics Using OpenGL>
int random( int m)
... {
int rand();
return rand()%m;
// P49 in <Computer Graphics Using OpenGL>
#include " GLintPoint.h "
#include < iostream >
using std::cout;
using std::cin;
using std::endl;
// Create a number between 0 and m(a number which will be given)
// the input m must be less than 32767 according to P49 in <Computer Graphics Using OpenGL>
int random( int m)
... {
int rand();
return rand()%m;