重新定位形状/对象 - OpenGL
我想重新定位圆形、三角形、直线和圆弧。我该怎么办?我在网上搜索了解决方案,但没有任何具体解决该问题的方法。
任何能引导我走向正确方向的意见都会有所帮助。
我正在使用 C++ 和 opengl。
I would like to reposition a circle, triangles, lines and an arc. How do I go about it? I've searched the web for solutions but nothing that address the issue specifically.
Any input that will lead me in the right direction will be helpful.
I'm using C++ with opengl.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
搜索函数
glTranslatef
作为旁注,您可能还想查看
glRotatef
和glScalef
。如果您对翻译一无所知,请查找翻译矩阵,首先在 2D 中学习,然后在 3D 中学习。Search for the function
glTranslatef
As a side note, you might want to look at
glRotatef
andglScalef
also. If you know nothing about translation, look for translation matrix, first learn it in 2D and then in 3D.那么您已经绘制了场景,现在想要更改对象的位置?
那么,您需要了解的是,OpenGL 不维护某种场景图。提交绘制调用后,只会更新目标帧缓冲区,仅此而已。你想改变什么吗?清除屏幕,重新绘制所有内容,但现在应用了调整。
实际上,OpenGL 只是绘制东西,它只不过是操作系统(视口/窗口)提供的一些纸张的复杂画笔(纹理)和铅笔(基元)。
由于评论而编辑
通常带有动画的交互式OpenGL图形程序,用命令式编程语言编程,结构如下(伪代码)
So you already did draw the scene and now want to change the position of the objects?
Well then, all you need to understand is, that OpenGL doesn't maintain a scene graph of sorts. After submitting a draw call, things get only updates on the target framebuffer and that's it. You want to change something? Clear the screen, redraw everything, but now with the adjustments applied.
Really, OpenGL just draws things, it's nothing more than sophisticated brushes (textures) and pencils (primitives) for some paper offered by the operating system (viewport/window).
EDIT due to comment
The usual interactive OpenGL graphics program with animations, programmed in a imperative programming language, is structured like this (pseudocode)