Joe's OpenGL ES 2.0 系列經典入門教程(第一課:Introduction)

偶然機會,大柚發現一套非常適合iOS平臺的OpenGL ES 2.0 入門E文教程,於是準備把該系列教程搬到CSDN上來。


文章來源:

http://www.endodigital.com/opengl-es-2-0-on-the-iphone/part-one-introduction/

 

Part One:Introduction

I’ve been a software developer for a long time now, over twenty years, but until the iPhone I had never seriously played with 3D graphics programming. As I usually do when I start trying to learn something new, I bought a few books and started searching the web for examples. After just a few hours I could tell this was going to be difficult.

Not necessarily because OpenGL ES it self is terribly complex, although parts of it certainly are, but more because most of the examples I could find were for OpenGL ES 1.1,and I wanted to learn 2.0. In OpenGL ES 1.1, many of the graphics manipulations were taken care of for you by setting values in certain functions before asking OpenGL to render your stuff. In OpenGL ES 2.0, those functions no longer exist,and the programmer is expected to figure out the math on their own.

The books I had bought for developing games on the iPhone all dealt with 1.1 as well, so I could only ‘think’ in OpenGL ES 1.1, and the ES 2.0 example generated by Xcode was a little too ‘bare-boned’ to be very helpful. So I started scroungingaround and trying all kinds of strange things in the code, and even had to learn how to perform matrix math on my own.

So many of the OpenGL tutorials available on the web contain the caveat “you’ll need to know how to multiply matrices, but I don’t have time to get into that here.”Unfortunately, OpenGL ES 2.0 is all about  the matrices, and trying to write a proper  OpenGL ES 2.0 tutorial without covering the matrix math in detail is like trying to trying to teach someone to play so litaire with only one suit of cards – you can sort of see how it would work, but you won’t be able to do it yourself without that critical missing piece.

As my OpenGL ES2.0 ‘Hello World’ program, I had simply wanted to write a small program to display a cube that the user could rotate. It didn’t seem like it would be too difficult to do, but for someone coming into OpenGL ES 2.0 on the iPhone as fresh as I was, it was quite a mental work out. Now that I’ve finally got it working, I thought I’d share what I’ve learned with two goals in mind: firstly,I know how difficult it is to find solid, complete OpenGL ES 2.0 examples for the iPhone out there, and secondly, I know I need to learn more, and may have mistakes in this tutorial, which I hope the more knowledgable readers will help me correct.

Throughout this tutorial, I will be working in the OpenGL ES Application template as generated by Xcode 4.0. We will start with a fresh project as generated by Xcode, then modify the code in steps until we have completed my version of ‘Hello World’,with each step introducing another piece of the puzzle needed to complete the code.


第二課:  basics

 

文章來源: http://www.endodigital.com/opengl-es-2-0-on-the-iphone/part-two-opengl-basics/

First of all, what is OpenGL,  anyway? According to Wikipedia,OpenGL is “a standard specification defining a cross-language, cross platformAPI for writing applications that produce 2D and 3D computer graphics.” The specifications for OpenGL are currently maintained by the KhronosGroup, which is a group of people from various companies inrelated industries.

The full OpenGL library is used by computers to drive the high-powered graphics cards that we put in our machines to play the latest video games and heat up our rooms. But for smaller devices like the iPhone, we use OpenGL ES, which is a subset of thefull OpenGL specification. The ‘ES’ stands for Embedded Systems, but don’tthink that means it’s not powerful. OpenGL ES on the iPhone is capable of some amazing things, and if you’ve played around  with Epic Citadel from Epic Games, you know what I mean.

Originally, the iPhone supported only OpenGL ES 1.1, which you’ll often hear described as a‘fixed-pipeline’ system, while the more recently-supported OpenGL ES 2.0 is described as having a ‘programmable-pipeline’. But what does that mean to a developer,and why does it matter?

In OpenGL ES 1.1, the developer was given a library of functions to set data values for the rendering process, such as altering data in matrices for positional and rotational data,and setting up lighting and camera parameters. Once you had specified the available parameters, OpenGL would go off and do its thing, rendering the scene in a particular way using the data provided by the programmer to tweak certain things. Life was good, but a little predictable, because the rendering process(or pipeline) was ‘fixed’.

In OpenGL ES 2.0, all those handy functions for setting up the rendering parameters are gone, and instead we use ‘shaders’, which are little programs that OpenGL will run whenit’s time to render something. OpenGL no longer cares what you want it to dowith the camera, or the lights, or the objects you have defined. The way these things are rendered are no longer ‘fixed’, they are now altered programmatically, through the shaders that we code, at the appropriate steps in the rendering process (or pipeline), hence the phrase ‘programmable-pipeline’.

With a little extrawork, graphics programmers can now do a lot more during the rendering process,and have much more control over how OpenGL will render things.

We’ll learn more aboutshaders when we go through the template that Xcode uses for its OpenGL ESApplication projects.

Rather than spend a lotof time right now going over all of the conceptual bits and pieces of howOpenGL ES 2.0 works, let’s dive right into the Xcode project template and savethe explanations for the relevant sections of code. Putting the concepts together with the actual code has always worked best for me, so that’s how I’ll construct this tutorial.

 

本系列教程從第三課開始正式講解OpenGL ES 2.0的各知識點,敬請期待!



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章