小糊涂的移动技术BLOG(Mobile Excite World)  
Mobile Dev Symbian/JavaMe/ Web Dev php/web 2.0/ Now Iphone.Opengles android is planning.
公告
  • i'm cnsoft. i am focus on mobile devlopment. symbian,javame,and now iphone, android is planning to be resarch. i am only one beginner。
    Donews Blog :http://blog.donews.com/cnsoft/
    Free AD: WB Editor 是支持中文 blog 写作的工具。



  • 欢迎支持我的GoogleADSENSE测试计划

  • 如果你看到了想要看的东西,不妨点击一下表示鼓励。
日历
<2008年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
统计
  • 随笔 - 165
  • 文章 - 2
  • 评论 - 237
  • 引用 - 1

导航

搜索

 

常用链接

随笔分类

随笔档案

相册

Links2me

最新评论

阅读排行榜

评论排行榜

 

 其实很简单.自己就是个搬运工而已。。其实连搬运都谈不上了,就是 copy...   但这是我的心得体会。拿来和你分享。请你顺手点击AD 是对我的鼓励。

 

  翻译一下:   http://www.scottlu.com/2008/04/fast-2d-graphics-wopengl-es.html

  关键字: Pbuffer, glTexSubImage2D, glDrawTex, GL_TEXTURE_CROP_RECT_OES,

  原文如下,

  "Thankfully, OpenGL ES has created the concept of a "PBuffer". A PBuffer is both a surface for rendering onto, that can also be used as a pixel buffer for a texture. It is assumed that PBuffers dynamically update, so using a PBuffer as a texture is designed to be inexpensive. They key thing for your 2D game, is that uploading a new texture into your PBuffer is also fairly inexpensive, using glTexSubImage2D().

Once your frame is composed in your PBuffer, you'll want to draw it onto your windowed surface. OpenGL ES v1.1 has a nice "extension api" called glDrawTex(). This is the fastest and easiest way of drawing a textured quad. Use this to draw your PBuffer contents to your window surface. Before you call glDrawTex(), be sure to set the clipping rectangle with glTexParameter / GL_TEXTURE_CROP_RECT_OES. Finally, your platform specific swap buffers api will copy your color buffer to the associated native window. This whole process will give you decent frame rates with minimal change to your existing game. To recap:

1. Use glOrtho to set up a parallel projection, useful for your 2D game.
2. Create a PBuffer surface and associate it with a texture name. Use powers of 2 dimensions.
3. Use glTexSubImage to update only the parts of the PBuffer that are changing (worst case, the whole frame).
4. Once the PBuffer is ready, draw it to your window surface by setting the cropping rect and calling glDrawTex.
5. Swap buffers. Goto 3. "  

 在Opengl es 处理2D 的图像时, 文中提到了2种方式,

 1种是将所有的代码转换成 opengl es 的. 因为之前进行一些优化的处理,而现在需要重新修改,还有自定义格式的图形,(非标准的图像格式,可能经过压缩处理的) 都是如此, 这样的运行效率应该是最高的. 

 2种 就是每次刷新屏幕的时候, 刷新时都画在一个屏幕上, 然后更新 纹理贴图, 但是这个操作很慢. 因为机器要转换成GPU识别的优化的格式.

 然后提到了 Pbuffer 的概念,  They key thing for your 2D game, is that uploading a new texture into your PBuffer is also fairly inexpensive, using glTexSubImage2D().  

 在调用 glDrawTex 之前 要设置 GL_TEXTURE_CROP_RECT_OES 函数,  具体的步骤如下,

  1. 设置好投影.

  2. 创建 pBuffer 的surface, 然后绑定到纹理的名称.

  3. 用 glTexSubImage2D 更新指定的区域

  4  一旦 pBuffer 准备就绪, 就可以调用 drawTex 来完成了.

  5 Swap Buffers 刷新缓冲, 回到第3步。

 

结合lipeng 同学前两天的问题, 似乎他就是用 glTexSubImage 来处理的, 不知道是否和这篇说的一致? 或者有一些遗漏的步骤没有处理好。看来这个原理上是行得通的。 待我这几天有时间来写一个Sample 测试一下。 

0
0
(请您对文章做出评价)
« 上一篇:opengl 如何渲染视频流.
» 下一篇:How to Downgrade From iPhone Firmware 2.2 to 2.1 视频教程降级iphone 2.2 到2.1
posted on 2008-12-29 13:55 小糊涂的超级blog 阅读(902) 评论(0)  编辑 收藏 网摘
 
Copyright © 小糊涂的超级blog Powered by: 博客园 模板提供:沪江博客