#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <stdlib.h>
#include <GL/glaux.h>
GLfloat diffuseMaterial[4] = { 0.5, 0.5, 0.5, 1.0 };
/* Initialize values for material property, light source,
* lighting model, and depth buffer.
*/
void myinit(void)
{
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseMaterial);
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialf(GL_FRONT, GL_SHININESS, 25.0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
}
void CALLBACK changeRedDiffuse (AUX_EVENTREC *event)
{
diffuseMaterial[0] += 0.1f;
if (diffuseMaterial[0] > 1.0f)
diffuseMaterial[0] = 0.0f;
glColor4fv(diffuseMaterial);
}
void CALLBACK changeGreenDiffuse (AUX_EVENTREC *event)
{
diffuseMaterial[1] += 0.1f;
if (diffuseMaterial[1] > 1.0f)
diffuseMaterial[1] = 0.0f;
glColor4fv(diffuseMaterial);
}
void CALLBACK changeBlueDiffuse (AUX_EVENTREC *event)
{
diffuseMaterial[2] += 0.1f;
if (diffuseMaterial[2] > 1.0f)
diffuseMaterial[2] = 0.0f;
glColor4fv(diffuseMaterial);
}
void CALLBACK display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
auxSolidSphere(1.0);
glFlush();
}
void CALLBACK myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w,
1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
else
glOrtho (-1.5*(GLfloat)w/(GLfloat)h,
1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void main(int argc, char** argv)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB | AUX_DEPTH);
auxInitPosition (0, 0, 500, 500);
auxInitWindow (argv[0]);
myinit();
auxMouseFunc (AUX_LEFTBUTTON, AUX_MOUSEDOWN, changeRedDiffuse);
auxMouseFunc (AUX_MIDDLEBUTTON, AUX_MOUSEDOWN, changeGreenDiffuse);
auxMouseFunc (AUX_RIGHTBUTTON, AUX_MOUSEDOWN, changeBlueDiffuse);
auxReshapeFunc (myReshape);
auxMainLoop(display);
}
sph.rar_opengl_opengl 光照_sph opengl_sph source code_光照
版权申诉
154 浏览量
2022-09-22
16:48:24
上传
评论
收藏 7KB RAR 举报
JaniceLu
- 粉丝: 79
- 资源: 1万+
最新资源
- 海尔618算价表_七海5.20_16.00xlsx(1)(2).xlsx
- WebCrawler.scr
- 【计算机专业毕业设计】大学生就业信息管理系统设计源码.zip
- YOLO 数据集:8种路面缺陷病害检测【包含划分好的数据集、类别class文件、数据可视化脚本】
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于YOLOv8的FPS TPS AI自动锁定源码+使用步骤说明.zip
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于yolov8+streamlit的火灾检测部署源码+模型.zip
- 测试aaaaaaabbbbb
- VID20240521070643.mp4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈