资源简介
真实感图形的例子,可以移动点光源产生阴影变化
代码片段和文件信息
/* Copyright (c) Mark J. Kilgard 1994. */
#include
#include
#include
#include
#define TORUS 0
#define TEAPOT 1
#define DOD 2
#define TET 3
#define ISO 4
#define QUIT 5
static int spin = 0;
static int obj = TORUS;
static int begin;
void
menu_select(int item) //定义选择菜单
{
if (item == QUIT)
exit(0);
obj = item;
glutPostRedisplay();
}
/* ARGSUSED2 */
void
movelight(int button int state int x int y)
{
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
begin = x;
}
}
/* ARGSUSED1 */
void
motion(int x int y)
{
spin = (spin + (x - begin)) % 360;
begin = x;
glutPostRedisplay();
}
void
myinit(void)
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
}
/* Here is where the light position is reset after the modeling
* transformation (glRotated) is called. This places the
* light at a new position in world coordinates. The cube
* represents the position of the light.
*/
void
display(void)
{
GLfloat position[] =
{0.0 0.0 1.5 1.0};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(0.0 0.0 -5.0);
glPushMatrix();
glRotated((GLdouble) spin 0.0 1.0 0.0);
glLightfv(GL_LIGHT0 GL_POSITION position);
glTranslated(0.0 0.0 1.5);
glDisable(GL_LIGHTING);
glColor3f(0.0 1.0 1.0);
glutWireCube(
- 上一篇:仓库管理系统分别通过数据库实现和文件实现,含流程图
- 下一篇:用C语言编写二叉排序树
相关资源
- 仓库管理系统分别通过数据库实现和
- C++ TEST 6.0 破解
- 《数据结构——C++实现》第二版课本
- 哈夫曼树 C++算法
- tcp socket实现单进程单线程 高并发服务
- 八数码的深度优先算法c++实现
- C++实现灰度图像的边缘检测、提取及
- 摄影测量直接线性变换DLTVC++程序代码
- 用VC++6.0开发监控界面的方法
- 用Visual C++仿真实现卡尔曼滤波
- libstdc++.so.6.0.17
- c++写的操作系统课程设计:模拟文件
- C++编写的航空客运订票系统
- MFC 界面编程13个
- MFC入门教程:1天深入浅出MFC
- listing_4.1.cpp
- 摄影测量空间后方交会程序合集,含
- 进程调度的设计与实现代码C++
- window平台下c++ 对zip压缩解压缩工程源
- 人工智能旅行商问题实验报告及C++源
- VC++ 基于IE内核功能很齐全的浏览器(
- c++实现最简单的COM
- (转)VC老版主薄荷用VC++6.0写的TCP
- C++ 矩阵乘并行算法实现
- c++ 贪食蛇控制台游戏代码,不闪屏功
- C++实现音频录音wav格式
- 唯一可译码判决准则 1使用的编程:
- x新安江模型c++
- C++停车场管理系统的完整代码.txt
- C++经典试题附答案
评论
共有 条评论