怎样画茶壶的结构体
GLUT中直接用glutSolidTeapot()来画茶壶。
在OpenGL红宝书的例子程序opengl14.zip(百度一下opengl14,就有很多地方提供下载)中,有一个teapots.c,就是用GLUT来画一个茶壶的源代码。
源代码如下,
#include
#include
GLuint teapotList;
void init(void)
GLfloat ambient[] = {0.0, 0.0, 0.0, 1.0};
GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0};
GLfloat position[] = {0.0, 3.0, 3.0, 0.0};
GLfloat lmodel_ambient[] = {0.2, 0.2, 0.2, 1.0};
GLfloat local_view[] = {0.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
glFrontFace(GL_CW);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
/* be efficient--make teapot display list */
teapotList = glGenLists(1);
glNewList (teapotList, GL_COMPILE);
glutSolidTeapot(1.0);
glEndList ();
void renderTeapot(GLfloat x, GLfloat y,
GLfloat ambr, GLfloat ambg, GLfloat ambb,
GLfloat difr, GLfloat difg, GLfloat difb,
GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine)
GLfloat mat[4];
glPushMatrix();
glTranslatef(x, y, 0.0);
mat[0] = ambr; mat[1] = ambg; mat[2] = ambb; mat[3] = 1.0;
glMaterialfv(GL_FRONT, GL_AMBIENT, mat);
mat[0] = difr; mat[1] = difg; mat[2] = difb;
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat);
mat[0] = specr; mat[1] = specg; mat[2] = specb;
glMaterialfv(GL_FRONT, GL_SPECULAR, mat);
glMaterialf(GL_FRONT, GL_SHININESS, shine * 128.0);
glCallList(teapotList);
glPopMatrix();
GLUT中直接用glutSolidTeapot()来画茶壶。
在OpenGL红宝书的例子程序opengl14.zip(百度一下opengl14,就有很多地方提供下载)中,有一个teapots.c,就是用GLUT来画一个茶壶的源代码。
打字不易,采纳哦!GLUT中直接用glutSolidTeapot()来画茶壶。
在OpenGL红宝书的例子程序opengl14.zip(百度一下opengl14,就有很多地方提供下载)中,有一个teapots.c,就是用GLUT来画一个茶壶的源代码。茶壶的结构体
你这个定义也太宽泛了
是绘制3D模型么
还是什么东西
谁知道哪边可以看到茶壶最简易的画法...急
转载自互联网,版权归原作者所有,汉中陶瓷网仅在为您分享好文章,本文地址:https://www.hzfswh.cn/hydt/97.html