Opengl 在哪里可以找到GluCylinder的源代码及其调用的函数
我需要Opengl 在哪里可以找到GluCylinder的源代码及其调用的函数,opengl,glut,Opengl,Glut,我需要的源代码和它调用的函数,以便修改它们。我在谷歌上搜索了一下,但什么也没找到 有人能给我指一下正确的方向吗?就在那里的: void GLAPIENTRY gluCylinder(Gluquadrac*qobj,GluDouble baseRadius,GluDouble topRadius, GLP双倍高度、闪烁切片、闪烁堆栈) { 闪烁i,j; GLfloat sinCache[缓存大小]; GLfloat cosCache[缓存大小]; GLfloat sinCache2[缓存大小];
的源代码和它调用的函数,以便修改它们。我在谷歌上搜索了一下,但什么也没找到
有人能给我指一下正确的方向吗?就在那里的:
void GLAPIENTRY
gluCylinder(Gluquadrac*qobj,GluDouble baseRadius,GluDouble topRadius,
GLP双倍高度、闪烁切片、闪烁堆栈)
{
闪烁i,j;
GLfloat sinCache[缓存大小];
GLfloat cosCache[缓存大小];
GLfloat sinCache2[缓存大小];
GLfloat COSCHACHE2[缓存大小];
GLfloat sinCache3[缓存大小];
GLfloat COSCHACHE3[缓存大小];
GLfloat角;
格尔兹洛,志高;
GLEMP、costemp;
GLfloat长度;
德塔拉迪乌斯;
glznormal;
乙二醇正态比值;
GLfloat radiusLow,radiusHigh;
int needCache2、needCache3;
如果(切片>=缓存大小)切片=缓存大小-1;
如果(切片<2 | |堆栈<1 | |基半径<0.0 | |顶半径<0.0||
高度<0.0){
gluQuadricError(qobj,GLU_无效值);
返回;
}
/*计算长度(正常计算所需)*/
deltaRadius=基底半径-顶部半径;
长度=SQRT(德尔塔拉迪乌斯*德尔塔拉迪乌斯+高度*高度);
如果(长度==0.0){
gluQuadricError(qobj,GLU_无效值);
返回;
}
/*缓存是顶点位置缓存*/
/*Cache2是顶点本身的各种法线*/
/*Cache3是面的各种法线*/
needCache2=needCache3=0;
if(qobj->normals==GLU_平滑){
2=1;
}
如果(qobj->normals==GLU_FLAT){
如果(qobj->drawStyle!=GLU_点){
3=1;
}
如果(qobj->drawStyle==GLU_线){
2=1;
}
}
zNormal=德塔拉迪乌斯/长度;
xyNormalRatio=高度/长度;
对于(i=0;i方向==GLU_外部){
sinCache2[i]=xyNormalRatio*SIN(角度);
cosCache2[i]=xyNormalRatio*COS(角度);
}否则{
sinCache2[i]=-xyNormalRatio*SIN(角度);
cosCache2[i]=-xyNormalRatio*COS(角度);
}
}
sinCache[i]=SIN(角度);
cosCache[i]=COS(角度);
}
如有需要(3){
对于(i=0;i方向==GLU_外部){
sinCache3[i]=xyNormalRatio*SIN(角度);
cosCache3[i]=xyNormalRatio*COS(角度);
}否则{
sinCache3[i]=-xyNormalRatio*SIN(角度);
cosCache3[i]=-xyNormalRatio*COS(角度);
}
}
}
sinCache[slices]=sinCache[0];
cosCache[slices]=cosCache[0];
如有需要(2){
sinCache2[slices]=sinCache2[0];
cosCache2[slices]=cosCache2[0];
}
如有需要(3){
sinCache3[slices]=sinCache3[0];
cocache3[slices]=cocache3[0];
}
开关(qobj->drawStyle){
案例GLU_填充:
/*注:
**可以为使用三角形风扇作为末端进行辩论
**任一半径的圆柱体的半径为0.0(圆锥体)
**三角形风扇无法在平滑着色模式下工作(常见
**因为每个顶点的法线都不同
**三角形(三角形的范不让我再具体说明那个法线)。
**现在,我的选择是GL_三角形,或者离开GL_四边形带
**让GL简单地拒绝两个三角形中的一个
**GL\u QUAD\u STRIP可能更快,所以我将保留此代码
**独自一人。
*/
对于(j=0;j方向==GLU_外部){
if(qobj->textureCoords){
glTexCoord2f(1-(浮动)i/切片,
(浮动)j/堆叠);
}
glVertex3f(radiusLow*sinCache[i],
radiusLow*cosCache[i],zLow);
if(qobj->textureCoords){
glTexCoord2f(1-(浮动)i/切片,
(浮动)(j+1)/堆叠);
}
glVertex3f(radiusHigh*SINCHACE[i],
radiusHigh*COSCHACHE[i],zHigh);
}否则{
if(qobj->textureCoords){
glTexCoord2f(1-(浮动)i/切片,
(浮动)(j+1)/堆叠);
}
glVertex3f(radiusHigh*SINCHACE[i],
radiusHigh*COSCHACHE[i],zHigh);
if(qobj->textureCoords){
glTexCoord2f(1-(浮动)i/切片,
(浮动)j/堆叠);
}
glVertex3f(radiusLow*sinCache[i],
radiusLow*cosCache[i],zLow);
}
}
格伦德();
}
打破
案例GLU_点:
glBegin(总分);
对于(i=0;i法线){
案例GLU_扁平:
外壳GLU_光滑:
glNormal3f(sinCache2[i],cocache2[i],zNormal);
打破
案例GLU_无:
违约:
打破
}
sintemp=sinCache[i];
costemp=cosCache[i];
对于(j=0;j纹理词){
glTexCoord2f(1-(浮动)i/切片,
(浮动)j/堆叠);
}
glVertex3f(半径低*sintemp,
半径低*costemp,zLow);
}
}
格伦德();
打破
案例GLU_线:
F
void GLAPIENTRY
gluCylinder(GLUquadric *qobj, GLdouble baseRadius, GLdouble topRadius,
GLdouble height, GLint slices, GLint stacks)
{
GLint i,j;
GLfloat sinCache[CACHE_SIZE];
GLfloat cosCache[CACHE_SIZE];
GLfloat sinCache2[CACHE_SIZE];
GLfloat cosCache2[CACHE_SIZE];
GLfloat sinCache3[CACHE_SIZE];
GLfloat cosCache3[CACHE_SIZE];
GLfloat angle;
GLfloat zLow, zHigh;
GLfloat sintemp, costemp;
GLfloat length;
GLfloat deltaRadius;
GLfloat zNormal;
GLfloat xyNormalRatio;
GLfloat radiusLow, radiusHigh;
int needCache2, needCache3;
if (slices >= CACHE_SIZE) slices = CACHE_SIZE-1;
if (slices < 2 || stacks < 1 || baseRadius < 0.0 || topRadius < 0.0 ||
height < 0.0) {
gluQuadricError(qobj, GLU_INVALID_VALUE);
return;
}
/* Compute length (needed for normal calculations) */
deltaRadius = baseRadius - topRadius;
length = SQRT(deltaRadius*deltaRadius + height*height);
if (length == 0.0) {
gluQuadricError(qobj, GLU_INVALID_VALUE);
return;
}
/* Cache is the vertex locations cache */
/* Cache2 is the various normals at the vertices themselves */
/* Cache3 is the various normals for the faces */
needCache2 = needCache3 = 0;
if (qobj->normals == GLU_SMOOTH) {
needCache2 = 1;
}
if (qobj->normals == GLU_FLAT) {
if (qobj->drawStyle != GLU_POINT) {
needCache3 = 1;
}
if (qobj->drawStyle == GLU_LINE) {
needCache2 = 1;
}
}
zNormal = deltaRadius / length;
xyNormalRatio = height / length;
for (i = 0; i < slices; i++) {
angle = 2 * PI * i / slices;
if (needCache2) {
if (qobj->orientation == GLU_OUTSIDE) {
sinCache2[i] = xyNormalRatio * SIN(angle);
cosCache2[i] = xyNormalRatio * COS(angle);
} else {
sinCache2[i] = -xyNormalRatio * SIN(angle);
cosCache2[i] = -xyNormalRatio * COS(angle);
}
}
sinCache[i] = SIN(angle);
cosCache[i] = COS(angle);
}
if (needCache3) {
for (i = 0; i < slices; i++) {
angle = 2 * PI * (i-0.5) / slices;
if (qobj->orientation == GLU_OUTSIDE) {
sinCache3[i] = xyNormalRatio * SIN(angle);
cosCache3[i] = xyNormalRatio * COS(angle);
} else {
sinCache3[i] = -xyNormalRatio * SIN(angle);
cosCache3[i] = -xyNormalRatio * COS(angle);
}
}
}
sinCache[slices] = sinCache[0];
cosCache[slices] = cosCache[0];
if (needCache2) {
sinCache2[slices] = sinCache2[0];
cosCache2[slices] = cosCache2[0];
}
if (needCache3) {
sinCache3[slices] = sinCache3[0];
cosCache3[slices] = cosCache3[0];
}
switch (qobj->drawStyle) {
case GLU_FILL:
/* Note:
** An argument could be made for using a TRIANGLE_FAN for the end
** of the cylinder of either radii is 0.0 (a cone). However, a
** TRIANGLE_FAN would not work in smooth shading mode (the common
** case) because the normal for the apex is different for every
** triangle (and TRIANGLE_FAN doesn't let me respecify that normal).
** Now, my choice is GL_TRIANGLES, or leave the GL_QUAD_STRIP and
** just let the GL trivially reject one of the two triangles of the
** QUAD. GL_QUAD_STRIP is probably faster, so I will leave this code
** alone.
*/
for (j = 0; j < stacks; j++) {
zLow = j * height / stacks;
zHigh = (j + 1) * height / stacks;
radiusLow = baseRadius - deltaRadius * ((float) j / stacks);
radiusHigh = baseRadius - deltaRadius * ((float) (j + 1) / stacks);
glBegin(GL_QUAD_STRIP);
for (i = 0; i <= slices; i++) {
switch(qobj->normals) {
case GLU_FLAT:
glNormal3f(sinCache3[i], cosCache3[i], zNormal);
break;
case GLU_SMOOTH:
glNormal3f(sinCache2[i], cosCache2[i], zNormal);
break;
case GLU_NONE:
default:
break;
}
if (qobj->orientation == GLU_OUTSIDE) {
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) j / stacks);
}
glVertex3f(radiusLow * sinCache[i],
radiusLow * cosCache[i], zLow);
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) (j+1) / stacks);
}
glVertex3f(radiusHigh * sinCache[i],
radiusHigh * cosCache[i], zHigh);
} else {
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) (j+1) / stacks);
}
glVertex3f(radiusHigh * sinCache[i],
radiusHigh * cosCache[i], zHigh);
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) j / stacks);
}
glVertex3f(radiusLow * sinCache[i],
radiusLow * cosCache[i], zLow);
}
}
glEnd();
}
break;
case GLU_POINT:
glBegin(GL_POINTS);
for (i = 0; i < slices; i++) {
switch(qobj->normals) {
case GLU_FLAT:
case GLU_SMOOTH:
glNormal3f(sinCache2[i], cosCache2[i], zNormal);
break;
case GLU_NONE:
default:
break;
}
sintemp = sinCache[i];
costemp = cosCache[i];
for (j = 0; j <= stacks; j++) {
zLow = j * height / stacks;
radiusLow = baseRadius - deltaRadius * ((float) j / stacks);
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) j / stacks);
}
glVertex3f(radiusLow * sintemp,
radiusLow * costemp, zLow);
}
}
glEnd();
break;
case GLU_LINE:
for (j = 1; j < stacks; j++) {
zLow = j * height / stacks;
radiusLow = baseRadius - deltaRadius * ((float) j / stacks);
glBegin(GL_LINE_STRIP);
for (i = 0; i <= slices; i++) {
switch(qobj->normals) {
case GLU_FLAT:
glNormal3f(sinCache3[i], cosCache3[i], zNormal);
break;
case GLU_SMOOTH:
glNormal3f(sinCache2[i], cosCache2[i], zNormal);
break;
case GLU_NONE:
default:
break;
}
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) j / stacks);
}
glVertex3f(radiusLow * sinCache[i],
radiusLow * cosCache[i], zLow);
}
glEnd();
}
/* Intentionally fall through here... */
case GLU_SILHOUETTE:
for (j = 0; j <= stacks; j += stacks) {
zLow = j * height / stacks;
radiusLow = baseRadius - deltaRadius * ((float) j / stacks);
glBegin(GL_LINE_STRIP);
for (i = 0; i <= slices; i++) {
switch(qobj->normals) {
case GLU_FLAT:
glNormal3f(sinCache3[i], cosCache3[i], zNormal);
break;
case GLU_SMOOTH:
glNormal3f(sinCache2[i], cosCache2[i], zNormal);
break;
case GLU_NONE:
default:
break;
}
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) j / stacks);
}
glVertex3f(radiusLow * sinCache[i], radiusLow * cosCache[i],
zLow);
}
glEnd();
}
for (i = 0; i < slices; i++) {
switch(qobj->normals) {
case GLU_FLAT:
case GLU_SMOOTH:
glNormal3f(sinCache2[i], cosCache2[i], 0.0);
break;
case GLU_NONE:
default:
break;
}
sintemp = sinCache[i];
costemp = cosCache[i];
glBegin(GL_LINE_STRIP);
for (j = 0; j <= stacks; j++) {
zLow = j * height / stacks;
radiusLow = baseRadius - deltaRadius * ((float) j / stacks);
if (qobj->textureCoords) {
glTexCoord2f(1 - (float) i / slices,
(float) j / stacks);
}
glVertex3f(radiusLow * sintemp,
radiusLow * costemp, zLow);
}
glEnd();
}
break;
default:
break;
}
}