#include "windows.h"
#include "gl/gl.h"
#include "gl/glaux.h"
#include "gl/glu.h"
#include "math.h"
void myinit()
{
glClearColor(1,1,0,0);
GLfloat ambient[]={.5,.5,.5,0};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient);
GLfloat mat_ambient[]={.8,.8,.8,1.0};
GLfloat mat_diffuse[]={.8,.0,.8,1.0};
GLfloat mat_specular[]={1.0,.0,1.0,1.0};
GLfloat mat_shininess[]={50.0};
GLfloat light_diffuse[]={0,0,.5,1};
GLfloat light_position[]={0,0,1.0,0};
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,mat_ambient);
glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,mat_diffuse);
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,mat_specular);
glMaterialfv(GL_FRONT_AND_BACK,GL_SHININESS,mat_shininess);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0,GL_POSITION, light_position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
}
void CALLBACK display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
auxSolidSphere(1.0); // 绘制半径为1.0的实体球
glFlush(); // 强制输出图像
auxSwapBuffers(); // 交换绘图缓存
_sleep(100);
}
void CALLBACK Idledisplay()
{
// x,y满足x2+y2=0.01。这样可以使物体沿该圆轨迹运动。
static float x=-.1,y=0.0;
static BOOL mark=TRUE;
static float step=.01;
x+=step;
if(x<=.1&&x>=-.1)
{
if(step>0)
y=sqrt(.01-x*x);
else
y=-sqrt(.01-x*x);
glTranslatef(x,y,0);
}
else
{
step=0-step;
}
display();
}
void CALLBACK myReshape(GLsizei w,GLsizei h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w<=h)
glOrtho(-3.5,3.5,-3.5*(GLfloat)w/(GLfloat)h, 3.5*(GLfloat)w/(GLfloat)h,-10,10);
else
glOrtho(-3.5*(GLfloat)w/(GLfloat)h,3.5* (GLfloat)w/(GLfloat)h,-3.5,3.5,-10,10);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void main()
{
auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA);
auxInitPosition(0,0,400,400);
auxInitWindow(" circle ");
myinit();
auxReshapeFunc(myReshape);
auxIdleFunc(Idledisplay);
auxMainLoop(display);
}
chengxu.rar_an active workspa_project
版权申诉
82 浏览量
2022-09-20
15:52:48
上传
评论
收藏 1KB RAR 举报
alvarocfc
- 粉丝: 109
- 资源: 1万+
最新资源
- Picasso_v3.1 2.ipa
- chromedriver-mac-arm64.zip
- 蓝zapro.apk
- chromedriver-linux64.zip
- UCAS研一深度学习实验-MNIST手写数字识别python源码+详细注释(高分项目)
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- 基于SVM多特征融合的微表情识别python源码+项目说明+详细注释(高分课程设计)
- html动态爱心代码一(附源码)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈