iOS Graphics Overview
core animation是ios图形子系统的基础,UIView对象由core animation layer支持。各种各样的layer更新他们的内容,由core animation动画和合成,并向显示设备呈现。OpenGL ES是Core Animation的客户,要使用OpenGL ES需要创建一个UIView,这个UIView由一个特殊的core animation layer支持,这个特殊的layer是一个CAEAGLLayer对象。CAEAGLLayer是OpenGLES和core animation联系的桥梁。当应用程序渲染完一帧后,CAEAGLLayer的内容被呈现并且和其他view的数据组合。
Overview of OpenGL ES
OpenGL ES命令被提交到rendering context。这些命令可以读取context的状态,改变context的状态,创建修改和销毁OpenGL ES Object,以及提交被渲染的几何体,几何体通过流水线处理最终光栅化到framebuffer。
renderbuffer: 是某种特定格式的2d图形。格式可以是颜色信息,也可以是深度或模板信息。renderbuffer一般不单独使用,而是被收集作为fraembuffer的一部分使用。
Framebuffers: 是图形流水线的最终目的地。一个framebuffer object其实是一个容器,包含了attach上去的纹理和renderbuffer。
iOS Classes
所有的OpenGL ES实现需要提供平台相关的代码创建rendering context用于绘制到屏幕。iOS通过一个Objective-C的接口EAGL实现。几个主要的类:
EAGLContext : 定义了rendering context。应用程序创建和初始化一个EAGLContext,设定他为当前的OpenGL命令的目标。OpenGL命令通常存放在一个context所维护的队列里面,并在之后被执行。EAGLContext也提供了方法将图像呈现给Core Animation。
EAGLSharegroup: 每个EAGLContext对象包含一个EAGLSharegroup对象的引用。当OpenGL ES需要为context分配一个对象时,实际是sharegroup分配并维护对象。这样可以让多个context共享对象。另一种共享对象的方法是单个context,多个framebuffer object,这种情况下不需要切换context,而需要切换target for rendering。
EAGLDrawable Protocol: CAEAGLLayer实现了这个协议,从而可以将OpenGLES renderbuffers和Core Animation图形系统联系起来。
确定OpenGL ES能力
在初始化OpenGL ES rendering context(即EAGLContext)的时候可以确定设备支持的OpenGL ES版本。
创建使用es 1.1的context:
EAGLContext* myContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
创建使用es 2.0的context:
EAGLContext* myContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
如果OpenGL ES的某个实现不支持,initWithAPI会返回nil。
所以,如果想同时支持2.0和1.1,先测试是否能创建2.0的context,如果返回nil,则创建1.1的。
context初始化后,从他的API属性可知道所支持的OpenGL ES版本。
Working with OpenGL ES Contexts and Framebuffers
1)创建EAGL Context
EAGLContext* myContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
[EAGLContext setCurrentContext: myContext];
2)创建 Framebuffer Objects
es2.0直接支持fbo, ios的es1.1通过GL_OES_FRAMEBUFFER_OBJECT扩展支持。fbo允许应用程序精确的控制color,depth,stencil targets的创建。这些targets通常是renderbuffers,即具有一定宽度高度和格式的2d图形像素,另外color target可以指向一个纹理。创建framebuffer的过程是:1 创建一个frame buffer object 2 创建一个或多个targets(renderbuffers or textures),给他们分配空间并attach到fbo上 3 测试framebuffer的完整性。
创建renderbuffer,可以是offscreen, texture(仅限color), Drawable(通过EAGLLayer)
分享到:
相关推荐
Learning OpenGL ES for iOS a Hands-on Guide to Modern 3D Graphics Programming, 基于iOS 讲解OpenGL ES开发,支持kindle
This book covers the basics in both theory of 3D and implementations using the industry standard OpenGL ES toolkit for small devices. While iOS supports both flavors—version 1.x for the easy way, and...
一本介绍iOS 上OpenGL ES编程的好书,适合游戏开发人员阅读和学习。
All code has been built and tested on iOS 7, Android 4.3, Windows (OpenGL ES 3.0 Emulation), and Ubuntu Linux, and the authors demonstrate how to build OpenGL ES code for each platform. Coverage ...
A lightning-fast particle system for OpenGL ES on iOS. Primitives are generated only once on the CPU, and particle positions are calculated in the vertex shader. Currently only supports constant-color...
Swift 实现的基于 OpenGL ES3 的涂鸦绘图库,支持自定义纹理、压力感应、自动笔触等特性。.zip,iOS painting library based on Metal. 神笔马良有一支神笔(基于 Metal 的涂鸦绘图库)
Learning iOS Game Programming Michael Daley First printing September 2010 This book describes the key components needed to create this 2D game.It covers both the technology,such as OpenGL ES and ...
with chapters on storyboards and iCloud, for example, as well as significant updates to existing chapters to bring them in line with all the changes that came with the iOS 5 SDK. You'll have ...
with chapters on storyboards and iCloud, for example, as well as significant updates to existing chapters to bring them in line with all the changes that came with the iOS 6 SDK. You'll have ...
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:...
You’ll learn to draw using Quartz 2D and OpenGL ES, add multitouch gestural support (pinches and swipes) to your applications, and work with the camera, photo library, accelerometer, and built-in ...
Game And Graphics Programming For iOS And Android With Opengl ES 2, Free Books Online Pdf
艾库波v0.6.x现在适用于iOS和OSX v0.4.2(稳定版)可供下载: : 待办事项:•使用预处理标志和主持OpenGL调用将OpenGLES移植回OpenGL•添加用于切换选项的用户界面•创建用于输入自定义行为的用户界面•创建简化的...
libGDX is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux, Mac OS X, Android, your WebGL enabled browser and iOS. 用什么方式能够实现高效的流畅的...
1.sunmap是基于cocos2d-x上构建的地图框架,采用OpenGL ES的渲染方式 2.sunmap只支持Web墨卡托投影坐标,比如Google,OSM,Bing,ArcGis online以及高德地图 3.到目前为止,sunmap还有很多要做的事情,而且sunmap的...
is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux, Mac OS X, Android, iOS and your WebGL enabled browser. It provides a well-tried and robust ...
OpenGL (ES) that works on Windows, Linux, Mac OS X, Android, your WebGL enabled browser and iOS. Getting Started Setup your development environment (Eclipse, Intellij IDEA, NetBeans) Create a libGDX ...
- OpenGL ES 3.1 (Android 8.0 Oreo or later) - Modern Consoles (PS4, Xbox One) To provide the fastest possible performance, GPU Instancer utilizes Indirect GPU Instancing using Unity's ...