📄 botol.cpp
字号:
#include<glut.h>
#include<GL/GL.h>
#include<GL/glu.h>
void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glEnable(GL_DEPTH_TEST);
glColor3f(0.0,0.5,1.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(1,0,0,0,0,0,0,1,0);
glPushMatrix();
glRotatef(90,1,0,0);
GLUquadricObj* mySphere;
mySphere = gluNewQuadric();
gluQuadricDrawStyle(mySphere,GLU_SILHOUETTE);
gluQuadricTexture(mySphere,0);
gluCylinder(mySphere,0.27,0.27,1,30,5);
glPopMatrix();
glPushMatrix();
glTranslatef(0,0.3,0);
glRotatef(90,1,0,0);
GLUquadricObj* mySphere2;
mySphere2 = gluNewQuadric();
gluQuadricDrawStyle(mySphere2, GLU_SILHOUETTE);
gluCylinder(mySphere2,0.1,0.27,0.3,20,10);
glPopMatrix();
glPushMatrix();
glTranslatef(0,0.7,0);
glRotatef(90,1,0,0);
GLUquadricObj* mySphere3;
mySphere3 = gluNewQuadric();
gluQuadricDrawStyle(mySphere3, GLU_SILHOUETTE);
gluCylinder(mySphere3,0.1,0.1,0.4,20,10);
glPopMatrix();
glPushMatrix();
glTranslatef(0,0.8,0);
glRotatef(90,1,0,0);
GLUquadricObj* mySphere4;
mySphere4 = gluNewQuadric();
gluQuadricDrawStyle(mySphere3, GLU_SILHOUETTE);
gluCylinder(mySphere3,0.15,0.15,0.1,20,10);
glPopMatrix();
glutSwapBuffers();
}
void reshape(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-4.0,4.0,-4.0,4.0,-4.0,4.0);
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(700,700);
glutInitWindowPosition(0,0);
glutCreateWindow("Botol");
init();
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMainLoop();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -