OpenGL 教學索引
     
 


在 MacOS 上設定 OpenGL:

這不是一個教學課程, 而是由 Tony Parker 一步一步的說明如何在 Mac OS 上安裝 OpenGL 和 Glut. Tony 很好意的將我的 OpenGL 教學課程移轉到 MacOS 上, 包含 GLUT. 我希望大家能好好的享用它.

我知道有許多人要求要有 Mac 版本, 那麼請大家給 Tony 一些支持, 告訴他你是如何的享受這個 Mac 版本. 如果沒有他的努力付出, 就不會有這個 Mac 版本的誕生.
 
     
 


在 Solaris 上設定 OpenGL :

這不是一個教學課程, 而是由 Lakmal Gunasekara 一步一步的介紹如何在 Solaris 上安裝 OpenGL 和 Glut. Lakmal 很好意的將我的 OpenGL 教學課程移轉到 Irix 和 Solaris 上. 我希望大家能好好的享用它.

如果你想將這個程式碼移植到其他的作業系統或程式語言上, 請與我聯絡, 讓我知道. 在你開始移植之前, 請記住我是希望所有的程式碼都能被移植, 而不要只移植一部份的教學課程. 這樣一來, 各種程式背景的人就可以學到和熟悉 VC 的人一樣的程度了.
 
     
 


在 Windows 上設定 OpenGL: (第一課)

在這個課程中, 我會教你如何設定, 並且在 Windows 視窗環境下使用 OpenGL. 這個課程的程式會顯示一個空白的 OpenGL 視窗, 可以將畫面切換為全螢幕或視窗模式, 在你按下 ESC 鍵或關閉視窗則結束程式. 聽起來沒什麼東西, 不過這個程式將會是以後所有其他課程的基本架構.

這對於了解 OpenGL 的工作原理是很重要的, 在於如何去建立一個 OpenGL 視窗, 以及如何寫一個易讀易懂的程式碼. 你可以下載在本課程最後的程式碼, 但是我明確的建議你在開始設計 OpenGL 程式之前, 應該至少先讀過這個課程一次, .
 
     
 


你的第一個多邊形: (第二課)

使用第一課的原始程式碼, 再加上一些程式碼來建立一個三角形和一個正方形在畫面上. 我知道你也許會覺得 "一個三角形和正方形... 哈! 別開玩笑了", 但是這的確是很了不起的事. 幾乎所有你在 OpenGL 建立的東西就是三角形和四方形. 如果你不知道如何在三度空間中建立一個簡單的小三角形, 那你將完全迷失方向了. 然而學習之路正是經由這一章.

一但你讀完這一章, 你應該會了解 X 軸, Y 軸和 Z 軸. 你會學習有關於物件在畫面中的上下左右前後的位移. 你應該會了解如何將物件放置於三度空間中你所想放的位置. 你也會學到一點有關於深度緩衝區 (放置物件在畫面上).
 
     
 


色彩: (第三課)

延伸自第二課, 我會教你如何建立一個華麗色彩在 OpenGL 中, 卻只需要一點點的付出. 你將會學到有關於平面著色以及平滑著色. 左邊的三角型使用平滑著色. 右邊的正方形則是使用平面著色.注意到三角型的顏色是如何的混和在一起的.

加入一堆色彩到 OpenGL 的專案中. 在了解平面著色以及平滑著色後, 你就可以大大的提昇你的 OpenGL 展示範例的樣子了.
 
     
 


旋轉: (第四課)

移往正確的方向. 在本課程中, 我會教你如何旋轉三角形和四邊形. 三角形會依 Y 軸旋轉, 四邊形則會依 X 軸旋轉. 這個課程會介紹兩個變數, rtri 用來儲存三角形的旋轉角度, 而 rquad 用來儲存四邊形的旋轉角度.

用多邊形來建立場景是很容易的. 而那些物件再加上動作就會讓場景活了起來. 在以後的課程我會教你如何將物件繞著畫面中的一個點旋轉著, 以至於能夠在場景中移動, 而不是只有繞著軸旋轉而已.
 
     
 


實體物件: (第五課)

現在我們有了設定多邊形, 四方形, 色彩, 以及旋轉的概念, 該是建立 3D 物件的時候了. 我們會用多邊形和四方形來建立物件. 這也是我們將延伸上一個課程的時候了, 把三角形改為色彩豐富的金字塔, 而把正方形改為立方體. 金字塔將使用混合色彩, 而立方體則每個面有不同的顏色.

在 3D 中建立物件是很費時的, 但是結果卻是很值得的. 你的想像力將是唯一的限制了.
 
     
 


材質貼圖: (第六課)

你問到的, 就在這兒了... 貼圖材質!!! 在這個課程中, 我將教你如何把點陣圖圖形貼到六面的立方體. 我們將會用第一課的 OpenGL 程式碼來建立這個專案. 用一個空白的 OpenGL 程式碼會比修改上一課的程式碼容易一些.

你將發現第一課的程式碼是很有價值的, 當你要很快的開發一個專案計劃時. 第一課的程式碼為你設定每件事了, 那你要做的事就是專心設計特效.
 
     
 


貼圖材質濾鏡, 光源 & 鍵盤控制: (第七課)

好了, 我希望你已經了解之前的每件事, 因為這是一個很大的課程. 我將教你兩個新的方法來過濾你的貼圖材質, 簡單的光源, 鍵盤控制, 可能還有更多 :) 如果你不確定你在這一課學到了什麼, 回頭再看一次. 在別的課程中玩玩這個程式碼. 別急, 最好花些時間把之前的每一課學好, 再進入這一課, 只要懂得夠多, 事情就好辦.
 
     
 


* 混色: (第八課)

有一個中場休息的理由. 一個來自酷斃了網站 Hypercosm 的程式設計師, 問到他是否可以寫個關於混色的課程. 第八課就是混色了. 時機真是太巧了! 這一課擴充了第七課. 混色是很酷的特效... 我希望大家好好享受這一課. 這課的作者是 Tom Stanis. 他花了很多心血在這個課程裡, 所以讓他知道你的感想. 混色不是一個好寫的主題呢.
 
     
 


在三度空間中移動點陣圖: (第九課)

這一課涵蓋了一些主題是你們所要求的. 你想要知道如何在 3D 下的畫面移動物件. 你想知道如何在畫面上畫出點陣圖, 而且不畫出圖像涵蓋著黑色的部分. 你想要簡單的動畫, 並且使用更多的混色. 這一課都會教你的. 你將會注意到這兒並沒有旋轉的方塊. 上一課程涵蓋了 OpenGL 的基礎. 每一個課程都延伸自上一個課程. 這一個課程則結合了你到之前所學的一切, 有關於如何在 3D 移動物件的資訊. 這一個課程是有一點難度, 所以在你進入這一個課程之前, 先確定你了解了前面的課程.
 
     
 


* 載入 3D 世界以及在 3D 世界中移動: (第十課)

這一課是你一直在等待的課程吧! 這個課程是由一位叫做 Lionel Brits 的程式設計師所寫的. 在這一課中, 你將學會如何由一個資料檔案來載入一個 3D 世界, 並且在 3D 世界中移動著. 程式碼改自第一課, 然而, 這個課程網頁只解釋用來載入 3D 場景的新加程式碼, 以及在 3D 世界中移動的部分. 下載 VC++ 程式碼, 在你閱讀課程時邊看著程式碼. 鍵盤按鍵可以設定 [B] 混色, [F] 濾鏡, [L] 光源 (然而光源不會在場景中移動), 移及 Page Up/Down 按鍵. 我希望你能享用 Lionel 所貢獻的這一課. 在我有時間的話, 我會讓這一課更容易讓人看懂的.
 
     
 


* OpenGL 旗子特效: (第十一課)

這個課程是 Bosco 所寫給你們的. 他做了一個非常酷的迷你展示程式叫做 worthless. 他享受著每個人對於他的展示程式的反應, 並且決定更進一步的解釋他是怎麼做出這個酷的效果, 在展示程式的最後. 這個課程的程式碼架構自第六課. 在讀完這個課程之後, 你應該能夠彎曲表面, 以及熟練的運用自己的材質貼圖. 如果你享用了這一課, 請記得 e-mail 給 Bosco, 讓他知道吧.
 
     
 


顯示串列: (第十二課)

Want to know how to speed up you OpenGL programs? Tired of writing lots of code every time you want to put an object on the screen? If so, this tutorial is definitely for you. Learn how to use OpenGL display lists. Prebuild objects and display them on the screen with just one line of code. Speed up your programs by using precompiled objects in your programs. Stop writing the same code over and over. Let display lists do all the work for you! In this tutorial we'll build the Q-Bert pyramids using just a few lines of code thanks to display lists.
 
     
 


點陣圖字型: (第十三課)

I think the question I get asked most often in email is "how can I display text on the screen using OpenGL?". You could always texture map text onto your screen. Of course you have very little control over the text, and unless you're good at blending, the text usually ends up mixing with the images on the screen. If you'd like an easy way to write the text you want anywhere you want on the screen in any color you want, using any of your computers built in fonts, then this tutorial is definitely for you. Bitmaps font's are 2D scalable fonts, they can not be rotated. They always face forward.
 
     
 


輪廓字形: (第十四課)

Bitmap fonts not good enough? Do you need control over where the fonts are on the Z axis? Do you need 3D fonts (fonts with actual depth)? Do you need wireframe fonts? If so, Outline fonts are the perfect solution. You can move them along the Z axis, and they resize. You can spin them around on an axis (something you can't do with bitmap fonts), and because proper normals are generated for each character, they can be lit up with lighting. You can build Outline fonts using any of the fonts installed on your computer. Definitely a nice font to use in games and demos.
 
     
 


貼圖材質字型: (第十五課)

Hopefully my last font tutorial {grin}. This time we learn a quick and fairly nice looking way to texture map fonts, and any other 3D object on your screen. By playing around with the code, you can create some pretty cool special effects, Everything from normal texture mapped object to sphere mapped objects. In case you don't know... Sphere mapping creates a metalic looking object that reflects anything from a pattern to a picture.
 
     
 


* 看起來很酷的霧: (第十六課)

This tutorial was generously donated to the site by Chris Aliotta. It based on the code from lesson 7, that why you're seeing the famous crate again :) It's a pretty short tutorial aimed at teaching you the art of fog. You'll learn how to use 3 different fog filters, how to change the color of the fog, and how to set how far into the screen the fog starts and how far into the screen it ends. Definitely a nice effect to know!
 
     
 


* 2D Texture Font: (第十七課)

The original version of this tutorial was written by Giuseppe D'Agata. In this tutorial you will learn how to write any character or phrase you want to the screen using texture mapped quads. You will learn how to read one of 256 different characters from a 256x256 texture map, and finally I will show you how to place each character on the screen using pixels rather than units. Even if you're not interested in drawing 2D texture mapped characters to the screen, there is lots to learn from this tutorial. Definitely worth reading!
 
     
 


* Quadratics: (第十八課)

This tutorial was written by GB Schmick the wonderful site op over at TipTup. It will introduce you to the wonderful world of quadratics. With quadratics you can easily create complex objects such as spheres, discs, cylinders and cones. These object can be created with just one line of code. With some fancy math and planning it should be possible to morph these objects from one object into another. Please let GB Schmick know what you think of the tutorial, it's always nice when visitors contribute to the site, it benefits us all. Everyone that has contributed a tutorial or project deserves credit, please let them know their work is appreciated!
 
     
 


Particle Engine Using Triangle Strips: (第十九課)

Have you ever wanted to create an explosion, water fountain, flaming star, or some other cool effect in your OpenGL program, but writing a particle engine was either too hard, or just too complex? If so, this tutorial is for you. You'll learn how to program a simple but nice looking particle engine. I've thrown in a few extras like a rainbow mode, and lots of keyboard interaction. You'll also learn how to create OpenGL triangle strips. I hope you find the code both useful and entertaining.
 
     
 


Masking: (第二十課)

Up until now we've been blending our images onto the screen. Although this is effective, and it adds our image to the scene, a transparent object is not always pretty. Lets say you're making a game and you want solid text, or an odd shaped console to pop up. With the blending we have been using up until now, the scene will shine through our objects. By combining some fancy blending with an image mask, your text can be solid. You can also place solid oddly shaped images onto the screen. A tree with solid branches and non transparent leaves or a window, with transparent glass and a solid frame. Lots of possiblities!
 
     
 


Lines, Antialiasing, Timing, Ortho View And Simple Sounds: (第二十一課)

This is my first large tutorial. In this tutorial you will learn about: Lines, Anti-Aliasing, Orthographic Projection, Timing, Basic Sound Effects, and Simple Game Logic. Hopefully there's enough in this tutorial to keep everyone happy :) I spent 2 days coding this tutorial, and about 2 weeks writing this HTML file. If you've ever played Amidar, the game you write in this tutorial may bring back memories. You have to fill in a grid while avoiding nasty enemies. A special item appears from time to time to help make life easier. Learn lots and have fun doing it!
 
     
 


* Bump-Mapping, Multi-Texturing & Extensions: (第二十二課)

This tutorial was written by Jens Schneider. Right off the start I'd like to point out that this is an advanced tutorial. If you're still uncertain about the basics, please go back and read the previous tutorials. If you're a new GL programmer, this lesson may be a bit much. In this lesson, you will modify the code from lesson 6 to support hardware multi-texturing on cards that support it, along with a really cool visual effect called bump-mapping. Please let Jens Schneider know what you think of the tutorial, it's always nice when visitors contribute to the site, it benefits us all. Everyone that has contributed a tutorial or project deserves credit, please let them know their work is appreciated!
 
     
 


* Using Direct Input With OpenGL: (第二十三課)

This tutorial was written by Justin Eslinger and is based on lesson 10. Instead of focusing on OpenGL this tutorial will teach you how to use DirectInput in your OpenGL programs. I have had many requests for such a tutorial, so here it is. The code in lesson 10 will be modified to allow you to look around with the mouse and move with the arrow keys. Something you should know if you plan to write that killer 3D engine :) I hope you appreciate Justin's work. He spent alot of time making the tutorial unique (reading textures from the data file, etc), and I spent alot of time tweaking things, and making the HTML look pretty. If you enjoy this tutorial let him know!
 
     
 


* Sphere Mapping Quadratics In OpenGL: (第二十四課)

This tutorial was written by GB Schmick and is based on his quadratics tutorial (lesson 18). In lesson 15 (texture mapped fonts) I talked a little bit about sphere mapping. I explained how to auto-generate texture coordinates, and how to set up sphere mapping, but because lesson 15 was fairly simple I decided to keep the tutorial simple, leaving out alot of details in regards to sphere mapping. Now that the tutorials are a little more advanced it's time to dive into the world of sphere mapping. TipTup did an excellent job on the tutorial, so if you appreciate his work, let him know!
 
     
 


Tokens, Extensions, Scissor Testing And TGA Loading: (第二十五課)

In this tutorial I will teach you how to read and parse what OpenGL extensions are supported by your video card. I will also show you how to use scissor testing to create a cool scrolling window effect. And most importantly I will show you how to load and use TGA (targa) image files as textures in projects of your own. TGA files support the alpha channel, allowing you to create some great blending effects, and they are easy to create and work with. Not only that, by using TGA files, we no longer depend on the glAUX library. Something I'm sure alot of you guys will appreciate!
 
     
 

我並不是一個程式設計專家. 我只是一個普通的程式設計師, 每天學習關於 OpenGL 的新東東.
我不會要求去知道一切的東西. 我不保證我的程式碼是沒有臭蟲的. 我已經
盡可能的減少所有人為的臭蟲, 但是這並不都是一件簡單的事.
請在閱讀這些課程時記住這一點!

 
     
 

Back To NeHe Productions!
中文版由 Macbear 翻譯