没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
试读
76页
In this manual, a general framework for easily creating OpenGL-applications is considered. This framework is written in C++ and relies heavily on the concept of Object-Oriented Programming (OOP). General knowledge of encapsulation, inheritance and polymorphism is assumed. Various aspects are discussed, ranging from a general introduction and detailed explanations of class-methods to an in-depth treatment of the ray tracer, which was (partially) built using this framework.
资源推荐
资源详情
资源评论
Universitaire Instelling Antwerpen
Department of Mathematics and Computer Science
Advanced Computer Graphics
using OpenGL.
Sven Maerivoet
http://svengl.dyns.cx
2000 - 2001
Contents
1 Introduction 1
1.1 A word about the framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 How to use the library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 The GL-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.2 The instantiator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Compiling and linking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.1 UNIX and Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.2 Windows 95/98/2000/NT/ME . . . . . . . . . . . . . . . . . . . . . . . 7
2 TOpenGLApp base class 9
2.1 General considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.1 Useful constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.2 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.3 Callback registrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.1.4 Default callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1.5 Continuous camera movements versus momentum-mode . . . . . . . . . 13
2.1.6 Miscellaneous functions . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Viewing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.1 Window-to-viewport mapping . . . . . . . . . . . . . . . . . . . . . . . 14
2.2.2 Projection management . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Color, fog, lighting and texture management . . . . . . . . . . . . . . . . . . . . 16
2.3.1 Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.2 Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3.3 Lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
i
2.3.4 Texture management . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4 Graphics routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.1 2D-graphics routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.2 3D-graphics routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4.3 Miscellaneous 3D-graphics routines . . . . . . . . . . . . . . . . . . . . 22
2.4.4 Scene-rendering (OpenGL and ray tracing) . . . . . . . . . . . . . . . . 23
2.4.5 2D- and 3D-transformations . . . . . . . . . . . . . . . . . . . . . . . . 24
3 SDL 25
3.1 General layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2 The different categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.1 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.2 Lights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2.3 Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2.4 Boolean-objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2.5 Material-properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.2.6 Motion blur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2.7 Global scene attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.2.8 Textures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.2.9 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.2.10 Including other SDL-files . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3 The different shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3.1 Polyhedra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.2 Tapered cylinders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.3 Cube, sphere and teapot . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.4 Meshes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.3.5 Torus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3.6 Algebraic surfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
ii
4 Ray tracing 37
4.1 The lighting-model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.1.1 Surface roughness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.1.2 Emissive and ambient components . . . . . . . . . . . . . . . . . . . . . 38
4.1.3 Diffuse and specular components . . . . . . . . . . . . . . . . . . . . . 39
4.1.4 Reflection and transparency . . . . . . . . . . . . . . . . . . . . . . . . 40
4.1.5 Atmospheric attenuation . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.1.6 Fog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.2 Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.2.1 Hard and soft shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.2.2 Indirect lighting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.3 Texturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.3.1 Solid texturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.3.2 Flat texturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.4 Anti-aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
4.4.1 Regular supersampling . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.4.2 Stochastic supersampling . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.5 Motion blur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.6 Post-normalization of the colors . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.7 Adding a new shape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.7.1 Modifying SDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.7.2 Implementing the shape . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.7.3 Using a world-extent . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
A Utilities 60
A.1 Chrono . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
A.2 Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
A.2.1 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
A.2.2 Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
A.3 RNG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
B Key-assignments 64
B.1 Assigned keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
B.2 Available keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
iii
List of Figures
2.1 The various software-components. . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1 Cross-sections of the three kinds of tori. . . . . . . . . . . . . . . . . . . . . . . 35
4.1 Non-weighted jittered discrete cone tracing. . . . . . . . . . . . . . . . . . . . . 42
4.2 Atmospheric attenuation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.3 Unsupported indirect lighting. . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.4 Decision-tree when applying texture mapping. . . . . . . . . . . . . . . . . . . . 46
4.5 Regular supersampling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
4.6 Stochastic supersampling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.7 Distribution of time-samples over one frame. . . . . . . . . . . . . . . . . . . . 53
iv
剩余75页未读,继续阅读
资源评论
jihao_111
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功