OpenGLプログラミング
OpenGL Programming ブックへようこそ。 OpenGL は 3D グラフィックスの描画に使用するAPIです。 OpenGL はプログラミング言語ではありません。 OpenGL アプリケーションは、一般的に、C言語またはC++で書かれます。 OpenGL の役割は、魅力的で、リアルな3Dグラフィックスを、最小限の労力で描画できるようにすることです。 APIは通常、GPUと連携をとってハードウェア アクセラレーション レンダリングを実現するために使用されます。
このwikibookへの 参加 や 貢献 は自由で、 奨励されています: フリードキュメンテーションの精神で書かれていて、全人類に帰属するものです。 気軽に印刷したり、学校やプロフェッショナルクラスに教えたり、テキストを改善し、コメントを書き、新しいセクションを執筆してください。
私たちは貢献者を探しています。 OpenGLについて知っていることがあれば、お気軽にコメントを残したり、TODOセクションを拡張したり、新しいセクションを書いてくださいね!
はじめに
[編集]OpenGLのセットアップ
[編集]- Installation on GNU/Linux
- Installation on Macintosh
- Installation on Windows with Code::Blocks
- Installation for Android NDK development
- with a GLUT-like wrapper to follow the exercises
- Installation for iPhone development
- Installing GLUT
Modern OpenGL
[編集]"Modern" OpenGL の範囲は、 OpenGL 2.1+, OpenGL ES 2.0+,および WebGLで、 プログラマブルなパイプラインやシェーダが付属するものです。
The basics arc
[編集]01 | チュートリアル 01: newcomer's introduction, first dive into shaders | 02 | チュートリアル 02: adding more robustness to our code, transparency | ||
03 | チュートリアル 03: passing information to shaders: attributes, varying and uniforms | 04 | チュートリアル 04: transformation matrices: positioning and rotating | ||
05 | チュートリアル 05: adding the 3rd dimension: a cube, plus a camera | 06 | チュートリアル 06: textures: displaying a wooden cube | ||
07 | OBJ format: loading Suzanne the monkey from Blender | 08 | Navigation: navigate in 3D space and manipulate objects in our model viewer |
Tutorial_drafts: ideas and notes for upcoming tutorials
The lighting arc
[編集]This series of tutorials is a C++ port of the GLSL wikibook Basic Lighting tutorials.
01 | Diffuse Reflection: about per-vertex diffuse lighting and multiple light sources of different kinds | 02 | Specular Highlights: about per-vertex lighting | ||
03 | Two-Sided Surfaces (about two-sided per-vertex lighting) | 04 | Smooth Specular Highlights (about per-pixel lighting) | ||
05 | Two-Sided Smooth Surfaces (about two-sided per-pixel lighting) | 06 | Multiple Lights (about for-loops for handling multiple light sources) |
This series of tutorials is a C++ port of the GLSL wikibook Basic Texturing tutorials.
01 | Textured Spheres: about texturing a sphere | 02 | Lighting Textured Surfaces: about textures for diffuse lighting | ||
03 | Glossy Textures: about gloss mapping | 04 | Transparent Textures: about using alpha textures for discarding fragments, alpha testing, and blending | ||
05 | Layers of Textures: about multitexturing |
This series of tutorials is a C++ port of the GLSL wikibook tutorials about Textures in 3D.
01 | Lighting of Bumpy Surfaces: about normal mapping | 02 | Projection of Bumpy Surfaces: about parallax mapping | ||
03 | Cookies: about projective texture mapping for shaping light | 04 | Light Attenuation: about texture mapping for light attenuation and lookup tables in general | ||
05 | Projectors: about projective texture mapping for projectors |
There are more tutorials to port at the GLSL wikibook!
The scientific arc
[編集]01 | Graph 01: plotting a simple function, using vertex buffer objects and point sprites | 02 | Graph 02: plotting a graph from data in a texture | ||
03 | Graph 03: plotting borders and axes, clipping | 04 | Graph 04: plotting a three-dimensional graph | ||
05 | Graph 05: plotting a surface with hidden line removal |
And more to come.
Selected topics
[編集]01 | Arcball: intuitive object rotation with the mouse | 02 | Bounding box: draw a cube around your object for editing or debugging purposes | ||
03 | 2D-on-3D: hardware-accelerated 2D programming | 04 | Video Capture: capture your animation using apitrace (C++) or JavaScript (WebGL) | ||
05 | Tea time: generating a HD teapot from Bézier surfaces | 06 | Stencil buffer: masking and combining | ||
07 | Quadrics: creating simple shapes with a bit of maths | 08 | Basic text: rendering text using the FreeType library | ||
09 | Optimized text rendering: using a texture atlas containing all glyphs | 10 | Object selection: unprojecting coordinates and object identification using the stencil buffer | ||
11 | Anti-Aliasing: smoothing lines |
The post-processing arc
[編集]01 | Concepts: how to perform full-screen post-processing, first example with a simple animated wave | 02 | ???: next effect to be decided! |
Mini-portal
[編集]This series shows how to implement a teleportation system similar to Valve's Portal, step-by-step, using OpenGL.
01 | Mini-Portal: a first working see-through portal | 02 | Mini-Portal Smooth: smooth transition, understanding the camera | ||
03 | Mini-Portal Recursive: recursive portals - display portals within portals | 04 | Mini-Portal Optimization: optimization with scissors |
Glescraft
[編集]This series shows how to render a voxel based world, similar to Minecraft.
01 | Glescraft 1: basic voxel rendering | 02 | Glescraft 2: removing unnecessary voxel faces | ||
03 | Glescraft 3: texturing, lighting, fog, transparency | 04 | Glescraft 4: first person camera controls | ||
05 | Glescraft 5: drawing only what is on screen | 06 | Glescraft 6: adding and removing voxels | ||
07 | Glescraft 7: using geometry shaders |
Using the accumulation buffer
[編集]01 | Tutorial 01: motion blur | 02 | Tutorial 02: full-screen supersampling anti-aliasing | ||
03 | Tutorial 03: depth of field | 04 | Tutorial 04: order-independent transparency |
Cutting-edge OpenGL
[編集]If you do not need to target mobile devices or the web, you can upgrade to OpenGL 4.x. It notably introduces 3 new kinds of shaders: Geometry, Tessellation Control and Tessellation Evaluation.
01 | Tutorial 01: modify and create vertices on the fly with geometry shaders | 02 | Tutorial 02: dynamic mesh quality with tesselation |
and lots of other features.
Code quality
[編集]01 | Debugging: tips to help debug your OpenGL code | 02 | Performances: measuring and improving your application perfs |
Appendices
[編集]- OpenGL ES 2.0 Overview: OpenGL ES 2.0 (OpenGL for Embedded Systems 2.0) concepts and its differences to normal OpenGL
- Migrating from 1.x to 2.x: how to upgrade your code to use modern OpenGL
- Glossary: what do all those new weird words mean?
- APIs, Libraries and acronyms: how all acronyms relate to each others
- OpenGL Shading Language: elements of GLSL programming
- Shaders reference: input and output variables list
- Team: contributors to this wikibook
- Download code: Gitorious wikibooks-opengl project
Legacy OpenGL 1.x
[編集]"Legacy" OpenGL is about OpenGL 1.x and OpenGL ES 1.x, with a fixed pipeline and no shaders.
Starting Tutorial
[編集]- Setting Up A Programming Environment On Windows
- Setting Up OpenGL In The Programming Environment
- Drawing Primitives
- Immediate Mode
- Display Lists
- Vertex Arrays
- Basic Transformations
- Translation
- Rotation
- Scaling
- Custom Transformations
Basics
[編集]- Structure of a Typical OpenGL Application
- Drawing Rectangles
- Drawing Lines and Points
- Drawing Simple 2D Shapes
- OpenGL Naming Conventions
- Using Color
- Viewing Transformations
- Drawing Simple 3D Objects
- Perspective versus Orthographic Projections
Intermediate
[編集]- Smoothing Polygons with Normals
- Adding Lights
- Using Materials
- Using Textures
- Using Mipmaps
- Drawing Complex Polygons Using Tessellation
Advanced
[編集]- Optimizing OpenGL Code
- Drawing Shadows
- Drawing Using Quadrics
- Drawing Using NURBS and Curves
- Ambient Occlusion
Appendices
[編集]- Coordinate Transformations
- Understanding Transformation Matrices
- OpenGL Library Reference. functions and type reference for gl.h glu.h and glut.h
- Why OpenGL Exists and What It's Good For
- Migrating from 1.x to 2.x: how to upgrade your code to use modern OpenGL
Wikibooks
[編集]Related WikiBooks:
- GLSL Programming : wikibook on the use of the OpenGL Shading Language (GLSL) in Unity 3 and Blender 2.5, with much information on lighting and texturing
- Blender 3D: Noob to Pro: comprehensive book on using the Blender 3D modeling environment
Ports
[編集]The following websites provide conversion of the tutorials to other programming languages or platforms:
- https://github.com/alihelmy/lwjglTutorial : port to Lightweight Java Game Library (LWJGL) (blog)
- http://littlefootlandmines.blogspot.com/search/label/opengl%20tutorials : not really a port, but commented, progressive version of the tutorials code as the author follows them
Freely-licensed documentation and samples
[編集]- Learning Modern 3D Graphics Programming: another modern OpenGL tutorial, requiring v3.3 or later, MIT license (source repository)
- Learn OpenGL ES: Detailed, step-by-step OpenGL ES tutorials in Java for Android, and a bit of WebGL as well, CC BY-SA 3.0 license (source repository - Apache License 2)
- OpenGL Samples Pack: written in C++ based on the "core profile" specifications, aimed at easing upgrades to new OpenGL versions and features, MIT license (source repository)
- Introduction and examples for OpenGL 3.3: GFDL license
- A modern OpenGL FAQ: GFDL license
- OpenGLContext Python Tutorials: basic tutorials using PyOpenGL (BSD-style licenses)
- Paul's projects: OpenGL 1.x, two tutorials on shadow mapping and bump mapping, with code under the MIT license
- WebGL:
- Gregg Tavares’ WebGL articles: detailed 2D and 3D basics with emphasing on matrix operations; lots of diagrams and interactive animations (code - MIT license)
- WebGL at Mozilla Developer Network: WebGL overview, including embedding videos; CC BY-SA for articles, MIT and public domain for code
- three.js: impressive collection of demos using the three.js WebGL framework; code is MIT but models/data may be non-free
Non-freely-licensed documentation
[編集]- NeHe's OpenGL tutorial: OpenGL 1.x
- Collection of OpenGL fundamentals tutorials using C++ and Windows API: OpenGL 1.x
- ZeusCMD OpenGL Tutorials: OpenGL 1.x
- OpenGL Programming Examples: OpenGL 1.x,
Websites
[編集]Further reading
[編集]- OpenGL Architecture Review Board, et al: OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 2, Fifth Edition, Addison-Wesley, ISBN 0-321-33573-2
- OpenGL Architecture Review Board, et al: OpenGL Reference Manual: The Official Reference Document to OpenGL, Version 1.4, Addison-Wesley, ISBN 0-321-17383-X
- Wright, Richard S. Jr and Lipchak, Benjamin: OpenGL SuperBible, Third Edition, Sams Publishing, ISBN 0-672-32601-9