Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复 delay_ms(0) 延时过高的问题 #141

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

yixy-only
Copy link
Collaborator

@yixy-only yixy-only commented Dec 17, 2023

造成 delay_ms(0) 较高延时的两个因素:

  • delay_ms(0) 里加入了一个固定延时 ege_sleep(1),这个延时在默认设置下通常是 15 到 17ms (EGE 使用了 timePriodBegin(1) 将定时器周期设置为 1 ms,所以额外延时是 1 到 2 ms) 。
  • 代码里加了个 setviewport() 设置视口区域,但视口区域并没有做任何修改,应该是多余的,并且对帧率有不小的影响。刷新时不应该改变视口区域。

现在将 ege_sleep(1) 改为 ege_sleep(0),Sleep() 函数在微软文档里的描述是 "如果值为0,则线程会将其时间片的剩余部分放弃给已准备好运行的任何其他线程。 如果没有其他线程可供运行,函数将立即返回,并且线程继续执行。"

@wysaid wysaid self-assigned this Jan 22, 2024
@wysaid wysaid merged commit a6231b0 into wysaid:master Jan 22, 2024
1 check passed
@yixy-only yixy-only deleted the fix_delay_ms branch January 25, 2024 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants