GLPaint如何工作 [英] How does GLPaint work

查看:45
本文介绍了GLPaint如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完全确定OpenGL-ES菜鸟问题.如果有人能解释苹果如何做到GLPaint或更好地完成他们如何做到这一点的非常基本的代码,我将很高兴.老实说,我并不是要您编写程序,而是要了解苹果如何实现GLPaint绘图功能的基础知识.

Ok completely OpenGL-ES noob question. If anyone could explain how apple does GLPaint or better yet the VERY BASIC code of how they accomplished that, I would be thrilled. I am honestly not trying to ask for you to write my program, but trying to understand the basics of how apple accomplished the GLPaint drawing feature.

P.S:我不需要颜色转换,只需要画图(很明显)
请帮助

P.S: I don't need the color conversion, just the drawing (obviously)
Please help

推荐答案

我不知道为什么有人会产生比分析非常有趣.我不知道此示例的逐行分析是否是了解其功能的最佳方法.

I don't know why someone would produce simpler code than that which already exists for the Apple GLPaint example, yet does the same thing. The analysis that Kenny points to is interesting, if a little odd. I don't know if a line-by-line analysis of this example is the best way to learn what it does.

在iPhone上使用OpenGL ES时,需要在特定类型的Core Animation图层(CAEAGLLayer)中进行绘制,该图层位于UIView内.该示例中的EAGLView类包含用于设置此类图层托管视图的样板代码.

When working with OpenGL ES on the iPhone, you need to do your drawing in a particular type of Core Animation layer, a CAEAGLLayer, which is hosted inside of a UIView. The EAGLView class in that example contains boilerplate code for setting up such a layer-hosting view.

执行实际绘图的视图是PaintingView,它是EAGLView的子类.PaintingView处理触摸事件,并沿您的手指画出的线每隔这么多像素就逐渐绘制画笔纹理.当需要擦除屏幕时,将清除OpenGL ES上下文.

The view where the actual drawing is performed is the PaintingView, a subclass of EAGLView. The PaintingView handles touch events, and incrementally draws a brush texture every so many pixels along the line drawn by your finger. When the screen needs to be erased, the OpenGL ES context is cleared.

如果您遇到的是基本的OpenGL ES设置,我建议您根据Xcode中的OpenGL ES应用程序模板创建一个新项目,并查看该非常简单的启动应用程序的工作原理.

If it's the basic OpenGL ES setup that has you stumped, I'd recommend creating a new project based on the OpenGL ES Application template in Xcode and seeing how that very simple starting application works.

这篇关于GLPaint如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆