OpenGL完全教程_图文_第1页
OpenGL完全教程_图文_第2页
OpenGL完全教程_图文_第3页
OpenGL完全教程_图文_第4页
OpenGL完全教程_图文_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、 Course #10An Interactive Introduction to OpenGL ProgrammingEd AngelDave ShreinerVicki ShreinerOpenGL is the most widely available graphics programming library, and is used for almost every discipline of computer graphics: research, scientific visualization, entertainment and visual effects, compute

2、r-aided design, interactive gaming, and many more. This course provides an accelerated introduction to creating applications using OpenGL.The course takes a beginning OpenGL programmer from the basics of what's required for OpenGL operation, through geometric modeling and transformations, thorou

3、ghly discusses topics such as lighting, depth buffering, alpha blending, and texture mapping, and concludes with a brief introduction to advanced study topics such as the stencil and accumulation buffers, and display lists.Course PrerequisitesOur only prerequisite is that students should be able to

4、read simple computer programs written in the C computer language.The course does present a few concepts from linear algebra (vector notation and matrix multiplication, but knowledge of those subjects is not required for the student to successfully understand the material. Additionally, although not

5、a course on computer graphics, we generally do introduce and define most major concepts (e.g., depth buffering, simulated lighting, etc.Table of ContentsTitle.1 Welcome .2 Downloading Our Tutorials.3 What Is OpenGL, and What Can It Do for Me?.4 OpenGL and Its Related APIs.5 Related APIs.6 General St

6、ructure of an OpenGL Program.7 An OpenGL Program.8 An OpenGL Program (contd.9 An OpenGL Program (contd.10 OpenGL Command Formats.11 Whats Required in Your Programs.12 GLUT Basics.13 GLUT Callback Functions.14 What can OpenGL Draw?.15 OpenGL Geometric Primitives.16 Specifying Geometric Primitives.17

7、How OpenGL Works: The Conceptual Model.18 Controlling OpenGLs Drawing.19 The Power of Setting OpenGL State.20 Setting OpenGL State.21 Setting OpenGL State (contd.22 OpenGL and Color.23 Shapes Tutorial.24 Transformations.25 Camera Analogy.26 Camera Analogy and Transformations.27 Coordinate Systems an

8、d Transformations.28 Homogeneous Coordinates.29 3D Transformations.30 Specifying Transformations.31 Programming Transformations.32 Transformation Pipeline.33 Matrix Operations.34 Projection Transformation.35 Applying Projection Transformations.36 Viewing Transformations.37 Projection Tutorial.38 Mod

9、eling Transformations.39Transformation Tutorial.40 Connection: Viewing and Modeling.41 Compositing Modeling Transformations.42 Compositing Modeling Transformations (contd.43 Additional Clipping Planes.44 Animation and Depth Buffering.45 Double Buffering.46 Animation Using Double Buffering.47 Depth B

10、uffering and Hidden Surface Removal.48 Depth Buffering Using OpenGL.49 Lighting.50 Lighting Principles.51 OpenGL Shading.52 The Modified Phong Model.53 How OpenGL Simulates Lights.54 Surface Normals.55 Material Properties.56 Light Sources.57 Light Sources (cont'd.58 Types of Lights.59 Turning on

11、 the Lights.60 Light Material Tutorial.61 Controlling a Lights Position.62 Light Position Tutorial.63 Tips for Better Lighting.64 Imaging and Raster Primitives.65 Pixel-based primitives.66 Pixel Pipeline.67 Positioning Image Primitives.68 Rendering Images.69 Reading Pixels.70 Texture Mapping: Part 1

12、.71 Texture Mapping.72 Texture Mapping and the OpenGL Pipeline.73 Texture Example.74 Applying Textures I.75 Texture Objects.76 Texture Objects (cont'd.77 Specifying a Texture Image.78 Mapping a Texture.79 Generating Texture Coordinates.80 Texture Tutorial.81Texture Mapping: Part 2.82 Applying Te

13、xtures II.83 Texture Application Methods.84 Filter Modes.85 Mipmapped Textures.86 Wrapping Mode.87 Texture Functions.88 Advanced OpenGL Topics.89 Immediate Mode versus Display Listed Rendering.90 Immediate Mode versus Display Lists.91 Display Lists.92 Display Lists (contd. .93 Display Lists and Hier

14、archy.94 Advanced Primitives.95 Alpha: the 4th Color Component.96 Blending .97 Fog.98 Fog Tutorial.99 Multi-pass Rendering.100 Antialiasing.101 OpenGL Pipeline Revisited.102 Geometry Processing.103 Rasterizer.104 Fragment Processing.105 GLSL.106 Vertex Shader Execution .107 Simple Vertex Shader.108

15、Vertex Shader Applications.109 Example: Vertex Shader Twisting.110 Fragment Shader Execution.111 Simple Fragment Shader.112 Fragment Shader Applications.113 Example: Per Fragment Shading.114 Linking with Application.115 Accumulation Buffer.116 Accumulation Buffer Applications.117 Stencil Buffer.118

16、Getting to the Framebuffer.119 Alpha Test.120 GPUs and GLSL.121 Summary / Q & A.122 On-Line Resources.123 Books .124 Thanks for Coming.125 SIGGRAPH 2007 Course #10 An Interactive Introduction to OpenGL Programming Transformation Pipeline object v e r t e x eye clip normalized device window Model

17、view Matrix Modelview Modelview z z z Projection Matrix Projection Perspective Division Viewport Transform other calculations here material Î color shade model (flat polygon rendering mode polygon culling clipping The depth of matrix stacks are implementation-dependent, but the Modelview matrix

18、 stack is guaranteed to be at least 32 matrices deep, and the Projection matrix stack is guaranteed to be at least 2 matrices deep. The material-to-color, flat-shading, and clipping calculations take place after the Modelview matrix calculations, but before the Projection matrix. The polygon culling

19、 and rendering mode operations take place after the Viewport operations. There is also a texture matrix stack, which is outside the scope of this course. It is an advanced texture mapping topic. - 33 - SIGGRAPH 2007 Course #10 An Interactive Introduction to OpenGL Programming Matrix Operations Speci

20、fy Current Matrix Stack glMatrixMode(GL_MODELVIEW or GL_PROJECTION Other Matrix or Stack Operations glLoadIdentity( glPushMatrix( glPopMatrix( Viewport usually same as window size viewport aspect ratio should be same as projection transformation or resulting image may be distorted glViewport( x, y,

21、width, height glLoadMatrix*( replaces the matrix on the top of the current matrix stack. glMultMatrix*(, post-multiples the matrix on the top of the current matrix stack. The matrix argument is a column-major 4 x 4 double or single precision floating point matrix. Matrix stacks are used because it i

22、s more efficient to save and restore matrices than to calculate and multiply new matrices. Popping a matrix stack can be said to “jump back” to a previous location or orientation. glViewport( clips the vertex or raster position. For geometric primitives, a new vertex may be created. For raster primi

23、tives, the raster position is completely clipped. There is a per-fragment operation, the scissor test, which works in situations where viewport clipping does not. The scissor operation is particularly good for fine clipping raster (bitmap or image primitives. - 34 - SIGGRAPH 2007 Course #10 An Inter

24、active Introduction to OpenGL Programming Projection Transformation Shape of viewing frustum Perspective projection gluPerspective( fovy, aspect, zNear, zFar glFrustum( left, right, bottom, top, zNear, zFar Orthographic parallel projection glOrtho(left, right, bottom, top, zNear, zFar gluOrtho2D( le

25、ft, right, bottom, top calls glOrtho with z values near zero For perspective projections, the viewing volume is shaped like a truncated pyramid (frustum. There is a distinct camera (eye position, and vertexes of objects are “projected” to camera. Objects which are further from the camera appear smal

26、ler. The default camera position at (0, 0, 0, looks down the z-axis, although the camera can be moved by other transformations. For gluPerspective(, fovy is the angle of field of view (in degrees in the y direction. fovy must be between 0.0 and 180.0, exclusive. aspect is x/y and should be the same

27、as the viewport to avoid distortion. zNear and zFar define the distance to the near and far clipping planes. The glFrustum( call is rarely used in practice. Warning: for gluPerspective( or glFrustum(, do not use zero for zNear! For glOrtho(, the viewing volume is shaped like a rectangular parallelep

28、iped (a box. Vertices of an object are “projected” towards infinity, and as such, distance does not change the apparent size of an object, as happens under perspective projection. Orthographic projection is used for drafting, and design (such as blueprints. - 35 - SIGGRAPH 2007 Course #10 An Interac

29、tive Introduction to OpenGL Programming Applying Projection Transformations Typical use (orthographic projection glMatrixMode( GL_PROJECTION ; glLoadIdentity(; glOrtho(left, right, bottom, top, zNear, zFar; Many users would follow the demonstrated sequence of commands with a glMatrixMode(GL_MODELVIEW call to return to modelview stack. In this example, the red line segment is inside the view volume and is projected (with parallel projectors to the green line on the view surface. The blue line

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论