opengl glutmainloop() [英] opengl glutmainloop()

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

问题描述

我刚开始使用OpenGL,似乎不容易理解glutMainLoop()的工作原理,到底发生了什么?在任何函数调用响应之前,它都不会做任何事情吗?

i just started off using OpenGL and it seems it is not easy to understand the working of the glutMainLoop() what really happens there? Does it stay there doing nothing till any of the function calls responds?

推荐答案

它一遍又一遍地调用您的显示回调,在它们之间调用空闲,以便在可能的情况下可以保持特定的帧速率,在必要时可以保持其他帧速率(例如,如果调整大小)窗口或触发输入事件.

It calls your display callback over and over, calling idle between so that it can maintain a specific framerate if possible, and others if necessary (such as if you resize the window or trigger an input event).

本质上,此函数内是主程序循环,其中GLUT可以为您完成大部分工作,并允许您简单地在这些回调中设置特定的程序逻辑.自从我与GLUT合作以来已经有一段时间了,一开始肯定令人困惑.

Essentially, within this function is the main program loop, where GLUT does most of the work for you and allows you to simply set up the specific program logic in these callbacks. It's been a while since I've worked with GLUT, and it is certainly confusing at first.

在您的显示回调中,显然应该是绘制应进行的操作的主要逻辑.在空闲回调中,应该执行一些非常轻量级的操作,以确定从上次调用显示到下一次调用应更改的状态.例如,如果要制作动画,则可以在其中更改其位置或方向.

In your display callback should obviously be your main logic to draw whatever it is that should be going on. In the idle callback should be some very lightweight operations to determine what the change in state should be from the last time display was called to the next time. For example, if you're animating something, this would be where you change its position or orientation.

这篇关于opengl glutmainloop()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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