应重新绘制 Bspline,而不删除窗口的所有其余部分
在我的 mousefunc 中,我调用函数 bspline。它的工作原理如下: 使用鼠标,您可以放置控制点,并根据这些点绘制 bspline。因此,如果您绘制了三个点,则会显示这些点之间的曲线。通过添加另一个点,旧曲线就会消失,新曲线就会出现。这个新点现在位于这四个点之间。这效果很好。但是:此 bspline 曲线仅显示在一个视口中。该视口有黑色边框。当我的 bspline 被重绘时,这个边框就会消失。发生这种情况是因为调用 glutPostredisplay。因为在我的 glutDisplayFunc 中我调用 glClear(GL_COLOR_BUFFER_BIT)。所以这是很自然的事情发生。如果我删除 displayfunc 中的 glClear(GL_COLOR_BUFFER_BIT) ,边框会保留,但旧曲线也会保留。即使我说应该重新绘制边界,也不会发生任何事情。我想不出替代方案。如果您能帮助我,我将不胜感激...
In my mousefunc i call a function bspline. It works like this:
With your mouse you can put controllpoints and according to these points the bspline is drawn.So if you have drawn three points a curve between those points is displayed. By adding another point the old curve disappears and a new one appears. This new one lies now between the four points.This works just fine. BUT: This bspline curve is only displayed in one viewport.This viewport has a black border. This border disappears when my bspline is redrawn. This happens because of calling glutPostredisplay. Because in my glutDisplayFunc i call glClear(GL_COLOR_BUFFER_BIT). So it is the natural thing to happen. If i delete the glClear(GL_COLOR_BUFFER_BIT) in my displayfunc the border stays but the old curves stay too. Even if i say that the border should be redrawn nothing happens. I cant think of an alternative. Would appreciate it if you could help me...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 OpenGL 中,通常的方法是每当场景的某些部分发生变化时重新渲染整个场景。在您的情况下,更改 B 样条曲线的控制点应触发场景的重新显示,而不是在 mouseclick 处理函数中执行绘图操作。
OpenGL 没有几何持久性,它只是将图元绘制到基于像素的帧缓冲区。因此你必须使用它。
为了澄清,一些伪代码:
In OpenGL the usual approach is to rerender the whole scene whenever some part of it changes. In your case changing the control points of the B-Spline should trigger a redisplay of the scene instead of perform drawing operations in the mouseclick handler function.
OpenGL has no geometry persistency, it just draws primitves to a pixelbased framebuffer. And as such you must use it.
To clarify, some pseudocode: