How does GLPaint work

好久不见. 提交于 2019-12-12 04:38:18

问题


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: I don't need the color conversion, just the drawing (obviously)
Please help


回答1:


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.

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.

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.

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.



来源:https://stackoverflow.com/questions/2044438/how-does-glpaint-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!