#include <Windows.h>
#include <gl\glut.h>
#include<math.h>
#define PI 3.14
void myDisplay2(){
//画两个顶端的圆形区域
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glBegin(GL_TRIANGLE_FAN);
glVertex3d(0.0,0.0,1.0);
double c = PI/180;
float z = sin(c*80);
float x,y;
for(float theta =-180.0;theta<=180.0;theta+=20.0){
GLfloat thetar = theta*c;
x= sin(thetar)*cos(c*80);
y= cos(thetar)*cos(c*80);
glVertex3d(x,y,z);
}
glEnd();
//画两个顶端的圆形区域
glBegin(GL_TRIANGLE_FAN);
glVertex3d(0.0,0.0,-1.0);
z = -sin(c*80);
for(GLfloat theta =-180.0;theta<=180.0;theta+=20.0){
GLfloat thetar = theta*c;
x= sin(thetar)*cos(c*80);
y= cos(thetar)*cos(c*80);
glVertex3d(x,y,z);
}
glEnd();
for(float phi=-80;phi<=80;phi+=20){
float phir = c*phi ;
float phir20 = c*(phi+20) ;
glBegin(GL_QUAD_STRIP);
for(GLfloat theta =-180.0;thet
[OpenGL]计算机图形学实验01:一个简单的球体
最新推荐文章于 2023-12-04 01:20:41 发布
这个博客通过OpenGL展示了如何使用GL_TRIANGLE_FAN和GL_QUAD_STRIP模式来绘制一个3D球体。代码中设置了背景颜色、绘图颜色,并通过一系列旋转实现了观察角度的变化。
摘要由CSDN通过智能技术生成