资源简介
OpenGL编程指南中提到的教程-Nate Robin的OpenGL教程

代码片段和文件信息
/*
fog.c
Nate Robins 1997
Tool for teaching about OpenGL fog.
*/
#include
#include
#include
#include
#include
#include “glm.h“
typedef struct _cell {
int id;
int x y;
float min max;
float value;
float step;
char* info;
char* format;
} cell;
cell color[4] = {
{ 1 180 40 0.0 1.0 0.7 0.005
“Specifies red component of fog color.“ “%.2f“ }
{ 2 240 40 0.0 1.0 0.7 0.005
“Specifies green component of fog color.“ “%.2f“ }
{ 3 300 40 0.0 1.0 0.7 0.005
“Specifies blue component of fog color.“ “%.2f“ }
{ 4 360 40 0.0 1.0 1.0 0.005
“Specifies alpha component of fog color.“ “%.2f“ }
};
cell density = { 5 260 120 0.0 3.0 1.0 0.01
“Specifies the near distance.“ “%.2f“ };
cell fstart = { 6 240 120 -3.0 3.0 0.5 0.01
“Specifies the far distance.“ “%.2f“ };
cell fend = { 7 240 160 -3.0 3.0 2.0 0.01
“Specifies the fog density.“ “%.2f“ };
GLenum mode = GL_LINEAR;
GLboolean clear = GL_TRUE;
GLMmodel* pmodel = NULL;
GLfloat eye[3] = { 0.5 0.25 1.5 };
GLfloat at[3] = { 0.0 -0.25 0.0 };
GLfloat up[3] = { 0.0 1.0 0.0 };
void redisplay_all(void);
GLuint window world screen command;
GLuint sub_width = 256 sub_height = 256;
GLint selection = 0;
GLvoid *font_style = GLUT_BITMAP_TIMES_ROMAN_10;
void
setfont(char* name int size)
{
font_style = GLUT_BITMAP_HELVETICA_10;
if (strcmp(name “helvetica“) == 0) {
if (size == 12)
font_style = GLUT_BITMAP_HELVETICA_12;
else if (size == 18)
font_style = GLUT_BITMAP_HELVETICA_18;
} else if (strcmp(name “times roman“) == 0) {
font_style = GLUT_BITMAP_TIMES_ROMAN_10;
if (size == 24)
font_style = GLUT_BITMAP_TIMES_ROMAN_24;
} else if (strcmp(name “8x13“) == 0) {
font_style = GLUT_BITMAP_8_BY_13;
} else if (strcmp(name “9x15“) == 0) {
font_style = GLUT_BITMAP_9_BY_15;
}
}
void
drawstr(GLuint x GLuint y char* format ...)
{
va_list args;
char buffer[255] *s;
va_start(args format);
vsprintf(buffer format args);
va_end(args);
glRasterPos2i(x y);
for (s = buffer; *s; s++)
glutBitmapCharacter(font_style *s);
}
void
cell_draw(cell* cell)
{
glColor3ub(0 255 128);
if (selection == cell->id) {
glColor3ub(255 255 0);
drawstr(10 240 cell->info);
glColor3ub(255 0 0);
}
drawstr(cell->x cell->y cell->format cell->value);
}
int
cell_hit(cell* cell int x int y)
{
if (x > cell->x && x < cell->x + 60 &&
y > cell->y-30 && y < cell->y+10)
return cell->id;
return 0;
}
void
cell_update(cell* cell int update)
{
if (selection != cell->id)
return;
cell->value += update * cell->step;
if (cell->value < cell->min)
cell->value = cell->min;
else if (cel
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2005-11-07 04:19 tutors\data\
目录 0 2005-11-07 04:19 tutors\tutors.vc6\
目录 0 2005-11-07 04:27 tutors\tutors.vsnetproj\
目录 0 2005-11-07 04:19 tutors\tutors.xcodeproj\
文件 12754 2005-11-07 04:19 tutors\fog.c
文件 73728 2005-11-07 04:27 tutors\fog.exe
文件 66463 2005-11-07 04:19 tutors\glm.c
文件 10176 2005-11-07 04:19 tutors\glm.h
文件 237568 2001-11-08 09:27 tutors\glut32.dll
文件 42283 2005-11-07 04:19 tutors\lightmaterial.c
文件 98304 2005-11-07 04:27 tutors\lightmaterial.exe
文件 20769 2005-11-07 04:19 tutors\lightposition.c
文件 77824 2005-11-07 04:27 tutors\lightposition.exe
文件 1542 2005-11-07 04:19 tutors\Makefile
文件 3256 2005-11-07 04:19 tutors\materials.h
文件 24516 2005-11-07 04:19 tutors\projection.c
文件 77824 2005-11-07 04:27 tutors\projection.exe
文件 56171 2005-11-07 04:19 tutors\shapes.c
文件 73728 2005-11-07 04:27 tutors\shapes.exe
文件 35888 2005-11-07 04:19 tutors\texture.c
文件 81920 2005-11-07 04:27 tutors\texture.exe
文件 19117 2005-11-07 04:19 tutors\transformation.c
文件 77824 2005-11-07 04:27 tutors\transformation.exe
文件 1747 2005-11-07 04:19 tutors\data\al.mtl
文件 186752 2005-11-07 04:19 tutors\data\al.obj
文件 49181 2005-11-07 04:19 tutors\data\checker.ppm
文件 342 2005-11-07 04:19 tutors\data\dolphins.mtl
文件 50315 2005-11-07 04:19 tutors\data\dolphins.obj
文件 536 2005-11-07 04:19 tutors\data\f-16.mtl
文件 284767 2005-11-07 04:19 tutors\data\f-16.obj
文件 49183 2005-11-07 04:19 tutors\data\fishermen.ppm
............此处省略30个文件信息
- 上一篇:Holtek无线充电方案原理图
- 下一篇:GTK+GNOME程序设计PDF(高清)3
相关资源
- OpenGL参考手册
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- hibernate调用存储过程
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 基于J2EE物资出入库管理系统
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 图数据库第二版 作者[美] 伊恩·罗宾
- 3D绘图程序设计:使用Direct3D 10/9和Ope
评论
共有 条评论