在 Cinder 中绘制文本
我想知道是否有一种方法可以绘制 gl::texture
文件,而不必每次循环都使用 gl::draw
命令。有没有办法让我画一次,然后就不用担心了。
在 draw()
的每个循环上绘制图像会减慢我的应用程序的速度,因此我只想在屏幕上绘制一次图像,然后在需要时更新它们。
I was wondering if there is a way to draw a gl::texture
file with out having to use the gl::draw
command every loop. Is there a way I can draw it once, and then not worry about it.
Drawing the image on every loop of draw()
is slowing down my application, so I'd like to only draw things once on the screen and then update them if need be.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引用 Cinder 的教程:
“当您创建一个新的 Cinder 项目时,您会注意到有一些为您声明的函数。每个 Cinder 项目都由三个主要函数组成。您可以在 setup() 方法中初始化变量,该方法被称为当你的程序开始时,你在 update() 方法中更改这些变量,最后,你在程序窗口中更新和绘制内容,然后更新和绘制,更新并绘制,更新然后继续画,直到你退出应用程序。”
有一种方法可以在 OpenGL 和 Cinder 中永久绘制对象,但我不推荐它。是在绘图函数中禁用 gl::clear() 。但您不能有选择地删除任何不需要的对象。您必须从头开始渲染场景。 OpenGL 的帧缓冲区更像是一块画布。每次调用 gl::clear() 时,您都会拿起画笔,将画布涂成黑色或使用 gl::clear() 指定的任何颜色。之后,帧缓冲区是“白板”,您必须从头开始绘制要显示的所有内容。如果在绘制新对象时不声明任何 gl::clear() 命令,就像您的画布保持不变,并且在已绘制的对象之上绘制对象。
Quoting from Cinder's tutorials:
"When you create a new Cinder project, you will notice there are a few functions declared for you. Every Cinder project is made up of three main functions. You initialize your variables in the setup() method which is called once when your program begins. You make changes to those variables in the update() method. And finally, you draw() content in your program window. Update and draw are the heartbeat of any Cinder project. UpdateSetup, then update and draw, update and draw, update and draw, on and on until you quit the application."
There's a way though to draw objects permanently in OpenGL and concequently in Cinder but I wouldn't recommend it. Is to disable gl::clear() in your draw function. You can't though selectively delete any unneeded object. You will have to render your scene from scratch. Think of OpenGL's frame-buffer more of a canvas. Everytime you call gl::clear() you take the brush and you paint your canvas black or what ever color you specify with gl::clear(). After that the frame-buffer is "tabula rasa" you have to draw everything you want to display from scratch. If you don't state any gl::clear() command when you draw a new object is like your canvas stays intact and you draw your object on top of the already drawn.