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的各知识点,敬请期待!



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值