📄 cyli.txt
字号:
#include<glut.h>
#include<math.h>
#include<stdio.h>
void draw_pixel(GL int cx,GL int cy)
{
glColor3f(1.0,0.0,0.0);
glBegin(GL_POINTS);
glVertex2i(cx,cy);
glEnd();
}
void plotpixel(GL int h,GL int k,GL int x,GL int y)
{
draw_pixel(x+h,y+k);
draw_pixel(-x+h,y+k);
draw_pixel(x+h,-y+k);
draw_pixel(-x+h,-y+k);
draw_pixel(y+h,x+k);
draw_pixel(-y+h,x+k);
draw_pixel(y+h,-x+k);
draw_pixel(-y+h,-x+k);
}
void circle_draw(GL int h,GL int k,GL int r)
{
GL int d=1-r,x=0,y=r;
while(y>x)
{
plotpixel(h,k,x,y);
if(d<0)
{
d+=2*x+3;
}
else
{
d+=2*(x-y)+5;
--y;
}
++x;
}
plotpixel(h,k,x,y);
}
void displaycircle(void )
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
circle_draw();
glFlush();
}
void main()
{
glutInitWindowPosition(350,350);
glutInitWindowSize(400,300);
glutCreateWindow("cylinder");
init();
glutDisplayFunc(displaycircle);
glutMainLoop();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -